|
Boost : |
Subject: Re: [boost] [xint] Boost.XInt formal review (concrete complaint)
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2011-03-09 13:04:16
Chad Nelson wrote:
> On Tue, 8 Mar 2011 10:01:13 -0800
> "Simonson, Lucanus J" <lucanus.j.simonson_at_[hidden]> wrote:
>
>>> Thanks. I think I see it now, and I'm playing with the concept to
>>> see whether it would be a good fit. Early comments from people
>>> who've used it suggest that it might not be.
>>
>> Ok, who were those people and what did they say about expression
>> templates?
>
> Eric Niebler: "[...] Joel, I'm honored by your enthusiasm for Proto,
> but in this case, I think it's misplaced. For a simple value type like
> an infinite precision integer, expression templates are just plain
> dangerous."
Perhaps Eric can elaborate on this. Is the usage of expression templates by GMP dangerous? I already said Proto shouldn't be used for the expression templates and if asked my opinion on how to implement the expression template syntax I would steer you away from SFINAE or even tag dispatching based designs and toward function overloading because I'm not proposing a big int concept, just an expression template system that handles only the library provided big int type and expressions thereof. I have designed several expression template systems and I think I know what is dangerous and how to avoid it. I am more than willing to help you. I respect Eric's opinion and if he knows why a simple expression template system like the one used in valarry or GMP itself is a bad idea I'm willing to listen.
> Peter Dimov: "[...] a large integer library doesn't seem like a
> trivial application. Even simple things [...] don't seem entirely
> straightforward when the goal is to eliminate all temporaries. So
> rewriting everything to use expression templates (properly) could be
> quite an amount of work."
Yes, it would be quite an ammount of work. That however is a very poor rationale for not doing the work. You aren't on a schedule (as far as I know) and can take your time to get the interface right. You stand to learn a lot from the experience and I think it would be effort well spent. It would be less work than I did for Polygon's redesigned interface before I brought it for review. I worked on that library for three years before I brought it for review and rewrote the interfaces twice. I have already proposed a fairly simple way to eliminate all temporaries using expression templates without complicated template metaprogramming. No need to create a complex system of rearranging expressions, no trying to implement a compiler that runs at compile time on expressions, just alloca if less then 4k.
> Steven Watanabe: "Expression templates are a powerfull tool. However,
> I'm not convinced that they're appropriate for this library. Although
> they allow some clever optimizations, the extra complexity can cause
> confusion. This is a fairly basic library which we can expect to be
> used by people who don't know the language well enough to cope with
> the problems easily."
No one has ever complained that the expresion templates in Polygon make the library hard to use, and I have many users of different experience levels. I have never had a problem with GMP's expression templates. Let me restate that clearly, unlike problems that were easy for me to deal with, GMP's expression templates posed no problems for me at all. I'm no proposing that the user be given the ability to extend the expression template system, so there is no need for them to understand or even be aware of it. My Polygon users often have no idea how the library works, but are quite happy with the productive operator syntax (in many cases.) The lower the experience level, generally, the happier they are to ignore the implementation details of the library and just use it to get their job done.
Regards,
Luke
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk