Relative Content

Tag Archive for language-design

Why do programming languages allow shadowing/hiding of variables and functions?

Many of the most popular programming languges (such as C++, Java, Python etc.) have the concept of hiding / shadowing of variables or functions. When I’ve encountered hiding or shadowing they have been the cause of hard to find bugs and I’ve never seen a case where I found it necessary to use these features of the languages.

Why use parentheses for function call when no arguments are passed?

The syntax function_name(arg1, arg2, ...) is used widely across various programming languages to invoke a function. Why is it necessary for the compiler or interpreter to require () to recognize it as a function call? If something is inherently callable, wouldn’t function_name; suffice to execute it?

Clarification about Grammars , Lexers and Parsers

Background info (May Skip): I am working on a task we have been set at uni in which we have to design a grammar for a DSL we have been provided with. The grammar must be in BNF or EBNF. As well as other thing we are being evaluated on the Lexical rules in the grammar and the Parsing rules – such as if rules are suitable for the language subset, how comprehensive these rules are, how clear the rules are ect.