[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua language extension for complex number and vector values
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 31 Mar 2011 08:40:05 +0200
On Thu, Mar 31, 2011 at 3:20 AM, David Manura <email@example.com> wrote:
> you know at compile time which operations must be interpreted as
> vector operations because the lexical variables are statically typed
> as vector
Yes, although to handle full complex arithmetic you must parse such
expressions into some AST form in order to generate the real and
complex parts of the expression. A bit messy, but the performance
benefits would be worth it.
It doesn't feel like something that should or needs core changes -
more like a supercharged preprocessor with MetaLua-like capabilities,
but emitting Lua code for LuaJIT, etc.
'Values' like c are interesting, because they can never be first-class
values. They are a generalization of '...' and subject to the same
restrictions - can only put into tables if explicitly packed as a
table, etc. So formally they are nasty to reason about.
Although I have noted that high-performance computing and elegance are
sometimes rather orthogonal ;)
 Fortran always had support for complex numbers, because in
scientific computing real numbers are mostly a special case of complex
 rather like the first cfront implementations of C++ which generated C code.