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. ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 "...
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 ...
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) ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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: ...
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 ...
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 ...
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.
...
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), <...
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 ...
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 ...
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., ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
semantics × 23language-design × 4
denotational-semantics × 3
language-comparison × 2
implementation × 2
undefined-behavior × 2
control-flow-graph × 2
syntax × 1
scoping × 1
rust × 1
haskell × 1
control-flow × 1
ambiguity × 1
parsing × 1
generics × 1
functions × 1
compilers × 1
identifiers × 1
functional-programming × 1
lambda-calculus × 1
imports × 1
nullability × 1
k-framework × 1
type-checker × 1
static-analysis × 1