Boost logo

Boost :

Subject: Re: [boost] [qvm] Terseness of syntax etc.
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2015-12-09 15:19:06


On Wed, Dec 9, 2015 at 12:35 AM, Dominique Devienne <ddevienne_at_[hidden]>
wrote:

> On Tue, Dec 8, 2015 at 10:13 PM, Emil Dotchevski <emil_at_[hidden]>
> wrote:
>
> > On Tue, Dec 8, 2015 at 11:07 AM, Francois Duranleau <
> > xiao.bai.xiong_at_[hidden]> wrote:
> > > [... ] I would shy away from the X, Y, Z (and combinations) [...]
> > to avoid clashes with macros
> >
> > Swizzling is rendered nearly useless if it requires elaborate syntax or
> > long names. Currently, if you want the Z and X swapped, you'd use
> (v,ZYX).
> >
>
> Again (and sorry for the bikeshedding), wouldn't (v,asZYX) or (v,toZYX) be
> terse enough and a bit more expressive, while further limiting potential
> conflicts with macros? --DD
>

toZYX won't work because swizzling gives you an lvalue, e.g. you could
write (v1,ZYX) += v2.

asZYX could work but then (v,asZ) looks weird.

If the swizzling names are to be prefixed with anything, then they should
be converted to lowercase. The reason they use uppercase is so that single
element access, e.g. (v,X) doesn't clash with single letter local variables
which presumably are lower case.

An important design goal of QVM is to provide quaternion, vector and matrix
operations for user-defined types, which means that if you have a vector v,
generally its elements could be defined in different ways, e.g. it could be
something like struct float3 { float x, y, z; } or struct vec3 { float
elements[3]; }. Regardless, (v,X) will access the X element of the vector.
Using a longer name here just to avoid clashing with a macro X seems like a
bad idea.

Emil


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