> (...) that has the nasty problem that 3 does not have a type (...)
How is that possible? At least in Common Lisp, all literal objects have types, and the same is true of C from what I have just checked.
How is that possible? At least in Common Lisp, all literal objects have types, and the same is true of C from what I have just checked.
Prelude> :t 3
3 :: Num p => p
> It is an error if the constant value cannot be represented as a value of the respective type. An untyped constant has a default type which is the type to which the constant is implicitly converted in contexts where a typed value is required, for instance, in a short variable declaration such as i := 0 where there is no explicit type. The default type of an untyped constant is bool, rune, int, float64, complex128 or string respectively, depending on whether it is a boolean, rune, integer, floating-point, complex, or string constant.