Quote without comment on char constant expansion
Ray Butterworth
rbutterworth at watmath.waterloo.edu
Wed Apr 27 01:50:11 AEST 1988
In article <522 at sol.warwick.ac.uk>, cudcv at daisy.warwick.ac.uk (Rob McMahon) writes:
> In article <7683 at brl-smoke.ARPA> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
> >In article <11056 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
> >>perhaps there should be a `charize' operator.
> >
> >It's been voted down (back when we hadn't settled on # and ## yet).
> >There has been a comment that &"..." should be allowed in constant
> >expressions.
>
> Maybe now that # & ## have been settled on, it's time for another vote ?
> It seems it ought to be there just for consistency, and it would provide
> a much cleaner solution than this #c[0] as a constant (is that right ?).
> Out of interest, what were the arguments against it ?
Better yet, if some future version of the Standard decides that
a "charize" operator would be a good thing, what on Earth are they
going to call it? ### ?
But doesn't "x###y" already have a meaning as "x ## # y"? i.e. x"y" ?
Yes, but ### is a longer string, so it is taken as charize just
as x+++++y is taken as the illegal "x++ ++ + y" rather than the
meaningful "x++ + ++y".
But that means that introducing this will break any code that
now thinks that ### means ## #. And there might be some in
light of the new "L" string prefix. e.g.
#define STRING(value) L###value
so that STRING(abc) generates L"abc".
And if they ever need another new operator, will it be #### ?
Good grief!
Why did the committee come up with such a limited and non-obvious
naming scheme for the preprocessor operators?
What would have been wrong with something like:
Current Renamed Resyntaxed Meaning
#x #string x #string(x) "x"
x##y x #glue y #glue(x,y) xy
----- #character x #character(x) 'x'
defined(x) #defined(x) #defined(x) preprocessor token x is defined
#define STRING(value) L #join #string value
or
#define STRING(value) #join(L,#string(value))
These new names (or better yet, the new syntax) is certainly
more obvious than the ## and # names, it doesn't step on
any name space other than the current preprocessor directive,
and it allows new preprocessor operators to be added with little
difficulty.
More information about the Comp.lang.c
mailing list