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

Namespace'd subs in IMCC?

3 views
Skip to first unread message

Joseph Ryan

unread,
Sep 6, 2003, 9:57:29 PM9/6/03
to perl6-i...@perl.org
From what I understand from the IMCC documentation, the ".namespace"
macro prepends the namespace name plus "::" to all names within it.
I figured that this would be handy in distinguishing which class a
method belongs to without causing name clashes. For instance:

.namespace foo
.sub bar
end
.end
.endnamespace foo

would create a method bar in the class foo, for a full name of
"foo::bar".

However, this doesn't seem to work. Is this a bug, or should I be
doing something else for this type of problem?


Thanks,

- Joe

Leopold Toetsch

unread,
Sep 7, 2003, 5:10:51 AM9/7/03
to Joseph Ryan, perl6-i...@perl.org
Joseph Ryan <ryan...@osu.edu> wrote:
> From what I understand from the IMCC documentation, the ".namespace"
> macro prepends the namespace name plus "::" to all names within it.

It's for variables only, currently.

> I figured that this would be handy in distinguishing which class a
> method belongs to without causing name clashes. For instance:

> .namespace foo
> .sub bar

> would create a method bar in the class foo, for a full name of
> "foo::bar".

I'm not outerly sure, if imcc should even have such a functionality. Or
at least, if there is one, it should be configurable. The name mangling
is HLL dependent and there may be no general scheme to do it right for
all kind of symbols.

> However, this doesn't seem to work. Is this a bug, or should I be
> doing something else for this type of problem?

It's not layed out what it should really do. I'm towards removing this
directive and let the HLL compiler deal with it.

Proposals welcome.

> - Joe

leo

Joseph Ryan

unread,
Sep 7, 2003, 2:11:14 PM9/7/03
to l...@toetsch.at, perl6-i...@perl.org
Leopold Toetsch wrote:

Well, in that case, would it be possible to allow ":" as a valid
character for use in symbol names?

-Joe

Brent Dax

unread,
Sep 7, 2003, 3:58:02 PM9/7/03
to l...@toetsch.at, Joseph Ryan, perl6-i...@perl.org
Leopold Toetsch:
# I'm not outerly sure, if imcc should even have such a functionality.
Or
# at least, if there is one, it should be configurable. The name
mangling
# is HLL dependent and there may be no general scheme to do it right for
# all kind of symbols.

Then allow a few more symbols in identifiers, and turn namespace into a
prefixing thing that applies to all identifiers:

.namespace Foo::
.sub bar #really Foo::bar
...
.end
.namespace Bar:: #really Foo::Bar::
.sub baz #really Foo::Bar::baz
...
.end
.endnamespace
.endnamespace

# C#, perhaps?
.namespace Quux.
.sub fnord #really Quux.fnord
...
.end
.endnamespace

--Brent Dax <br...@brentdax.com>
Perl and Parrot hacker

"Yeah, and my underwear is flame-retardant--that doesn't mean I'm gonna
set myself on fire to prove it."

Leopold Toetsch

unread,
Sep 8, 2003, 5:15:10 AM9/8/03
to Joseph Ryan, perl6-i...@perl.org
Joseph Ryan <ryan...@osu.edu> wrote:
> Leopold Toetsch wrote:

>>It's not layed out what it should really do. I'm towards removing this
>>directive and let the HLL compiler deal with it.

> Well, in that case, would it be possible to allow ":" as a valid
> character for use in symbol names?

Yep. And probably some other chars used by HLL to mangle names. This
should probably configurable somehow.

> -Joe

leo

Leopold Toetsch

unread,
Sep 8, 2003, 5:27:42 AM9/8/03
to Brent Dax, perl6-i...@perl.org
Brent Dax <br...@brentdax.com> wrote:
> Leopold Toetsch:
> # I'm not outerly sure, if imcc should even have such a functionality.
> Or
> # at least, if there is one, it should be configurable. The name
> mangling
> # is HLL dependent and there may be no general scheme to do it right for
> # all kind of symbols.

> Then allow a few more symbols in identifiers, and turn namespace into a
> prefixing thing that applies to all identifiers:

> .namespace Foo::
> .sub bar #really Foo::bar

What about lexical names? Scopes? I think all IDs that should be
mangled would need some kind of hint, that they are really subject of
mangling.

.namespace 1 "Foo::"
.namespace 2 "_Foo::"
.mangle sub 1
.mangle global 2
.sub bar # Foo::bar
.global a # _Foo::a
# how to generate @Foo::a and $Foo::a?

If the HLL is integrated we could use callbacks to deal with that mess.

leo

0 new messages