Boost logo

Boost :

Subject: Re: [boost] Formal review request: static size matrix/vector linear algebra library (Boost) LA
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2010-02-16 09:10:17


[sorry for dropping in the conversation, but I love these games of
play-with-syntax]

On Thu, Feb 11, 2010 at 5:12 PM, Emil Dotchevski
<emildotchevski_at_[hidden]> wrote:
> On Wed, Feb 10, 2010 at 11:20 PM, Joel Falcou <joel.falcou_at_[hidden]> wrote:
>> Emil Dotchevski wrote:
>>>
>>> By overloading generically, I mean the way other operators are
>>> overloaded in (Boost) LA: they're namespace-scope functions that
>>> kick-in for any conforming user-defined vector or matrix type.
>>
>> Oh yeah OK i see it now.
>> What about:
>>
>> at(v, (_2,_1,-_3)) = xxx ; ?
>
> Perhaps at<2,1,-3>(v) = xxx
>

That would lose the convenience of ADL (AFAIK ADL does not work when
you explicitly specify the template parameters). Also you would have
to use a different syntax if you were to add the possiblity to specify
the swizling at runtime.

This could be made to work:

(_2,_1,-_3)[v] = xxx;

but it is counterintuitive, altough in a perverse way it is consistent
with the rest of the language (think "string"[n] and n["string"]).

A more realisistic and simpler syntax would be:

  at(v)[_2,_1,-_3] = xxx;

at() could be implemented as the identity funciton by default so that
operator[] can be easily implemented as a member of v. To adapt
existing vectors or matrices one would just overload at() for v and
return a proxy.

Just my 0.02€

-- 
gpd

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