Boost logo

Boost Users :

From: Tarjei Knapstad (tarjeik_at_[hidden])
Date: 2003-05-20 16:10:15


On Tue, 2003-05-20 at 17:56, David Abrahams wrote:
> Tarjei Knapstad <tarjeik_at_[hidden]> writes:
>
> > On Mon, 2003-05-19 at 21:34, David Abrahams wrote:
> >> Tarjei Knapstad <tarjeik_at_[hidden]> writes:
> >>

<snip>

> >>and it's easy to see that pop_front<List>::type is
> >> evaluated whether List is empty or not.
> >>
> > ...is it?
>
> Sure! What happens when you try to Reverse an empty sequence?
>
Ah yes certainly, but in my real case (i.e. not this Reverse thingy),
giving an empty sequence means you're trying to generate illegal code,
so it's actually a positive side effect there (sorry, forgot to mention
this...)

> > I thought apply_if<> only instantiated either the 'true' or
> > 'false' statement depending on the condition.
>
> Yes, but it doesn't inhibit evaluation *lexically*. Whenever you
> write ::type, you get a non-lazy evaluation. In fact, your apply_if
> is not delaying anything, since you greedily evaluate the 2nd
> argument, and the first argument is already the right type. You'd get
> the first argument correctly because
>

<snip, long explanation>

Ahh, it was the ::type requests which I didn't have a sufficient
understanding for. I've solved it for now by specializing my class
template for an empty sequence (I had a look at the Lambda stuff, but it
involved quite a bit more than the specialization so I've postponed it)

>
> Oh, and please, do yourself a favor and follow the MPL metafunction
> protocol! That means your result is called "::type", not "::Type".
>
Yes, but this goes againts our own coding standards unfortunately (all
types are captialized). I'm considering a modification to our standards
though, in that stuff that models STL concepts (like iterators etc.)
should be named like they are in the STL. I'm still undecided on what
will end up being less confusing...

On a sidenote, I seem to remember from the ACCU conf. in Oxford this
year that you were preparing a book on the MPL? Is it in it's early
stages, or do you have any rough date for it's completion? (It certainly
looks like I could need a copy ;) )

Thanks,

--
Tarjei

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net