Questions tagged [programming-languages]

Questions related to design, implementation, and analysis of programming languages. NOT for questions about how to program, which are off-topic on this site.

Filter by
Sorted by
Tagged with
1 vote
0 answers
58 views

How to convert wp equations into linear algebra equations?

I am reading this paper [1], wherein the authors first formulated a safety constraint in terms of wp equations. Then, they converted the equations into linear algebra form. As per section 4.3, their ...
desert_ranger's user avatar
0 votes
1 answer
37 views

How are PCFGs used in programming language design?

I've been reading the wikipedia article about probabilistic context-free grammars (PCFGs), and they state that PCFGs have application in areas as diverse as natural language processing to the study ...
Knogger's user avatar
  • 1,032
-3 votes
0 answers
26 views

Calculate sum(position*element) for a vector array in C++

Consider vector<int> C I aim to calculate $\displaystyle \sum_i i*C[i]$ using some stl library. In there any stl function there to do that?
Subhankar Ghosal's user avatar
0 votes
2 answers
39 views

Reference types

Is a reference type (agnostic of PL) the object being pointed at, or the object doing the pointing? I'm having a hard time wrapping my head around the concept fundamentally (of course, I have ...
user129393192's user avatar
0 votes
2 answers
64 views

What is the precise difference between state and environment and memory?

I was just reading this question regarding the difference between environment and memory. However, the textbook in question, Essentials of Programming Languages, third edition, by Friedman and Wand, ...
The Pointer's user avatar
1 vote
1 answer
33 views

Creating an executable after code generation - compiler design

I am learning about and building a very basic compiler. My question is about code generation. I have read on a lot of materials about code generation when building a compiler and I get the concept. ...
Ali Ahmed's user avatar
1 vote
2 answers
59 views

How are conflicts between free and bound de Bruijn indices resolved?

On page 77 (section 6.1) of Types and Programming Languages by Benjamin C. Pierce (1st and only edition thus far), there is the following quote regarding naming contexts and de Bruijn indices: Γ = x ...
bbarker's user avatar
  • 175
1 vote
0 answers
144 views

How to deal with missing variables when utilizing weakest precondition for verification?

I am reading the example given in [1], section 4.2. It deals with applying weakest precondition (wp) rules to ensure that the velocity of a car doesn't exceed a certain limit. We have the following ...
desert_ranger's user avatar
3 votes
1 answer
172 views

How did this work apply weakest precondition rule on their example car problem?

While reading the example given in [1]., I couldn't understand how the authors set up the logic to compute the weakest preconditions (wp) in their car example in section 4.2. The dynamics of the ...
desert_ranger's user avatar
0 votes
2 answers
38 views

Returning more than one value from a function without overhead

In stack languages (e.g. PostScript, Forth), return values are passed on the stack - zero, one, even a variable number. Python supports tuples of values there, frequently used "without tuple ...
greybeard's user avatar
  • 1,041
0 votes
0 answers
28 views

Formal Proofs for Rust-related Programming Languages Paper

I've done some PL-related work in Rust that requires some proofs to guarantee the resulting language is free of data races. I'd like to include such work in a paper, but I'm not sure whether I should ...
baffld's user avatar
  • 593
0 votes
1 answer
34 views

Results of a Program After Call By Reference Vs. Call By Value-Result

I have a question that I am trying to work through. I have a program: ...
RDizzl3's user avatar
  • 101
-1 votes
1 answer
53 views

Guess the output of a c program [closed]

I have come across a c program like this . int main() { int a,i=4; int z=5; a=--i+ --i+ --z; printf("%d %d",a,i); return 0; } What will be ...
Shahed al mamun's user avatar
1 vote
2 answers
55 views

In the simulation of a C-program by a Turing machine, how does a TM determine which instruction to execute?

In Arora-Barak, the authors mention a way how TMs can compute everything that can be computed by computers. The idea is that every high-level language program has an equivalent machine language ...
Burt Macklin's user avatar
0 votes
0 answers
60 views

What is the earliest compiler in chain that was used to create what we nowadays have as a modern C compiler?

My apologies if the title is confusing. First I begin with the statement that may be wrong but what I always thought what happened. "Dennis Ritchie created C compiler which was used to create ...
Clear Sky's user avatar
2 votes
1 answer
42 views

Is there any reference materials on complexity analysis for lazy languages?

