[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#135730: writeln radix control



> The "pc" compiler on Tru64 (formerly OSF/1 or Digital UNIX) has
> radix control. NOTE: it is typed and works for negative values.
> I get stuff like "-FFF" from -4095 but "EE6CD998" from 4000111000.
> I've no idea how to get leading zeros on these.
>
>    writeln('''', 4095:2:16, '''');

Interesting feature, but there is one problem: The syntax is
ambiguous. `WriteLn (4095:2:16)' can also mean: convert 4095 to real
type (since integer is assignment-compatible to real) and write it
with 16 digits.

More generally, there's a number of useful extensions to the
`Write[Ln]' formatting, including radix control, but also, e.g.,
left/right adjusted or centered output etc., and it seems impossible
to stuff them all in the syntax. Therefore my current plans include
a `FormatString' procedure that takes a format string which
describes all the required formatting. So it's similar to C's
`printf', but without its inherent type unsafeties.

Frank

-- 
Frank Heckenbach, frank@g-n-u.de
http://fjf.gnu.de/
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)



Reply to: