February 09, 2006
Walter Bright wrote:
> "Don Clugston" <dac@nospam.com.au> wrote in message news:dscv6f$1kks$1@digitaldaemon.com...
>> Walter Bright wrote:
>>> The one about (a[x]) template arguments? That one turns out to be not so easy to solve, which is why I deferred it. The workaround (putting redundant parentheses around it) is ugly, but not onerous.
>> Indeed. It's just a mild imperfection. Wow, it's really hard to guess what's difficult to implement and what isn't. That one sounded really easy, whereas I guessed that the static if scoping issue was an intrinsic limitation of the parser.
> 
> The trouble is that a[x] could be a type, or it could be an expression. Right now, it assumes it's a type, so it fails to match with a template expression parameter.
> 
>> <g> C++ metaprogramming using partial template specialisation has always felt like drawing with a crayon. With static if, it's so easy.
>> I found a C++ implementation of a compile-time PI calculation, extremely clever but hilariously unreadable. And I bet it took fifty times longer to write than mine did.
> 
> I'd really like a pointer to that, to use as a comparison. Such side-by-side comparisons really drive the point home, and so are very valuable.

It's in
http://boost-consulting.com/vault/
in template metaprogramming, mpl_math.zip, boost/mpl/math/pi.hpp

---- C++ version (excerpt) ----------

// Copyright (C) 2005-2006 Cromwell D. Enage
// Distributed under the Boost Software License, Version 1.0.
[snip]

    template <typename NumericTag>
    struct pi
      : times<
            typename apply1<
                BOOST_MPL_AUX_NUMERIC_CAST<
                    big_integral_tag
                  , NumericTag
                >
              , big_integral<'+',4>
            >::type
          , minus<
                times<
                    typename apply1<
                        BOOST_MPL_AUX_NUMERIC_CAST<
                            big_integral_tag
                          , NumericTag
                        >
                      , big_integral<'+',4>
                    >::type
                  , arcus_tangent< reciprocal_integral<NumericTag,big_integral<'+',5> >
                    >
                >
              , arcus_tangent< reciprocal_integral<NumericTag,big_integral<'+',2,3,9> >
                >
            >
        >::type
    {
    };

---- D version ----------

const pi = 4.0 * (4*atan!(1/5.0) - atan!(1/239.0));

I think it makes the point rather well.

It's also interesting to compare the implementation of atan!() with arcus_tangent<>; the latter defines a series using the preprocessor and hard-codes the number of terms to be used. You can trace atan!() all the way back and it never gets ugly (there are just a few simple metafunctions, each only a couple of lines long).

However, the C++ version is still under active development (last update 2006-1-11). Maybe they can close the gap...

Something you might mention is that much of the C++ compile-time stuff is performed during the optimisation pass. 100% of the D metaprogramming is performed during the semantic pass (and you can verify this by running the programs with the -c option, so that no object file is generated).

>> The regex example blew my socks off,
>>> and I wanted to showcase it. That meant fixing D's templates so regex didn't need all those ugly workarounds.
>> Time for that to move from proof-of-concept to some serious code, I think. If I only had some time...
> 
> Don't we all <g>. It'd be great to have it in place before SDWest, because then there'll be a surge of very influential people looking at it. 

Unfortunately, I won't be able to spend _any_ time on D in the next two weeks, so it will be tough. I had a look at the programme, it's perhaps a shame you're up against Dave Abrahams on metaprogramming, a lot of the target audience will hear him instead.

February 09, 2006
"Don Clugston" <dac@nospam.com.au> wrote in message news:dseu57$p3p$1@digitaldaemon.com...
> Walter Bright wrote:
>> "Don Clugston" <dac@nospam.com.au> wrote in message news:dscv6f$1kks$1@digitaldaemon.com...
>>> <g> C++ metaprogramming using partial template specialisation has always
>>> felt like drawing with a crayon. With static if, it's so easy.
>>> I found a C++ implementation of a compile-time PI calculation, extremely
>>> clever but hilariously unreadable. And I bet it took fifty times longer
>>> to write than mine did.
>>
>> I'd really like a pointer to that, to use as a comparison. Such side-by-side comparisons really drive the point home, and so are very valuable.
>
> It's in
> http://boost-consulting.com/vault/
> in template metaprogramming, mpl_math.zip, boost/mpl/math/pi.hpp

Thanks, this is exactly what I need.

> I think it makes the point rather well.

It sure does.

> However, the C++ version is still under active development (last update 2006-1-11). Maybe they can close the gap...

I doubt it. It isn't even on the same continent.

>> Don't we all <g>. It'd be great to have it in place before SDWest, because then there'll be a surge of very influential people looking at it.
> Unfortunately, I won't be able to spend _any_ time on D in the next two weeks, so it will be tough. I had a look at the programme, it's perhaps a shame you're up against Dave Abrahams on metaprogramming, a lot of the target audience will hear him instead.

Sadly, they put me in a poor time slot.


February 14, 2006
Walter Bright wrote:
> "Don Clugston" <dac@nospam.com.au>
>> Walter Bright wrote:
>>> "Don Clugston" <dac@nospam.com.au>

>>> Don't we all <g>. It'd be great to have it in place before
>>> SDWest, because then there'll be a surge of very influential
>>> people looking at it.
>> 
>> Unfortunately, I won't be able to spend _any_ time on D in the next
>> two weeks, so it will be tough. I had a look at the programme, it's
>> perhaps a shame you're up against Dave Abrahams on metaprogramming,
>> a lot of the target audience will hear him instead.
> 
> Sadly, they put me in a poor time slot.

Have no fear, there's _nothing_ one remembers so well as when one bets on the "safe" thing, and then on the break the hall is just bursting from what the other guy had said!

That'll make them play catch-up and the buzz will go on for weeks.

Thanks to this, next year you're the one with a line round the block!
February 14, 2006
Walter Bright wrote:
> "Charles" <noone@nowhere.com> wrote in message news:dsag9h$2cm8$1@digitaldaemon.com...
> 
>>>I'd say hold off on designing a template library without implicit
>>>function template instantiation.
>>
>>That scentence is a little tricky for me, does that mean IFTI is expected
>>for 1.0 ?
> 
> Yes. 

Wow!

I'm just breathless: incredible leaps!!!
1 2 3
Next ›   Last »