Questions tagged [language-design]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
2 answers
50 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
26 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.) ...
  • 115
1 vote
2 answers
105 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
65 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
74 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 (&) ...
  • 31
5 votes
2 answers
257 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
57 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 ...
  • 147
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 ...
  • 141
1 vote
0 answers
57 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. ...
  • 293
4 votes
1 answer
213 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 ...
  • 153
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
133 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
185 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 ...
  • 173
0 votes
1 answer
140 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 ...
  • 133
2 votes
3 answers
188 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 ...
  • 4,017
1 vote
0 answers
87 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
35 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 ...
  • 103
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 ?
  • 141
0 votes
0 answers
31 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?
  • 101
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 ...
  • 352
0 votes
1 answer
99 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, ...
  • 101
5 votes
2 answers
539 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 ...
  • 243
1 vote
1 answer
89 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? ...
  • 352
0 votes
1 answer
72 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?} ...
  • 103
3 votes
1 answer
209 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
313 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 ...
  • 335
8 votes
2 answers
300 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
65 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 ...
  • 111
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 ...
  • 213
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 ...
  • 103
6 votes
1 answer
548 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 ...
  • 1
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 ...
  • 353
6 votes
1 answer
274 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 ...
  • 643
1 vote
2 answers
450 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
710 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 ...
  • 53
4 votes
1 answer
187 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 ...
  • 141
-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 ...
  • 893
2 votes
2 answers
118 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 ...
  • 165
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 ...