Re: Namespace Proposal

new topic     » goto parent     » topic index » view thread      » older message » newer message

In My Humble Opinion:

include "misc.e" -- will include in global namespace
? PI

include "graphics.e" as abc -- include in abc namespace
abc.sound(500)

with abc
   sound(500) -- same as abc.sound(500)
end with

namespace def
    function func()
        return 500
    end function
    
    global atom wow
    wow = 400

    namespace ghi
        atom some
        some = 123
    end namespace
end namespace

? def.func()     -- 500
? def.wow        -- 400
? def.ghi.some   -- 123
? def.ghi.wow    -- 400 (because declared as global)
? wow            -- error

with def
    with ghi
        ? some   -- 123
    end with
end with

with def.ghi
    ? some       -- 123
end with
    

# contents of file shape.e ---------------------

global object x = 50     -- i hope in 2.3 it is legal

namespace square
    atom W = 100, L = 200
end namespace

namespace other
    atom W = 111
    function L() return 222 end function
end namespace

global atom GLOBALALL = 44444

# end contents --------------------

include "shape.e" as form

? form.x         -- 50
? form.square.W  -- 100
? form.other.L() -- 222
? form.other.x   -- 50  (because global)
? GLOBALALL      -- 44444 (if in the include file not in namespace,
                 -- variable will become global)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu