lua-users home
lua-l archive

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


Den 2011-09-26 12:07, skrev steve donovan:
On Mon, Sep 26, 2011 at 10:52 AM, Dirk Laurie<dpl@sun.ac.za>  wrote:
but is the proposed 'import sin,cos from math' really so much more
convenient than 'import(math,{"sin","cos"})' as to justify two new
keywords?  (As I have confessed before, I'm a Python _apostate_).
Ah, but note the difference

import sin, cos from math  =>  local sin, cos = math.sin, math.cos

the idea is to get away from globals.  Now this kind of thing can be
done with macros or whatnot, but can't be done with table magic.

steve d.


Even more generic:

  local a,b,c from t

being equivalent to

  local a,b,c = t.a, t.b, t.c

Then the import can be written as

local sin, cos from require 'math'

But I not competent to assess the impact on the Lua grammar and implementation..
Egil