Nigel Tao
unread,Feb 26, 2015, 10:20:36 PM2/26/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to snes...@gmail.com, golang-dev, David Crawshaw, Stephen Gutekanst, Jeff Juozapaitis, Dmitri Shuralyov, Robert Griesemer
On Thu, Feb 26, 2015 at 10:30 PM, <
snes...@gmail.com> wrote:
> How to arrive at a consensus about the type definitions? I have been torn
> between [4]float32 and X, Y, Z, W variants for instance, and what about R,
> G, B, A selectors, etc.. I wished Go would allow a union of those like
> C/C++, or GLSL like flexible field syntax. From a distance i would say that
> the array variant is the most flexible and generic, but i find code written
> using it less clear to read. Maybe the use of constants for indexing can
> alleviate this, a la vec[X], where: const X = 0, etc.
We arrive at a consensus by discussing it in this mail thread and on
the code review. Note that there are valid arguments for a variety of
approaches, e.g. whether a Mat3 is [3][3]float32 or [9]float32, but at
some point we have to pick one and stick with it.
As for saying v.X instead of v[X], I don't think that's going to
happen in Go per se. I could imagine a separate 'compiler' that took
something similar to GLSL shaders and translated "a.X = b.G" to be
"a[0] = b[1]", or skipped the middleman and output (SIMD) assembly
that was compatible with the Go calling convention, but I don't see it
part of Go the language.
You are, of course, free to define your own X, Y, Z, W, R, G, B, A, S,
T, P and Q constants in your own package.