Re: Problem using hexadecimal [format] on integers



On Apr 19, 9:17 am, Helmut Giese <hgi...@xxxxxxxxxxxxx> wrote:

seems like [format] needs a special format for wide integers. Try
format %lx [expr 0x5ade3412ab]

[format] has become a complete mess in Tcl today!
With multiple versions of integer representation
(normal, wide, unlimited; varying by platform)
plus automatic conversion between them, the fixed
size format specifiers are a broken relic from the
past. They require knowledge of a value's special
representation, when that is supposed to be hidden.
Unfortunately, in the beginning, [format] was copied
too blindly from C, but it didn't seem so bad in
those days -- the fixed-size implication of %x and %d
could be viewed as an irrelevant curiosity that had
no effect in Tcl. Now that Tcl has various sized of
integers, entirely different from the system in C,
the carry-over of format specifiers is terrible.
It is a painful hangover.

It seems that recently the meaning of the size
specifiers has changed from a requirement to a
conversion request. This may seem better than
getting type-errors in a typeless language, but
has the bad effect of entrenching and legitimizing
the use of these size-specific tags for type-
conversion. Whereas I would like to have the
simplest forms (%x, %d) work, without conversion,
on all sizes of internal integer.

The question is, would it be feasible to change the
meaning of the format specifiers to drop the size
requirement? Another prefix would have to be introduced
to retain the current behavior for conversion to
regular int.

Donald Arseneau asnd@xxxxxxxxx

.



Relevant Pages

  • Proposal: String::Format::General
    ... It provides format string parsing and output assembly, you provide the code that implements the individual conversion characters. ... Format syntax is kind of a cross between sprintf and strftime, but how close it is to each of these depends on the semantics implemented by the user. ... Note that the following is pre-alpha documentation; the interface to the output conversion code has changed since yesterday, ... conversion character, and contain a number of optional fields which may ...
    (comp.lang.perl.modules)
  • Proposal: String::Format::General
    ... This should be considered pre-Alpha, since it has changed since yesterday, and I am seriously considering passing the format parameters to the output conversion code as a hash reference instead of a large number of arguments. ... Some limited heading capability is provided. ... This module provides a formatter class which allows its user to ...
    (comp.lang.perl.modules)
  • Proposal: String::Format::General
    ... It's almost a meta-formatter with the user providing individual conversion code behind a sprintf/strftime-like interface. ... A format is basically a string into which data are to be inserted. ... conversion character, and contain a number of optional fields which may ...
    (comp.lang.perl.modules)
  • Re: Proposal: String::Format::General
    ... It's almost a meta-formatter with the user providing individual conversion code behind a sprintf/strftime-like interface. ... A format is basically a string into which data are to be inserted. ... conversion character, and contain a number of optional fields which may ...
    (comp.lang.perl.modules)
  • Re: Cobol format conversion
    ... That is useful background. ... explanation of the format specs. ... Or at least this format of COBOL files. ... > probably do as good a job of coding a conversion routine as they can. ...
    (perl.beginners)