-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
acceptedThis proposal is planned.This proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Description
Currently we emit an error if we attempt to pass a comptime literal to be formatted.
printf("{}", 5);
error: parameter of type '(integer literal)' requires comptime
This example requires that the 5 be explicitly cast to an integer of specified size before we can actually print.
printf("{}", u64(5));
Often, we just want any readable value we can so we could instead check whether the literal fits into the range of a specific large integer type (i.e. u64
) and cast within the printf
routine.
This proposal suggest doing automatic casting within printf
in order to simplify and make code clearer. Also note we have a similar issue for floats, however casting/narrowing there is likely a bit more nuanced in respect to preserving precision.
The following would compile and work if accepted.
printf("{}", 5);
Metadata
Metadata
Assignees
Labels
acceptedThis proposal is planned.This proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.