Boost logo

Boost :

Subject: Re: [boost] compile time parser generator
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2012-01-09 14:43:53


From: Ábel Sinkovics

>The typesafe printf is important because it is more than a table-based
>regexp recogniser. It builds an MPL list of expected types by parsing
>the format string and type-checks the printf arguments using it. Thus,
>it demonstrates that you have full access to template metaprogramming
>while you're parsing.

Syntax example:

printf<_S("John %d, %s %d\n")>(11, "Joe", 13);

Yay! That syntax doesn't suck. The _S would be BOOST_S if it were a boost library, I guess, or perhaps BOOST_MPL_STRING if we want to be very descriptive. Too bad we need the macro. It would be nice to jet get a variadic template instantiation from the language if we wrote printf<"John %d, %s, %d\n"> directly. It is pretty obvious that we can take this idea and run with it to do something really evil like:

ruby<_S("_1.each {|item| puts item }")>(my_array);

or

perl<_S("foreach $item (@_1){ print "$item\n"; }")>(my_array);

Man is that evil. Right up there with overloading the comma operator evilness. Ok, now, hands please, who wants to implement a Ruby interpreter as a template metaprogram?

Laughing evilly yours,
Luke


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk