binary constants (??)
Chris Torek
chris at mimsy.umd.edu
Mon Nov 20 05:21:00 AEST 1989
One of my favourite silly ideas for C is now ruled out by X3J11's
`#' `stringize' preprocessing operator (or at least, would require
some other syntax), but it went like this: Instead of having hex,
decimal, octal, binary, etc., constant syntaxes, why not have a
single syntax for `based numbers'? The initial radix would always
be decimal; the format would be something like
#(base,expr)
Numbers in the `expr' part would be interpreted in the base given by
the `base' expression. Any value from 2 to 36 would be legal for the
base. All `numbers' would be of the form
[0-9][0-9a-zA-Z]*
where ordinary digits represent themselves and letters represent digits
>= 10 in the obvious manner. (Whether digits greater than the base
would be legal is essentially irrelevant.)
The sneaky (or silly) bit is that both `base' and `expr' would be
arbitrary constant expressions. This would be useful for obfuscation
such as
#(3+#(2,#(6,13)-0010),#(5,11)/30)
which is actually 1.
(I think.)
Whether the base is always decimal is an unresolved question. (Bases
that are part of the base-forming expression are definitely decimal,
but bases that are part of the based-expression---the stuff to the
right of the comma---might start in the base determined by the thing
to the left. This would probably be a bad idea, since macro expansion
would yeild unpredictable results if the base part were multi-digit.
Of course, this would be even better for obfuscatory purposes.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at cs.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list