Tag Info

New answers tagged

0

If you can access tokens with an index, there's the temptation to jump ahead or behind, and you can do so, however you generally wind up with very hard code to understand. Good parsers have a grammar which determines what they should look for next based on where they are in the grammar, and if the grammar is done right, you should never be faced with ...


2

Common parsing techniques rely on inspecting a single 'current' token from a stream of such tokens. In some variations a certain amount of lookahead is required, but is usually provided from within the parser and not by indexing forwards and backwards across the lexer stream. In other words the data structure you will most likely need is some kind of ...


0

Given that languages already exist that bracket the possible behaviours you are considering, the question is: which would suit your users better? To create a programming language you need an intended audience of developers who will use it. When you ask a question of this type you then ask which choices will suit your intended users better. If your users ...


4

You should consider that alternative systems can also be acceptable design decisions. Shells: 0 exit status is true, non-zero is false The example of shells treating a 0 exit status as true has already been mentioned. $ ( exit 0 ) && echo "0 is true" || echo "0 is false" 0 is true $ ( exit 1 ) && echo "1 is true" || echo "1 is false" 1 is ...


2

In many languages the convention is to use PascalCasing for types(the only exceptions I can think of are lisps and STL). Using camelCasing or snake_casing allows you to easily name a variable after it's type(like void foo(Bar bar)). snake_casing also allows that. You'll have to change more letters(remove underscores and decapitalize letters), but you get ...


5

There really isn't hard evidence for preferring camel-casing over pascal-casing. Though that doesn't stop people from arguing over it a lot. If you're consistent, then there's not a huge difference either way. No casing comes with disadvantage of providing no hints for what words start where, which makes it more difficult to mentally parse and can lead to ...


2

Even in languages that allow dynamic modification of a single instance, like Python or Ruby, the code of methods still only exists in memory once. The main difference between those languages and those where a single instance cannot be changed (like Java or C++) is that in the static languages, each instance conceptually holds a single reference to a list of ...


0

OOP concepts do not change if you compare them in different programming languages though the way it gets implemented might vary. I have been working on C++ for 2 years and before that I learnt and worked in Java as well. Here is how you can look at it. Classes are the blueprints based on which objects are generated. In other words class can be seen as ...


5

The relevant terms here are dynamic and static typing. With static typing, all the types are fixed and do not change during the execution time of your program. This is what traditional languages like C/Java/etc are doing. The advantage for compiled languages with static typing is that they know, that each object of your class will have the same methods, ...


1

I can think of a few useful scenarios where partials make sense, most of them I am using myself in my projects: To separate Tool/IDE/Designer generated code from the code you are maintaining. A good example is the Form.Designer.cs file that contains the designer generated code for windows forms applications. Many other .NET formats also have some tool ...


1

Because the resultant structure will not be obvious to a compiler. A compiler will move through the grammar, step by step, in a systematic fashion. In practice, there are techniques that can shortcut this but if we want to formally and rigorously reason about grammars, we want it to all be as explicit as possible. This directly leads to the OR syntax. The ...


1

Java has call by value for a small number of predefined value types, and call by reference for object types. [The reference is internally a pointer that is passed by value, but that's not the point.] In C# (which is kind of Java 3.0) there are out and ref parameters, but Java doesn't have them. As a compiler writer I can tell you that they really complicate ...


6

Java is heavily influenced by Objective-C. Objective-C is heavily influenced by Smalltalk. Smalltalk is heavily influenced by Lisp. All of those are call-by-value. Or, more, specifically, it is call-by-object-sharing (aka call-by-sharing or call-by-object), which is a special case of call-by-value, where the value is a pointer to a (potentially mutable) ...


8

The terms "Call by Value" and "Call By Reference" are sometimes used a bit loosely by programmers, and the use of those terms doesn't always reflect the underlying reality. When you hear someone refer to Call By Value and Call By Reference, what they are usually saying is that primitive values are Call By Value, whereas objects are Call By Reference. You ...


2

You assume that the thought process behind Go and D was "we want a language compiled to native code that isn't C or C++". Then you wonder why the designers didn't just write native code compilers for Java or C#. But who says that this was the thought process behind those languages? I can't speak for the designers, of course, but from what I've read, the ...



Top 50 recent answers are included