Skip to main content
39 votes

Pros and cons of semantically-significant capitalization

Con: Doesn't work well for identifiers in alphabets other than latin Most programing langues nowadays support unicode identifiers. This allows writing identifiers in languages other than english. ...
mousetail 'he-him''s user avatar
27 votes

Pros and cons of semantically-significant capitalization

Con: inflexibility Using Go as an example, if you have a private identifier and want to make it public, you have to effectively rename it, which means changing code at every point where the identifier ...
xigoi's user avatar
  • 1,055
25 votes
Accepted

How can I specify a programming language step-by-step more formally than by providing a reference interpreter?

A popular way to do this is to give an operational semantics for your language. What is an operational semantics? Very roughly speaking, it is like a high-level outline for an interpreter. It is ...
David Young's user avatar
  • 2,412
23 votes

Are there any advantages of evaluating expressions differently in compile time and runtime?

Evaluating the same expression differently at compile time versus runtime would indeed be horrendous behavior. But, that's not really what's going on here. Go supports "untyped" floating ...
K. A. Buhr's user avatar
19 votes
Accepted

What are denotational semantics, and what are they useful for?

You could have invented denotational semantics! Suppose you want to know if some property about a program or a programming language holds. For example, you might wish to know whether a static analysis ...
Alexis King's user avatar
  • 10.4k
18 votes

Pros and cons of semantically-significant capitalization

Cons: You move representation of a binary property into the identifier concept. Go is actually a good example of why this is a bad idea. With their decision, they are now stuck with a binary ...
feldentm's user avatar
  • 2,192
16 votes
Accepted

How can we define a denotational semantics for recursive functions?

One way to represent this kind of (computable) recursive function mathematically comes from domain theory. I will end up describing something called a Scott domain in this answer, named after Dana ...
David Young's user avatar
  • 2,412
13 votes

Pros and cons of semantically-significant capitalization

Case has long been used by convention to indicate roles of identifiers. For instance, in C it's conventional to use ALLUPPER for macros, and either snake_case or camelCase for other identifiers. In ...
Barmar's user avatar
  • 1,980
10 votes

What languages have semantics with more than one "way" to execute each statement?

In continuation-based operational semantics we sometimes keep around two continuations, called the success and failure continuation. One is activated upon normal completion and the other when "...
Andrej Bauer's user avatar
9 votes
Accepted

Can something like a Donkey Sentence exist in a programming language?

Per Wikipedia: Barker and Shan define a donkey pronoun as "a pronoun that lies outside the restrictor of a quantifier or the if-clause of a conditional, yet covaries with some quantificational ...
kaya3's user avatar
  • 20.8k
9 votes

How might one formally communicate/define/describe a programming language design?

In conference papers, the usual way is: Extended BNF definition for the syntax, with textual description of some non-core features. Using inference rules (usually in the style of natural deduction) ...
ice1000's user avatar
  • 2,694
9 votes

How might one formally communicate/define/describe a programming language design?

Generally, programming languages are modeled using specialized mathematical notation for humans, and/or in formal methods languages like K and also Coq and Redex for computers. An example of the human ...
tarzh's user avatar
  • 4,284
9 votes

What are the different types of import semantics?

Broadly, there are two kinds of importing: Import declarations, which make other modules or their exported members available by name in the current scope; Import statements, which execute the code of ...
kaya3's user avatar
  • 20.8k
9 votes
Accepted

How can denotational semantics be defined for imperative statements?

Statements as Functions As suggested in coredump's comments, we generally interpret imperative statements as syntactic sugar for a function application. Side-effects are represented as usual in pure ...
Wheelwright's user avatar
8 votes
Accepted

What are the different types of import semantics?

As a start: Direct file text includes E.g. #include "foo.h" simple to implement, clear parse ordering Poor for dependency tracking and caching. Worse ...
Nuoji's user avatar
  • 1,153
7 votes

How might one formally communicate/define/describe a programming language design?

There is the definition of Standard ML using operational semantics for its typechecking ("static semantics") and evaluation ("dynamic semantics"), which has been formalized with ...
Alex Nelson's user avatar
7 votes

Can something like a Donkey Sentence exist in a programming language?

I'm not sure this is answering your question but... Programming languages are generally designed to be unambiguous With the exception of some esoteric languages programming language are generally ...
Bruce Adams's user avatar
  • 2,874
7 votes

Pros and cons of semantically-significant capitalization

One advantage is that you can lexically distinguish between two different classes of identifier, which could be useful if they need to be parsed differently. A good example of this is Haskell, which ...
occipita's user avatar
  • 579
7 votes

Data structures for scopes and variable shadowing

This is actually a question about language semantics, not about scopes. Your data structure is correct in essence. The question is if the languages introduces the inner var a before evaluating its ...
feldentm's user avatar
  • 2,192
6 votes

Pros and cons of semantically-significant capitalization

Con: screenreaders typically either don’t announce all-caps any differently to lowercase words, or, worse, can read them letter by letter as if they were an abbreviation. Language developers shouldn’t ...
Robin Whittleton's user avatar
6 votes

What languages have semantics with more than one "way" to execute each statement?

Context-oriented programming I think that Context-oriented programming is a possible way to name what you describe. Depending on the environment surrounding the code being executed, it can act ...
coredump's user avatar
  • 943
5 votes

Pros and cons of semantically-significant capitalization

Cons: not extensible There are only two cases. It can be a hard time if, for example, we need to add protected support to a newer version of the language. Cons: ...
tonychow1997's user avatar
5 votes

Pros and cons of semantically-significant capitalization

Similar to occipita's answer, but for humans instead of compilers: When reading code, it can be useful to immediately be able to tell whether a given identifier is public or private, without going to ...
pxeger's user avatar
  • 848
5 votes

Semantics of Haskell's `seq`

The first comment under the question is almost correct. What the case expression does is what is known as a "conformality check"; Haskell must evaluate ...
Pseudonym's user avatar
  • 5,366
5 votes

Semantics of Haskell's `seq`

TLDR: Because the Haskell report says so This is how seq is defined by the Haskell 98 report. ...
blueberry's user avatar
  • 2,597
5 votes

How should a language with period-based tuple indexing be parsed?

One thing to note about this syntax for tuple field accesses, is that it can clash with the lexical syntax for floating-point or decimal numbers. In many languages (e.g. Java, Javascript and Python), <...
kaya3's user avatar
  • 20.8k
5 votes
Accepted

How could I implement a non-null pointer qualifier in a C-style language?

Refinement Types NonNull is a function of type (a: PointerType) → { n ∈ a | n ≠ NULL }. Refinement types are types whose ...
Longinus's user avatar
  • 1,883
5 votes

Data structures for scopes and variable shadowing

This is called a persistent array. If you don't need the Scope object accessible after finishing processing a scope, you could just use one symbol table, modify the ...
user23013's user avatar
  • 2,850
5 votes

What should the semantics from branching from finally be?

Schedule and overwrite Branching around finally or in the presence of defer semantics is to schedule the effect, i.e., ...
André L F S Bacci's user avatar
4 votes

How might one formally communicate/define/describe a programming language design?

For completeness I must mention the C++ ISO standard. While it doesn't include mathematic proofs like some answers. It does include: complete syntax very precise wording indicating how each language ...
Bruce Adams's user avatar
  • 2,874

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