New answers tagged

0

Why, in programming languages in general, must function declarations be followed by a parameter set ... There are many programming languages and all of them work differently; nothing is "in general". "mex functions" in Matlab for example do not have a possibility to define the number (or data types) of the required parameters; the function itself must ...


3

On top of what everyone else has said, there is a very good reason why some programming languages did it this way. "Tuple" call notation in programming languages goes at least back to Fortran. I couldn't find an earlier example, although MATH-MATIC used parentheses and commas for subscripts. It makes sense, because this is familiar from mathematical ...


3

There are at least 3 things a function declaration needs to tell the compiler. It's a function declaration. The name (if any) of the function being declared. The names of the arguments (if any). You can devise any syntax you like that will convey those things. However, there's a certain preference for syntax that either resembles mathematical use, or ...


2

Well, in the case of Algol family, the answer is yes, most of them has similar syntax. and IMO, Algol family could be treated as representative of general programming languages since there are many of well-known field-tested languages like JS, Pascal, Ruby, Java and C-family language. FYI(I guess you might want to know how this kind of syntax has invented, ...


16

In my opinion, your question is formed on the basis of working with a small number of programming languages and extrapolating a conclusion that is not valid. Here are some assumptions I have recognized that are not valid which I will later explore in greater detail: Parenthesis are used to indicate arrays. All function calls must use parenthesis. All ...


0

This is (more or less) a legacy from C. In C (and most languages inheriting from it) you can declare a function (announce to the compiler what the function is all about), like: int some_function(int, double, bool); This announces that somewhere the function some_func will be defined (perhaps later in this file, perhaps in another file), and that some_func ...


2

An exception was Pascal, where using the name of a function with no arguments called it, and assigning to the name of a function assigned to it. It was considered a good idea back then. I always thought it made code less readable. Today, look at a language like Swift where a function is a first class object. Which can be stored into a variable, passed as a ...


11

This notation is seen as useful to differentiate variables from function calls (both for humans and compiler parsers): a = 12; int b = a; versus int a() { return 12; } int b = a(); Furthermore, when a is a function, a without parentheses can represent the function pointer itself (in Python for instance, or in C if preceded by &) Note that it is not ...


0

It means that at runtime you will not be able to see what object comes out of the collection, as that information is removed from the lower-level code that is generated by the compiler. In your specific instance, it would mean that at runtime an object of type AnyIterator<Element> will not be able to tell you what is the exact type of Element, unless ...


0

There is a proof by using parametricity/logical relations framework or free theorems as mentioned in Zhao et al.[1] For instance, we can conclude that there is no closed inhabitant of type ∀α.α in a pure setting. If there were such a term, it must yield a value of any type at which it is instantiated, but there is no uniform algorithm to compute a ...


0

AFAIK, the meaning of the term “declarative vs. imperative” changed over time. The original meaning is what you cited, “how vs. what”. This distinction is philosophical, so its meaning varies from person to person. To be honest, after all these years, I failed to understand it, so I will not discuss it here. A more specific meaning of “imperative” emerged: ...


0

//:Example of negative index: //:A memory pool with a heap and a stack: unsigned char memory_pool[64] = {0}; unsigned char* stack = &( memory_pool[ 64 - 1] ); unsigned char* heap = &( memory_pool[ 0 ] ); int stack_index = 0; int heap_index = 0; //:reserve 4 bytes on stack: stack_index += 4; //:reserve 8 bytes on heap: heap_index += ...


Top 50 recent answers are included