Implicit enum conversions are a stupid PITA
Adam D. Ruppe
destructionator at gmail.com
Thu Mar 25 12:01:53 PDT 2010
On Thu, Mar 25, 2010 at 11:45:11AM -0700, Walter Bright wrote:
> Good point. As I recall, we expended an enormous amount of effort working
> on template syntax, and I certainly feel that
>
> octal!"177"
>
> is far better than, say:
>
> octal<"177">.value
>
> but when I compare it to
>
> 0177
What about O!177?
The O template would take the integer passed as its argument, convert it
to a string, then convert that back into number assuming it is octal.
(Or some implementation of that idea.)
It just saves the quotes there, but ends up looking very close to the
custom syntax.
And it frees up leading zeroes for use in base ten where they belong to
make pretty tables. Though you might want to ban this for C compatibility
anyway.
--
Adam D. Ruppe
http://arsdnet.net
More information about the Digitalmars-d
mailing list