Questions tagged [literals]

For questions related to literals or constant, hardcoded values of a certain data type.

Filter by
Sorted by
Tagged with
5 votes
6 answers

What are the 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
25 votes
6 answers

Negative literals, or unary negated positive literals?

Are there benefits to number literal tokens including negative numbers? Or is the string -1234 being parsed as unary negation of positive number literal ...
bigyihsuan's user avatar
  • 1,663
7 votes
2 answers

Why color literals?

One of the stranger features of Swift is color literals -- invocations of the #colorLiteral macro that look like colored squares in Xcode. In this image, the macro ...
Bbrk24's user avatar
  • 8,857
7 votes
1 answer

What are the disadvantages of being able to define a matrix without typing any words?

Introduction In MATLAB, Octave and Julia, matrices are defined extremely easily. The following line defines a 2x2 matrix in any of those languages: A = [1 3; 4 -1] ...
Nike Dattani's user avatar
7 votes
1 answer

What design trade-offs led to the "Norway problem" in YAML, and when are they worthwhile?

A well-known problem in YAML is a type-inference issue in parsing where a string is misinterpreted as a boolean. This is known as the "Norway problem", because it occurs when a field or ...
Michael Homer's user avatar
  • 11.7k