Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A quick(doubtfully simple) namespace question

0 views
Skip to first unread message

Joshua Isom

unread,
Jan 4, 2006, 6:49:49 PM1/4/06
to perl6-i...@perl.org
The PIR syntax.pod file says that nested namespaces can be used by
separating namespaces with a semicolon, ala nested array/hash
structures. But the common writing convention seems to be along the
lines of perl5 packages with a double colon to separate. After looking
at the "find_global Foo::Bar::baz" test in t/pmc/namespace.t, I suppose
it's easily understandable that without a change to the find_global
opcode to allow a similar syntax to getting and setting array/hash
values that the double colon is preferable. All of the files in the
runtime/parrot/library directory use the :: method. A quick grep on
partcl seems to use both the double colon in a string and a null
character in a string, including multiple null characters. Although
it's "clipped", pdd06 says namespaces should be separated with a double
colon.

In any case, for the whole "future compatability" issue, which would be
prefered, double colon in the string, semicolon separating strings, or
null characters in strings?

Leopold Toetsch

unread,
Jan 5, 2006, 5:08:21 AM1/5/06
to Joshua Isom, perl6-i...@perl.org

On Jan 5, 2006, at 0:49, Joshua Isom wrote:

> In any case, for the whole "future compatability" issue, which would
> be prefered, double colon in the string, semicolon separating strings,
> or null characters in strings?

A namespace 'Foo::Bar' is just one, albeit funny, name and inaccessible
for languages like Python (without a wrapper). [1]

['Foo' ; 'Bar'] denotes a nested namespace and is totally different. [2]

A key with a leading NUL: "\0Foo" denotes the name of a nested
namespace hash. This is just an internal convention to be able to store
a variable name 'Foo' in the same namespace. [3]

%globals = {
'Foo::Bar' => $P1, # [1]
"\0Foo" => { "\0Bar => $P2 }, # [2]
'Foo', # [3]
}

HTH,
leo

0 new messages