lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Lua list <lua@bazar2.conectiva.com.br> writes:

>Aliases in the form
>	alias x=longVarName, y=AnotherLongVarName
>are trivial to implement with token filters (though respecting scopes will
>need some real work).

Do you mean that this would create new variables called x and y in the
function where the expression is used? This isn't what I was thinking of,
really. I imagined the aliases simply being "local" to the expression or
assignment (the leading question mark is to distinguish the symbols from
ordinary variables). So you could write:-

   ?x = longVarName?x + 1

...but it would be an error to follow this with

   newVar = ?x * 2

...on the next line because the ?x only exists for a single
expression/assignment. It's a bit like Python's lambda expressions or the
DEF FN you used to get in old versions of Basic but the declaration is
built into the expression and the "dummy" variable names disappear
immediately after the expression is finished.

It occurs to me that it might be an advantage to be able to alias values
on the left of the assignment too, in cases like:-

   table.x, table.y = table.y, table.x

...which would become

  table?a.x, ?a.y, = ?a.y, ?a.x

...a little bit like the swizzling feature in shader languages only more
flexible and less concise.

&.


#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal.
The Blackpool Sixth Form College.
#####################################################################################