.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
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
Well, in that case, would it be possible to allow ":" as a valid
character for use in symbol names?
-Joe
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."
>>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
> 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