[Click] compound element keyword arguments
Eddie Kohler
kohler at CS.UCLA.EDU
Wed Mar 17 10:54:47 EST 2004
On Mar 17, 2004, at 8:48 AM, Douglas S. J. De Couto wrote:
> re: perl -w
>
> i don't really care, but as far as i can tell the only reason you
> would ever give click empty arguments in an argument list is that you
> made a mistake somewhere.
Here's the example. It may seem familiar if you've ever used variadic
macros in C/C++.
elementclass PrintReplacer /* supposed to replace Print,
supporting
the same keyword arguments as Print does */
{
__REST__ $keywords |
input -> c :: Counter -> p :: Print(NBYTES 10, $keywords) -> output
}
pr :: PrintReplacer; /* should work */
pr2 :: PrintReplacer(TIMESTAMP true); /* should also work */
Check out the expansions of PrintReplacer/p:
pr/p :: Print(NBYTES 10, ); /* since $keywords is empty */
pr2/p :: Print(NBYTES 10, TIMESTAMP true);
*This* is why I'm thinking empty arguments should be ignored. There's
basically no
way to avoid empty arguments with __REST__ arguments. Gcc implements a
horrible hack,
as follows:
#define FOO(args...) printf("whatever" , ## args);
*********
Since 'args' is a variadic macro parameter, the token pasting operator
means something
weird and new here: If args is empty, then ", ## args" expands to
nothing (the comma
disappears); but if args is nonempty, then ", ## args" exapnds to ",
args" (the token
pasting disappears).
So this is what I'm trying to avoid. Anyone have a better suggestion?
And yes, there should be a Click preprocessor -- and no, it shouldn't
be just cpp ;)
Eddie
More information about the click
mailing list