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