Quantcast
Browsing all 65 articles
Browse latest View live

Why are mixed declarations more challenging to implement than forcing all...

C89 had a requirement that all declarations must appear at the top of the scope before any statements:int func(void) { int x = 10; f(); int y = 20; // Invalid // ...}However this requirement was easy...

View Article


Answer by CPlus for What are the advantages/disadvantages of null-terminated...

Short String OptimizationOne way one could save having to allocate a separate buffer at a separate location is short string optimization. The idea is if the string is shorter than the size of a...

View Article


Why are symbols (especially static/internal symbols) necessary?

Compiled languages seem to always have to attach some name to any global object, such as a function or global variable, even after they are compiled, but not local variables. As such, languages such as...

View Article

Answer by CPlus for Why do so many programming languages not have a...

One possible reason why C does this is because C has a concept of hosted and freestanding implementations. If an implementation is freestanding, then the standard libraries do not need to be provided....

View Article

Is there any particular reason to only include 3 out of the 6 trigonometry...

Most languages seem to only have sincos and tan. While the other 3 are just 1/cos1/sin and 1/tan, is there any way that supporting the other 3 directly could be faster than calculating one and then...

View Article


Answer by CPlus for What are the pros and cons of interpreted programming...

The ability to product self-modifying code, such as by producing strings that are then executed as if they are a piece of code of said language, are trivial to do in an interpreted language, but not so...

View Article

Answer by CPlus for Types and variables in a different namespace

Function call or type cast?One example of an ambiguous statement in a C-style language that supports type names and object names overlapping is if there is a function or function pointer called x and a...

View Article

Types and variables in a different namespace

What would it take to design a language that permitted construct such as below?int int = 10;Such a language would need to be able to infer contextually whether a type name or an expression is expected....

View Article


Is there any way a Java-like language could implement immutable primitive...

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...

View Article


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:int x = 10 + (y > 10); // Equivalent to: y > 10 ? 11...

View Article

What are the advantages and disadvantages of the callee versus caller...

This is more a question about compiler design than language design, but in low level languages, when a function is called, the parameters are pushed onto the stack, and when the function returns, the...

View Article

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:static int x;static int *const p = &x;static const char...

View Article

Image may be NSFW.
Clik here to view.

Why is truncated or non-Euclidean division/modulo the norm?

Related to, but not the same question: Distinguishing modulo (Euclidean division) from remainderThere are multiple ways a modulo operation can be performed. Most implementations, in C, for example, use...

View Article


What are the implications of a 'packed' keyword/feature?

I am bothered by the fact that, in C, struct types can be arbitrarily large. We have no control over their memory layout except for the fact that the first member is always at the beginning of the...

View Article

Why would a language have a concept of undefined behavior instead of raising...

Certain constructs or conditions in programming just are not allowed. Languages such as Java or Swift handle these by raising an error when encountered. C and C++ on the other hand say 'Anything could...

View Article


Comment by CPlus on Why are volatile objects so difficult to work with in C++?

Welcome. I am confused as to why you posted a screenshot of the code as opposed to the text of the code. Besides that, this is a great first answer.

View Article

Comment by CPlus on Why target an existing VM?

Because then anyone who has their VM can also run your code.

View Article


Comment by CPlus on Can sine converge to zero at infinity?

I'm voting to leave open. This essentially asks about the consequences of a programming language that defines sin(infinity) = 0.

View Article

Comment by CPlus on How can I specify a programming language step-by-step...

I don't think this should be closed. This is a good question with a useful answer.

View Article

What prevented fopen() from utilizing macros/flags but not fseek()?

In C, fopen() uses string literals such as "r" or "r+" or "w" to specify the mode with which to open a file. One possible reason for this I read is at the time C was so new that there might not have...

View Article
Browsing all 65 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>