Is there any books, papers or articles on how to analyze the time complexity of programs written in lazy languages such as Haskell? I know how laziness is implemented and how it can be expanded and ...
Kagura Hitoha's user avatar
1 vote
0 answers
28 views

A formula of the major garbage collection threshold

I'm studying the garbage collection code of Alex Aiken's COOL programming language's runtime system. (This is the language used in a relatively famous Stanford Online Compilers course) A major garbage ...
Myk's user avatar
  • 173
0 votes
1 answer
63 views

How to evaluate an arbitrary mathematical expression

For Instance, if I allowed the user to pass in expressions like "35 + 2 * 5" as strings, how would I go about writing such a program? Also, what topics does this question fall under?
Enoch's user avatar
  • 11
3 votes
1 answer
170 views

how to do incremental construction of the minimal model in logic programming?

I was reading a book titled "Essentials of Logic Programming.", most parts of the book are easy to understand. but now having a problem with Theme 45: incremental constructions of the ...
alim's user avatar
  • 994
1 vote
0 answers
54 views

Is it possible for Mojo language to include multiple dispatch feature of Julia through some hints or decorators mechanism? [closed]

Can the strengths of Mulitple Dispatch system of Julia language be replicated in a newly designed language like Mojo through cleverly designed mechanism? Or only Julia gets to have such a feature due ...
user238607's user avatar
0 votes
2 answers
85 views

Can you verify the end of a function declaration through syntax analysis?

In some languages, it is expected that a function declaration be terminated by syntax that includes the function name. For example, in MODULA-2, a function is declared as shown below: PROCEDURE P ; ...
Emma3201's user avatar
1 vote
2 answers
69 views

Datatypes and number representaton

I'm a freshman in computer science and I have a question that has been bugging me after my programming and electronics classes were over. My question is that in an integer datatype (assume short ...
WhizzingPhoton's user avatar
0 votes
0 answers
46 views

Metaprogramming language

Is there any programming language, by which I can write a code that during run time automatically generates so many other codes and furthermore those codes will be run in parallel?
DYNAMICS's user avatar
0 votes
1 answer
64 views

Show that if <S1;S2,s> => * s', it is not necessarily the case that <S1,s> =>* s'

I am studying Structural Semantics for programming languages and I have come to this proof that I can not achieve. Whith these rules plus Splitting and No interference, I am trying to get a proof. I ...
Francisco Aguilera's user avatar
1 vote
4 answers
3k views

Can we ever achieve Turing completeness?

I want to relate Turing completeness to the Halting Problem. As far as I know we say something is turing complete (eg: a programming language) when it can compute any function and can do any task. But ...
D Star Let's Explore's user avatar
5 votes
7 answers
3k views

What are the conditions necessary for a programming language to have no undefined behavior?

For context, yesterday I posted Does the first incompleteness theorem imply that any Turing complete programming language must have undefined behavior?. Part of what prompted me to ask that question ...
Mikayla Eckel Cifrese's user avatar
2 votes
3 answers
322 views

Does the first incompleteness theorem imply that any Turing complete programming language must have undefined behavior?

If I understand correctly, the first incompleteness theorem says that any "effectively axiomatized" formal system which is consistent must contain theorems which are independent of the ...
Mikayla Eckel Cifrese's user avatar
1 vote
0 answers
26 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-...
Tim's user avatar
  • 111
2 votes
1 answer
105 views

What is the closest theory to "The theory of code refactoring"?

We refactor code lots of times as developers. Metaphorically, our program space is an infinite-dimensional Rubik's cube. Things can be rearranged, preserving the code's action, so a "symmetry ...
Daniel Donnelly's user avatar
1 vote
1 answer
35 views

Algorithms/Data-Structures to calculate transitive call graphs in the presence of virtual dispatch?

Algorithms/Data-Structures to calculate transitive call graphs in the presence of virtual dispatch? I am trying to write a program to analyze Java programs and figure out the transitive closure of the ...
Li Haoyi's user avatar
10 votes
3 answers
2k views

Is there a theoretical foundation behind CSS?

You know how programming languages can be based on Lambda Calculus or the Turing Machine and SQL is based on relational algebra. Is there any such thing for CSS or any foundation that could be used ...
Juan's user avatar
  • 755
0 votes
0 answers
26 views

How does tokenization relates to formalism, lexical grammar, and regular language?

I am reading Bob Nystrom Crafting Compiler's and in the chapter 5 it says this In the last chapter, the formalism we used for defining the lexical grammar— the rules for how characters get grouped ...
Finlay Weber's user avatar
0 votes
1 answer
126 views

