lua-users home
lua-l archive

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


Rici Lake wrote:

On 16-Aug-05, at 1:12 PM, Chris Marrin wrote:

The one nice feature that Python has is:

    from math import *

which imports all names from math into the namespace. I suppose that could be done with:

    import("math", "all")

or something like that.


This cannot be done at compile time, since the compiler has no real way of knowing what might be in a package at run time. So it could not fabricate the necessary locals.

Does it have to be done at compile time? Couldn't the import function simply iterate over all the members of math and put them in the local namespace? Or is that not possible somehow?

--
chris marrin                ,""$,
chris@marrin.com          b`    $                             ,,.
                        mP     b'                            , 1$'
        ,.`           ,b`    ,`                              :$$'
     ,|`             mP    ,`                                       ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'