Low dimensional matrices, vectors, quaternions and a cubic equation solver

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Apr 19 13:31:18 PDT 2010


On 04/19/2010 02:41 PM, Eric Poggel wrote:
> On 4/16/2010 10:41 PM, Andrei Alexandrescu wrote:
>> Generally I'd strongly suggest making operations free generic functions
>> instead of members.
>
> I disagree on this one. It unnecessarily adds more names to an outer
> namespace and makes code less readable:
>
> vec1.cross(vec2).project(vec3).length();
>
> vs:
>
> length(project(cross(vec1, vec2), vec3);
>
> The first reads naturally while the second is more like polish notation
> and is easier to forget parentheses, as I did.

Notationally I agree - but you are (or at least should be) able to 
invoke a nonmember as if it were a member.

Andrei



More information about the Digitalmars-d mailing list