All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
83 views

What are the potential consequences of allowing decimal-point-less number literals to be interpreted as floats?

In some languages, a number literal's type can be inferred from nearby expressions. For example, 1u64 + 2 might give a u64 value ...
Rydwolf Programs's user avatar
-1 votes
0 answers
33 views

Should addition assignment `a += b` be equivalent to addition then assignment `a = a + b` [closed]

I am looking for the pros and cons of a += b being an exact synonymous, or not, of a = a + b. The question also holds regarding <...
Stef's user avatar
  • 244
4 votes
1 answer
126 views

Should bitwise operations have dedicated operators? [closed]

Many programming languages have built-in support for bitwise operations, often using C's syntax: ~ = NOT & = AND ...
dan04's user avatar
  • 1,534
0 votes
1 answer
97 views

How to minimize total size of static data?

I am implementing a WASM backend and I hope to optimize the size. I have collected a series of static data. After erasing the type, it can be simply considered as ...
Aster's user avatar
  • 2,552
2 votes
1 answer
112 views

Possible ways to determine reach of implicit lambda expressions

When defining an inline function, even the shortest way to do so usually requires naming its argument (unless you're going for the point-free style and you have an expression that returns a function). ...
Lazar Ljubenović's user avatar
5 votes
5 answers
860 views

Correctness of mixed signed/unsigned arithmetic

I'm implementing signed and unsigned integers in my language. They are represented in C as signed long and unsigned long ...
Matheus Moreira's user avatar
10 votes
1 answer
236 views

How to tolerate syntax errors in a typed language?

In my tokenizers and parsers, once I find a syntax error (like an unexpected token) I usually throw a fatal exception that finishes parsing of the input source. The downside of how I usually do it is ...
Hydroper's user avatar
  • 769
-1 votes
0 answers
49 views

How to be (more) critical during Code Reviews of team members? [closed]

I'm a Software Engineer who sometimes need to review the code of my fellow team members. I often look at the source code and think; this looks fine. I'm having a hard time to think critical about it. ...
Jay's user avatar
  • 1
4 votes
5 answers
252 views

How can memory addresses be compile-time constants?

In C the memory address of a statically allocated object or a function is considered compile-time constant. For example this is valid code: ...
user16217248's user avatar
  • 7,285
10 votes
4 answers
253 views

Are there languages that implement a more granular precondition system than just safe/unsafe

In a language like C, many functions and operators have some preconditions to work. Violating a precondition is undefined behavior. For example, when indexing an array the index must be less than the ...
mousetail's user avatar
  • 6,746
9 votes
1 answer
159 views

What was the rationale for making realloc(ptr, 0) have UB in C23

This is the first breaking change that C made, which was making realloc(ptr, 0) have UB instead of being roughly equivalent to ...
user1345541's user avatar
11 votes
9 answers
6k views

Can sine converge to zero at infinity?

In common languages, sine produces an error, NaN, or exception when evaluated at infinity. For example, in Python: ...
Corbin's user avatar
  • 670
5 votes
4 answers
289 views

What goes wrong when division-by-zero is defined as multiplication-by-infinity?

Sometimes, we want to implement floating-point operations on systems which use IEEE 754 representations of values, but don't necessarily support IEEE 754 semantics. For example, we may be using the <...
Corbin's user avatar
  • 670
1 vote
1 answer
121 views

Implementing automatic derivation without macros?

In Rust: #[derive(Display)] struct Foo<T>(T); If T conforms to the Display trait, ...
Jw C's user avatar
  • 121
2 votes
1 answer
158 views

How to assign unique names to variables within a function?

I want to promote all variables within the function to the top level of the function, make it more cache-friendly and reduce size bloat caused by alignment fill. In other words, it will roughly ...
Aster's user avatar
  • 2,552
22 votes
3 answers
5k views

Why are volatile objects so difficult to work with in C++?

C++ does not generate default copy/move constructors or assignment operators for any volatile struct or ...
Bbrk24's user avatar
  • 8,563
-2 votes
0 answers
58 views

How to Integrate Python with HTML? [closed]

I am a learner and am learning python currently. To know what all I have to learn I wanted to create a chatbot with algorithm that uses python. But I want that I have a input page to take commands ...
Dhruv Garg's user avatar
2 votes
1 answer
151 views

What if all static methods in Java or C# could be extension methods just by default?

C# 3.0 introduced extension methods to "enhance" behavior of existing types without interface bloating to avoid modifying/breaking existing interfaces. This was the first time I learned of ...
terrorrussia-keeps-killing's user avatar
0 votes
0 answers
69 views

What is best practice for a programming language which allows more than one syntax for class method invocations? [closed]

Consider the following code written in a syntax consistent with the programming language known as "python": ...
Samuel Muldoon's user avatar
9 votes
3 answers
1k views

What is a "primary expression"?

I've found that many grammars have a production called PrimaryExpression or something along those lines. ECMAScript has ...
Lazar Ljubenović's user avatar
-2 votes
1 answer
135 views

Low effort, high impact optimizations? [closed]

The Pareto principle tells us that 20% of our efforts will bring us 80% of the results. The same should be true of optimizations. Are there optimization techniques out there that: Are simple and easy ...
Matheus Moreira's user avatar
-1 votes
2 answers
162 views

Why hasn't html a simple way of showing html tags as they are? [closed]

html comments meant to be read by the person reading the source are like <!-- Write your comments here --> But sometimes we want to depict a html as it is, ...
Quora Feans's user avatar
0 votes
0 answers
188 views

Pros and cons of treating endless loops as "anything can happen" UB, versus allowing limited reordering

Many programming languages, including C89, specify that the behavior of a program in terms of sequentially executed steps, whose behavior is in turn defined in terms of the program's state when the ...
supercat's user avatar
  • 1,562
11 votes
1 answer
195 views

What exactly is Pratt parsing used for and how does it work?

I've come across the term “Pratt parsing”. The only thing I know is that it's an algorithm (or a pattern, a technique) used to parse expressions. How does it work? I'd like to see the intuition behind ...
Lazar Ljubenović's user avatar
26 votes
2 answers
3k views

Studies on learnability of braces vs. indentation for code blocks for beginners?

The discussion whether using indentation for code blocks is better or worse than using braces is an old one, but I don't want to rehash that discussion here (for reference, there was a fairly recent ...
Schmuddi's user avatar
  • 363
9 votes
0 answers
110 views

How to detect changes to definitions and their impacts?

I'm implementing the Language Server Protocol (LSP) for my language, and I'm having huge problems tracking updated definitions. 1. How to determine which files have been changed? lsp can only monitor ...
Aster's user avatar
  • 2,552
4 votes
0 answers
120 views

Determining the most optimized date type for the platform with type inference

For my programming language, I have built an engine that goes after the parser and before the compiler. This engine analyzes, validates, and simplifies the AST. During the analasys, it determines as ...
Hg0428's user avatar
  • 171
5 votes
1 answer
185 views

Optimization algorithm using conditional invariants

I am looking for an optimization algorithm that would make use of invariants in regions of code. For example if (n == 0) f(n); should be changed to ...
chrysante's user avatar
  • 628
4 votes
2 answers
142 views

Supporting reasonably efficient high-level indexing for strings

I'm designing a language that I intend to be implemented on the .NET platform. To my understanding, the native string representation uses UTF-16, by storing an array of ...
Karl Knechtel's user avatar
2 votes
1 answer
994 views

Why do we put imports at the top of files? [closed]

Most of the popular programming languages I know of either require or strongly encourage import statements to be at the top of the file, before any of the ...
Silvio Mayolo's user avatar
6 votes
1 answer
136 views

What's the benefit of using different tokens for accessing nested namespaces/modules versus properties?

In JavaScript, accessing items from a module is done using ., e.g. moduleBar.moduleFoo.functionFoo, which looks exactly the same ...
Lazar Ljubenović's user avatar
32 votes
2 answers
17k views

Why do common Rust packages depend on C code?

Chapter 1 of "The Rust Programming Language" (Klabnik and Nichols) says: [S]ome common Rust packages depend on C code and will need a C compiler. Why do Rust packages have any dependency ...
StoneThrow's user avatar
1 vote
3 answers
274 views

Is there any way a Java-like language could implement immutable primitive arrays without incurring performance penalties?

I asked: What prevents Java from having immutable primitive arrays? a while back and got an answer: Because immutable primitive arrays would typically require checking some immutable flag every time a ...
user16217248's user avatar
  • 7,285
6 votes
3 answers
3k views

How to implement + in a language where functions accept only one argument? [closed]

While reading about currying, I found the argument that it is beneficial in languages, which have only functions accepting only one argument. I am wondering how to implement a 2-ary function like the ...
ceving's user avatar
  • 356
1 vote
1 answer
111 views

Expressing runtime constraints with trait-bounds

I've recently listened to Corecursive episode with John A De Goes and there's one thing that really got me thinking: the idea of type class laws pertaining to performance guarantees. The example ...
gstukelj's user avatar
  • 143
9 votes
1 answer
229 views

What is the difference between GAT and HKT?

I implemented a basic generics-free, parameterless trait (type class) system. And I want to parameterize my trait system. The alternative paths I know of are Generic Associated Types (GAT) and Higher-...
Aster's user avatar
  • 2,552
9 votes
3 answers
1k views

Do parsers typically need access to all tokens?

Do parsers typically operate on the entire array/list of tokens available in memory, or are the tokens often streamed one by one as they are recognized? What influences the decision?
Lazar Ljubenović's user avatar
5 votes
3 answers
272 views

Reading Floating Point, perhaps without libc/msvcrt

Given a new language, how best should we convert decimal to binary floating point? And please don't just say "use strtod(3)": The venerable C function supports a baroque variety of weird ...
Ian's user avatar
  • 153
20 votes
10 answers
4k views

What are the drawbacks of allowing implicit boolean/integer conversions?

Some languages (C, C++, JavaScript, Python) allow one to use integers as booleans and vice versa: int x; if (x) // Equivalent to: x != 0 y(); Or: ...
user16217248's user avatar
  • 7,285
29 votes
5 answers
5k views

Are there Haskell-like languages where equations allow for arbitrary left-hand sides?

In Haskell, you can define algorithms by equations that pattern-match on left-hand side constructors. For example: ...
MaiaVictor's user avatar
13 votes
1 answer
635 views

Is there a difference between Rust's `macro_rules!` and Scheme's `syntax-rules`?

This is an example for the use of Rust's macro_rules!: ...
ceving's user avatar
  • 356
20 votes
6 answers
7k views

Why do some languages have both immutable "variables" and constants?

Some programming languages (Rust is one I can think of off the top of my head) provides mechanisms to have immutable variables but they also have constants. Isn't an immutable variable just a constant?...
QAH's user avatar
  • 311
2 votes
1 answer
179 views

Generic method: type inference

I am developing a verifier for the ActionScript 3 language and I have gone through implementing one before for my personal language. I had a type inference limitation with the following construct: <...
Hydroper's user avatar
  • 769
0 votes
2 answers
104 views

Challanges to integrate sum types into json/protobuffer/toml/yaml? [closed]

What challenges might arise when integrating sum types into data exchange or configuration file formats such as json, protobuf, toml or yaml?
Jw C's user avatar
  • 121
9 votes
1 answer
323 views

Why does ATTAPL's linear product introduction rule not delete the objects from the context?

In Chapter 1 of Advanced Topics in Types and Programming Languages, the following rule is presented for the introduction of a product in a linear/unrestricted type system: ($\circ$ is context ...
blueberry's user avatar
  • 1,582
29 votes
11 answers
18k views

Why do so many programming languages not have a "built-in" way to do simple math functions?

Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without ...
Nike Dattani's user avatar
5 votes
2 answers
616 views

How does the map function work in stack-based languages?

In many languages, the map function takes a function and a list, and applies the function to each element of the list, returning a new list of the results. Some ...
alephalpha's user avatar
9 votes
1 answer
627 views

How does Rust parse ambiguous macros?

Rust's macros require them to be delimited by either parentheses, braces, or brackets, such as println!(arg) or foo! { bar, baz }...
Seggan's user avatar
  • 2,594
14 votes
1 answer
2k views

What language was the first to treat null checks as smart casts to non-nullable types?

As far as I know, for many decades, in mainstream programming languages, there were only two options to handle null-like optionality: Pointer or reference types are always nullable (the famous "...
Eldritch Conundrum's user avatar
2 votes
3 answers
226 views

How do different template languages handle parsing?

In template languages, most of the content is written out as-is, with only certain special markers for expression evaluation or flow control. In my attempts to develop a language of this style, I've ...
kouta-kun's user avatar
  • 1,722

15 30 50 per page
1
2 3 4 5
14