Questions tagged [language-design]
The language-design tag has no usage guidance.
61
questions
1
vote
1
answer
25
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
87
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
53
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
64
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
246
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
56
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
96
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
29
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
52
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
207
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
79
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
128
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
167
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
137
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
3
answers
181
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
74
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
84
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
34
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
683
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
30
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
41
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
97
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
531
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
88
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
71
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
203
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
302
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
290
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
143
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
64
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
336
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
1k
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
530
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
258
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
436
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
682
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 ...
4
votes
1
answer
186
views
What techniques could be used to support thread-local contexts and resources in a language?
I am interested in the subject of thread-local contexts, which is a feature that I use quite often in solutions, but seems to lack first-class support in any languages I have used.
Quite often in ...
-1
votes
1
answer
53
views
How is a procedure application a control structure?
In scheme, a procedure application is considered as a control structure. Why is this?
1
vote
0
answers
74
views
DML , ML with restricted dependent types
Refering to this paper
Dependent ML: An Approach to Practical
Programming with Dependent Types
Have defined datatype 'alist ( int ) Its not clear why they have used int as a parameter rather than a ...
2
votes
2
answers
115
views
Functional programming with branches that have no order?
I was wondering if there is any programming style in which the outcome does not depend on the order of statements or groups of statements such as guards. Vaguely, I imagine this would leave room for ...
4
votes
2
answers
1k
views
What is the point of delimiters and whitespace handling
I see that language specifies reserved words, delimiters and whitespaces in the lexer section. Are delimiters just like reserved identifiers in the punctuation space or they have additioinal function ...
9
votes
3
answers
2k
views
Why are strings immutable in some languages?
String is an immutable class in Java. An immutable class is simply a class whose instances cannot be modified. Why does the Java programming language choose to make objects of class String immutable?
7
votes
3
answers
2k
views
How did it happen that Algol 60 was an improvement on its successors?
The original statement referred to by this question is:
The more I ponder the principles of language design, and the techniques which put them into practice, the more is my amazement and admiration ...
4
votes
4
answers
2k
views
Why would you introduce the goto statement into a modern language?
I just found out something really quite extraordinary. While looking through Stackoverflow, I came across a question about removing goto from a php function. PHP ...
0
votes
0
answers
24
views
procedures and immutable data to simulate return values
Let's say I have a programming language that allows procedures, i.e., methods without return values, and immutable data-structures, so no sideeffecting inside a procedure. Is it possible to simulate a ...