Quantcast
Channel: User CPlus - Programming Language Design and Implementation Stack Exchange
Browsing all 65 articles
Browse latest View live

What are the advantages of strings and character arrays being different?

In many languages such as Java, strings and character arrays are distinct types. In Java one must use toCharArray() in order to use array semantics on strings.In C, strings and character arrays are...

View Article


How would I describe an expression seperately from a statement?

I have thought about how I could specify an expression separate from a statement.A fragment of code that resolves to a value.But void expressions are still expressions but do not really resolve to a...

View Article


Entry point of low level languages

I noticed C defines the entry point as a main() function. So does Java. So does C++ (or not, because functions called as global variable initializers are called before main(). I was wondering. Is there...

View Article

Comment by CPlus on When can widening conversions cause problems?

Though do note, however, that this problem could be avoided if the wider type was unsigned, which Java unfortunately does not support.

View Article

Comment by CPlus on What's the rationale behind switch/yield in Java?

@CommunityCompiler Nah, this answer is clear.

View Article


What are the ways compilers recognize complex patterns?

This answer is an example of a compiler recognizing that a complex expression is equivalent to a single operation:uint8_t pcnt64(uint64_t n) { n = n - ((n >> 1) & 0x5555555555555555ULL); n =...

View Article

How would I describe an expression separately from a statement?

I have thought about how I could specify an expression separate from a statement.A fragment of code that resolves to a value.But void expressions are still expressions but do not really resolve to a...

View Article

When can widening conversions cause problems?

I can understand the reason for raising a warning or error when you try to convert a wider integer type to a narrower one, due to the loss of precision.Some C compilers will warn about this:uint32_t x...

View Article


Comment by CPlus on How might we deal with this special case of using a...

But is this not what using an escape character, such as a blackslash, is for?

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 Is there any particular reason to only implement 2 and 3...

Because 2 and 3 argument versions are used vastly more often.

View Article

Comment by CPlus on Why short and long and double and similar instead of...

I was not aware of such a requirement. I thought the Standard said that floating point format is implementation-defined.

View Article

Comment by CPlus on Why short and long and double and similar instead of...

@NateEldredge In hindsight in those cases, I find what C99 did to be the most logical, having the ambiguous, but required intlong etc., but also offering the unambiguous int32_tint64_t but only...

View Article


Comment by CPlus on Is there any way a Java-like language could implement...

What is meant by if we cannot prove linearity, freezing would fall back to copying?

View Article

What optimizations are possible with unsequenced operators?

In C, most binary operators do not specify which operand will be evaluated first:int x(void) { putchar('x'); return 10;}int y(void) { putchar('y'); return 10;}// ...x()+y(); // Unspecified behavior as...

View Article


Why did C99 have to add the underscored keywords for _Bool _Complex...

C99 introduced the following keywords: _Bool_Complex_ImaginaryinlinerestrictWhy _Bool_Complex and _Imaginary instead of just boolcomplex and imaginary? To preserve backwards compatibility for existing...

View Article

Comment by CPlus on What are the advantages if caller is responsible for...

This question is similar to: What are the advantages and disadvantages of the callee versus caller clearing the stack after a call?. If you believe it’s different, please [edit] the question, make it...

View Article


Why would a language need to have trap representations?

In C there is a concept of trap representations, or non-value representations. If such a value is produced or used, immediate undefined behavior is invoked. This is one of the dangers of using...

View Article

How do modern compilers choose which variables to put in registers?

C has the register keyword, originally designed as a hint to the compiler that a variable should be placed in a register rather than on the stack. However this is generally considered an unneeded...

View Article

Comment by CPlus on Decimal point as a binary operation

I am not sure why this would simplify the PL design.

View Article
Browsing all 65 articles
Browse latest View live


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