Questions tagged [language-design]
The language-design tag has no usage guidance.
70
questions
1
vote
0
answers
23
views
Resources on designing query languages
I'm looking for resources (books, papers, tutorials) on designing domain-specific query languages. I'm mostly interested in the design of syntax and grammar, rather than the implementation. Any UX-...
0
votes
1
answer
27
views
What name is used in the literature for an interpreter or compiler which compiles and executes all function calls which have constant literal inputs?
In the following discussion, we use the term old programming language to refer to programming languages which had their first release prior to the year 1990.
In old programming languages, there was a ...
0
votes
1
answer
67
views
Can contiguous arrays be lazily evaluated?
Contiguous arrays with variable length, such as C++'s std::vector, have been a major sequential container for languages whose evaluation is eager. However, it has ...
0
votes
2
answers
46
views
Types and programming languages: strange term construction?
Pierce's Types and Programming Languages has the following definition of terms:
$$S_0=\emptyset$$
$$S_{i+1} = \{true,false,0\} \cup \{succ(t), pred(t),iszero(t)|t \in S_i\} \cup\{if(t_1)then (t_2)...
-3
votes
1
answer
69
views
A chatbot's take on dynamic scoping: it is easier to debug - correct?
I asked the chatbot at you.com, "what is an advantage of dynamic scoping?" and it said the following on the pane titled YouChat. (If you click the link, you will probably see a different ...
0
votes
3
answers
139
views
In data structures, there are many identifiable characteristics, but what are the characteristics are of primitive-data types?
Data Structure
a data structure is a data organization, management, and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data ...
5
votes
3
answers
2k
views
automatic memory allocation
Global variables are given fixed addresses in main memory by the C compiler, called static memory allocation. Function local variables are created on the stack, this is called automatic memory ...
0
votes
0
answers
19
views
Reference request: Domain specific language, runtime, virtual machine design and implementation
I'm a working software engineer who is interested in programming language design and I want to try to implement a simple DSL as an exercise and a side project. I want to apply for grad school in this ...
1
vote
2
answers
284
views
How to disambiguate CFG with unary/binary minus and binary prefix operator
I'm designing an expression language that's trying to (a) be maximally compatible with a different ambiguous language; and (b) be LR(1).
I'm facing the current fragment of the language:
$$
\begin{...
1
vote
1
answer
32
views
Is a constant literal an example of a built-in?
My understanding is that in a programming language, built-ins are bindings that exist without the user having to make them. (Like + to its referent, for example.)
...
1
vote
2
answers
192
views
Why does Python allow stand-alone expressions?
In Python, this is a valid program
def PrintWorld():
print('World')
print('Hello')
0
'beautiful'
True
None
0 < 0
3, 3
lambda c:3
PrintWorld()
All it does ...
0
votes
1
answer
79
views
How to do asynchronous programming with only global variables?
If a programming language only supports global variables, is it still possible to use asynchronicity, like callbacks, event-driven programming, other kinds of parallelisation?
How can it be done?
3
votes
1
answer
145
views
Why is the address-of operator in C/C++ represented with the "&" symbol?
I've started learning C++, and I know a little bit of C. Something that always struck me as somewhat off was that the address-of operator is represented with the seemingly random ampersand (&) ...
5
votes
2
answers
294
views
Regarding Backus' Commentary on von Neumann-style Programming
in John Backus' 1978 FP paper "Can Programming Be Liberated from the von Neumann Style" he says
To help assemble the overall result from single words [von Neumann ie.
conventional mutation-...
1
vote
1
answer
61
views
CFG for a given languague
Give a CFG for the languague L = $ \{ 1^n +1^m = 1^{n+m}| n,m \in N_{0}\} $ , with the alphabet $\Sigma =\{1,+,=\}$.
I am currently trying to solve the given task, I thought a good way is to split ...
1
vote
2
answers
102
views
What is the property of a PL that extracting a subroutine should not change the meaning?
What is the name of the property of a Programming Language that says that extracting a subprogram into a subroutine and using that subroutine instead of the subprogram should not change the meaning of ...
3
votes
0
answers
33
views
What the type of an overloaded function should be?
Anecdotally, Virgill III language forbids overloading since overloading resolution is at odds with the language support of functions as first-class citizen, when resolution can't happen at compile ...
1
vote
0
answers
66
views
How to use dynamic scope?
I have this example code, which is an undefined language. We want to know what will be printed if we use static versus dynamic scope.
...
4
votes
1
answer
415
views
Why are struct and class essentially the same in C++?
struct and class in C++ are nearly identical (as covered for example here).
But why is this so? What did happen when C++ was ...
4
votes
0
answers
80
views
Scopes vs objects -- would a language make sense that voids the difference?
So there's this adage that says "Objects are a poor man's closures", which can equally well be reversed, which I understand to mean that they are equivalently expressive.
What strikes me about the ...
1
vote
1
answer
170
views
Why is the syntax of some programming languages very much not according to earlier conventions? [closed]
Looking at the syntax of the programming language C and others inspired by it, I cannot help but ask the question in the title. Mathematics, logic and other subjects have been existing for many ages ...
1
vote
2
answers
228
views
Is lazy evaluation required for do-notation?
Do-notation is most famous by Haskell, which is also famous for having lazy evaluation.
But is lazy evaluation a requirement for implementing do-notation?
In principle, could do-notation be added ...
0
votes
1
answer
160
views
Why in Declarative Programming variables are not reassigned?
I've read that a Declarative language is called "stateless". This means that we can imagine that internally every variable is a constant variable, and it never get reassigned ( in contrast with what ...
2
votes
5
answers
263
views
Are there any programming languages which support user defined control structures?
For instance, the user would define a for each loop in their code as having a structure something like:
foreach([variable1] : [variable2]){
[statements]
}
(...
1
vote
3
answers
77
views
Is there a reason to NOT wrap preprocessor macros in parens?
I'm writing a design document for a macro expansion language that is specifically intended for arithmetic operations on integers. I've already determined that not wrapping macros with parens can lead ...
23
votes
0
answers
1k
views
Can a calculus have incremental copying and closed scopes?
A few days ago, I proposed the Abstract Calculus, a minimal untyped language that is very similar to the Lambda Calculus, except for the main difference that substitutions are ...
1
vote
0
answers
101
views
Translation from Intermediate Language into 'three-address' machine instructions
I am unsure where to start with this. From what I understand so far, 'VAR(x)' corresponds to Rule 2, ':= VAR(x) ' refers to Rule 5 and '+ NUM (1) refers to link 3.
...
0
votes
1
answer
45
views
extend ECMAScript by adding new keywords and syntax
I would like to extend ECMAScript by adding new keywords and syntax to it, for example:
|variableName| stipulates a special kind of variable which I would like to be able to include in a normal ...
4
votes
1
answer
686
views
Which is easier for human perception: type of variable before or after its name?
In some programming languages type of variable goes before it's name.
In another - name goes first and then type.
Which version loads brain less and allow easier think about problem ?
0
votes
0
answers
32
views
How can fuzzy logic be applied to computer language design?
Is fuzzy logic in any way applicable to general-purpose language design? If yes, then how would a computer language theoretically benefit from first order support of fuzzy logic?
1
vote
1
answer
46
views
Was multiple inheritance ever implemented by adding redundant data members?
In discussions about why most languages which implement inheritance only implement single-inheritance, the question of the precise semantics of overlaps often comes up, and having redundant data ...
0
votes
1
answer
129
views
Are there any languages without tokens?
I know a lot of computer languages and they all use tokens. E.g. in very early BASIC you could say LET answer = 42, which is composed of seven tokens, ...
5
votes
2
answers
599
views
Why don't imperative languages like C or Go support Haskell-like parametric polymorphism?
Why don't imperative languages support parametric polymorphism as powerful as whats in Haskell and OCaml?
More specifically if I call a function foo(x) that ...
1
vote
1
answer
98
views
Can all optimizations be expressed in source code?
If someone compiled a program with all optimization settings enabled, would it be possible to create source code that, if it was compiled with all optimizations disabled, produced an identical binary? ...
0
votes
1
answer
79
views
A systematic approach to creating a simple test parser
I need to create a simple text parser that replaces {tokens} with text from a table. The more complicated bit is the {?text?} ...
3
votes
1
answer
220
views
Return destinations for an expression-oriented programming language
I am designing a programming language and I want to give everything the ability to return a value. For example, if I use a block as a right-hand side value, I can assign it to a lvalue:
...
0
votes
2
answers
343
views
Can String be a subtype of Character in a programming language?
Could a programming language be designed so that there is an inheritance relationship between string and character (both of ...
8
votes
2
answers
338
views
What would a language look like in which precise GC was implementable as a library?
Suppose you have some programming language with manual memory management. What features does this language need to have in order to be able to implement precise garbage collection as a library, and ...
1
vote
1
answer
147
views
Metaprogramming taken to an unnecessarily high level- how can a program write not just other programs, but a programming language? [closed]
So basically, automated language-oriented programming. I've tried finding info on this concept, but have had some trouble, probably because my brain is having a bit of trouble grasping the subject ...
1
vote
0
answers
74
views
Languages with Multiple Arbitrary Return Values
I am designing a DSL for writing numerical simulations. I am working on a specific issue related to returning values from functions, and I am wondering if any other existing language solves the same ...
0
votes
1
answer
337
views
The ultimate virtual machine
It seems to me that one way computer science could be divided up, is into three domains:
What is efficient for humans to represent and comprehend
What is efficient for computers to represent and ...
11
votes
4
answers
1k
views
Does it make sense to have both the concept of 'null' and 'Maybe'?
While creating a client for a web API in C#, I ran into a problem regarding null as a value where it would represent two different things:
nothing, e.g. a ...
10
votes
1
answer
2k
views
Types as first class Citizen
Coming from a C++ background I don't understand why one needs types / type expressions as first class citizen?
The only language I know that supports this feature is Aldor.
Does anybody have some ...
6
votes
1
answer
617
views
Lazy concatenative functional language
Can the idea of concatenative programming languages be extended to call-by-need evaluation strategy?
I see some problems that I will explain with few examples. I will use a prefix instead of a ...
0
votes
0
answers
33
views
How to design context-free grammars generating the languages with twice as many a’s as b’s? [duplicate]
The problem is designing context-free grammars generating the following languages.
The set of strings over the alphabet Σ = {a, b} with twice as many a’s as b’s.
I found a solution but I don't know ...
11
votes
3
answers
1k
views
Automatic Downcasting by Inferring the Type
In java, you must explicitly cast in order to downcast a variable
...
25
votes
3
answers
4k
views
Visual programming tools, why don’t they work with the AST directly?
I've found several open source visual programing tools like Blockly and friends, and other projects hosted at Github, but could't find any that work directly with the abstract syntax tree.
Why is ...
6
votes
1
answer
303
views
Safe way to explicitly define new types instead of using Algebraic data types for my functional language
Question:
As I'm working on a Hindley-Milner typed lambda calculus, in order to make it usable I need to add some types such as list and pairs. The way I currently do it is, I have an ...
1
vote
2
answers
555
views
Should names of built-in funtions be part of BNF grammar?
We're creating our own programming language for a subject. And we're confused whether to add the names of the functions we want to have in our language (like our own version of print) in the BNF ...
5
votes
1
answer
775
views
Examples of context sensitive syntactic constructs (statements)
So, I am implementing a context sensitive syntactic analyzator. It's kind of an experimantal thing and one of the things I need are usable syntactical contructs to test it on.
For example, the ...