What does it take to support a programming language on an OS?

From my understanding, something like Linux is very geared towards C programs, with things like libc. What I'm wondering is, even in Java, you have arguments to ...
user129393192's user avatar
0 votes
1 answer
124 views

Explanation of a simple example of how an interaction net computes?

I have briefly looked through the links at the bottom of this page: Interaction Nets Interaction Combinators Implementation of a low-level language for interaction nets, Shinya Sato Inpla, ...
Lance's user avatar
  • 2,223
0 votes
0 answers
119 views

What are fundamental differences between single dispatch and multiple dispatch?

How do single and multiple dispatch differ? In particular, I am wondering why some programming languages, both interpreted and compiled (such as Python and Java), natively support single dispatch but ...
fool's user avatar
  • 131
2 votes
0 answers
16 views

Does exist another models like CARDIAC, LMC and IPC?

I'm working with CARDIAC (Cardboard Illustrative Aid to Computation) that is a model created at Bell Labs in 1968 to explain students how the computers worked with the Von Neumann architecture to ...
Osvaldo Santos's user avatar
0 votes
0 answers
23 views

Problems with writing short job first algorithm(for scheduling of processes) in C language

Hy everyone. I'm trying to write the SJF (short job first) algorithm NON-PREEMPTIVE for scheduling processes in C. I want to implement an algorithm that orders some processes by the burst of the ...
Enri's user avatar
  • 1
9 votes
7 answers
7k views

Why do we use main function in almost all the programming languages?

Why do we need the main function and can't we execute the code without it? Can't we just execute our code outside the main function by making our own function?
Kakashi San's user avatar
0 votes
1 answer
31 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 ...
Toothpick Anemone's user avatar
5 votes
2 answers
638 views

Structural equivalence of self-referential structures

Given two types, T1 and T2, how does structural equivalence work when they're self-referential? Further, how do we go about proving it? ...
HidekiRyuga's user avatar
0 votes
0 answers
74 views

Function types in Computer Science Metanotation

See Guy Steele's slides for what I refer to by "Computer Science Metanotation", specifically the bits about BNF. I often make use of the BNF syntax observed there, as a substitute for ...
Sebastian Graf's user avatar
0 votes
2 answers
38 views

Discarding lists of same elements

Suppose, I have a list of lists where multiple lists can have same elements. In my final output, I just want one list with the same element. An example is the following: Input: A=[[1,2,0], [0,1,2], [2,...
Becker Mammat's user avatar
0 votes
1 answer
72 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 ...
Dannyu NDos's user avatar
3 votes
0 answers
82 views

Formalize the proof of theorem 2.4 in Harper's PFPL

In Harper's Practical Foundations for Programming Languages, page 19, rule (2.9) defines the $sum$ function inductively. $$ \frac{b:nat}{sum(zero;b;b)}\tag{rule 2.9a} $$ $$ \frac{sum(a;b;c)}{sum(succ(...
gingerologist's user avatar
2 votes
1 answer
63 views

Is there any formalization of GADTs implemented in OCaml?

There are papers that describe how generalized algebraic datatypes (GADTs) are encoded in core Haskell (System FC)[1][2], but I could not find any documentation on how OCaml formalizes/implements/...
Apoorv's user avatar
  • 659
-2 votes
1 answer
65 views

How a computer works?

I know that a computer can be mechanical, screws/nuts or even water/pipes. Of course, it would be slow and big, but it doesn't have to be electric, transistors, etc. How can a machine like this do all ...
user157635's user avatar
1 vote
2 answers
113 views

Division by zero in APL: assign return value 0 or 1

Recently I began learning a couple array based programming languages: Dyalog APL and BQN. And I cam across this peculiar manner in which division by zero is handled in Dyalog APL. Using the in-built ...
oliverjones's user avatar
1 vote
1 answer
37 views

Example of preservation failing in Java - follow up question

This is a follow-up question to my previous question I have been reading this post and it comes up with the following example showing how Java type system is unsound: ...
Node.JS's user avatar
  • 151
0 votes
2 answers
48 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)...
Hank Igoe's user avatar
  • 179
1 vote
2 answers
185 views

Example of progress and preservation failing in a commonly used programming language like Java

I am wondering if my solution is correct or I am on the right track. I have searched online and found a paper about Java type system being unsound but that doesn't really answer the progress and ...
Node.JS's user avatar
  • 151

1
2 3 4 5
20