hughperman / pure-lang

Automatically exported from code.google.com/p/pure-lang
0 stars 0 forks source link

namespace issue? #62

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The file ns.pure contains:

using system;
namespace ns;
foo x = puts $ str x;
::bar1 x = foo x;
::bar2 x = ns::foo x;

At the prompt I get:

play$> pure -w 
Pure 0.49 (i686-pc-linux-gnu) Copyright (c) 2008-2011 by Albert Graef
(Type 'help' for help, 'help copying' for license information.)
Loaded prelude from /usr/local/lib/pure/prelude.pure.

> using ns;
ns.pure, line 6: undeclared symbol '::bar1'
ns.pure, line 7: undeclared symbol '::bar2'
> show ns::foo
ns::foo x = puts (str x);
> show bar1
> show bar2
> show ns::bar1
> show ns::bar2

> sysinfo;
"i686-pc-linux-gnu"

I expected bar1 and bar2 to be defined in the global namespace.

Is this a bug?

Original issue reported on code.google.com by p.summer...@gmail.com on 16 Nov 2011 at 8:28

GoogleCodeExporter commented 8 years ago
Not a bug. See 
http://docs.pure-lang.googlecode.com/hg/pure.html#symbol-lookup-and-creation. 
You're trying to introduce new qualified identifiers outside their home 
namespace, which is forbidden. The solution is to just declare the symbols in 
their proper namespace beforehand:

using system;
public bar1 bar2;
namespace ns;
foo x = puts $ str x;
::bar1 x = foo x;
::bar2 x = ns::foo x;

Original comment by aggraef@gmail.com on 16 Nov 2011 at 10:04