The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged


Edit: This answer is not specifically geared toward project-specific naming, but I believe that the principle can be applied as well. In one of my applications, I have three separate VS projects which I do not separate with either namespaces nor class prefixes as a naming convention. Namespaces would be a possible way to separate the entities by project, and ...


Both pre- and postfix have basically the same advantages over infix notation. The most important of these are: much easier to translate to a format that is suitable for direct execution. Either format can trivially be turned into a tree for further processing, and postfix can be directly translated to code if you use a stack-based processor or virtual ...


This will at least partly depend on the language. Id say it is, in general, bad practice in languages that provide proper namespace facilities but good practice in languages that don't.


Tricks? What for? It doesn't feel intuitive for you yet because your mental parser isn't used to it. It'll become better if you just use it and read it over and over again.


The difference is in the default execution models of prefix and postfix languages. A prefix language like say a Lisp is typically based on an lambda calculus inspired node-substitution based evaluation. So in order to evaluate + 1 * 3 2 I would first make a tree + 1 * 3 2 And then substitute inner expressions to simplify + 1 6 7 In order to get ...


Mentally reading it left to right as spoken language with the proper verbs can help. For example (+ 3 2) could be "add three and two". In the more general case, you can say "perform $operation on $operands". Applied to the same case: "Perform the add operation on three and two".


You could think about it as a kind of function call: (operator operand1 operand2 ...) There is nothing very special about it. If you overload operators in C++ (and many other languages that allow it) you often have to define this kind of function exactly that way: MyClass operator+(MyClass const& x, MyClass const& y);


Many languages use a mix of prefix, infix and even postfix. Lisp just uses only prefix - by default. If sin(x) is intuitive from mathematics, then (sin x) is not far away. If move(dog,home) is a traditional procedure call, then in Lisp it is just (move dog home). Lisp does not make any exception for mathematics and treats +, -, * and others like ordinary ...


When (eventually) "Everything is a function call" (or a special form, or a macro-expansion, both having the surface syntax of "function call") clicked, it felt pretty natural. So, for (= 1 2) I read that as 'call the numeric equals comparison on 1 and 2'.


Notice that LISP languages (e.g. Common Lisp, Scheme, Clojure and many specific dialects inspired by them like AutoLISP, Emacs-LISP, MELT, etc...) are all using a prefix-syntax: every expression starts with a left parenthesis, then the operator, then the operands, then the right parenthesis. These expressions are called S-expressions. For example 1+2*3 is ...


(Short answer – it depends: there are a gazillion different IDEs and editors which might all handle such cases slightly differently, so there is no single user interface which everyone uses) The problem is much larger than just languages where the method comes before the invocant. What horror must it be to program in languages that don't even support OOP, ...


I would say that the line should be drawn when the class name seems somewhat generic but has a very particular implementation and meaning that is specific to the containing library/framework/api. Also if the library/api/whatever is expected to be used in the context with other compenents that may have classes with similar or identical names. You could also ...

Only top voted, non community-wiki answers of a minimum length are eligible