Skip to main content

Questions tagged [declarations]

For questions related to declarations, constructs that introduce a new variable, function, method, class, type, or other program entity

Filter by
Sorted by
Tagged with
3 votes
0 answers

Languages in which array types must be declared before usage

Some languages require array types to be declared before an object of that type can be declared. In Ada, for example: ...
QF0's user avatar
  • 131
8 votes
4 answers

Why are mixed declarations more challenging to implement than forcing all declarations to be at the top of a scope?

C89 had a requirement that all declarations must appear at the top of the scope before any statements: ...
CPlus's user avatar
  • 8,301
4 votes
6 answers

Why tag function definition with def, fn, fun, func or function etc?

What makes it hard for compilers/interpreters that we need to tag the function definition with keyword fn/fun/func/function? I can understand that types for numbers: int, int32, float32, float64... ...
Anubhav's user avatar
  • 173
12 votes
3 answers

Is type checking usually preceded by a pass that looks at just names and declarations?

Let's say I've parsed a file of code into an AST, and now I want to walk the AST and type check it. My AST nodes have a signature like this (C++) ...
Rob N's user avatar
  • 1,083
-1 votes
1 answer

What is a good universal naming syntax? [closed]

Lots of languages do not clearly separate the declaration of a variable, function or type from naming that entity, or if they do it does not have a uniform syntax. Consider C++: Naming a variable: <...
G. Sliepen's user avatar
6 votes
3 answers

Why is implicitly declaring functions problematic?

I believe one used to be able to do this in C: int main(void) { return printf("Hello world!") > 0; } Now this became invalid in C99, and one must ...
CPlus's user avatar
  • 8,301
4 votes
3 answers

What are the advantages and disadvantages of only allowing declarations at the top level?

Some languages, such as C++ and Java, have grammar restrictions where code that is not a declaration or import statement cannot be outside of a function. However, variables, functions, and classes can ...
FireTheLost's user avatar
  • 1,603
6 votes
2 answers

Why do newer languages allow implicit variable declarations?

For me, one of the best things to happen to FORTRAN was the introduction of the LOGICAL*1 type. I quickly discovered that putting ...
Ray Butterworth's user avatar