flat assembler
Message board for the users of flat assembler.
Index
> Main > [fasmg] namespace traversal bug or ? |
Author |
|
Tomasz Grysztar 01 Oct 2021, 21:17
When "c" is not defined, it defaults to symbol in current namespace, so "namespace c" looks up the namespace of "a.b.c" - but when you have "c" symbol defined (with "c:") at another level - in this case as "a.c", you end up switching to it instead. The symbol that gets defined then is "a.c.mydata".
An important thing to note is that NAMESPACE directive does not create the namespace, it just switches temporarily to a namespace that it finds through the provided identifier. You do not nest NAMESPACE blocks to create a similarly nested tree, each of them just switches the base namespace and then switches back. It may help to think of "namespace c"/"end namespace" block as meaning do something in namespace called c, not make a namespace c here. It refers to an existing symbol (though when none is found, it picks one in current namespace, even if undefined). Therefore, if you need to reliably make a tree of nested namespaces, you should ensure to always have them specified through defined symbols, for example: Code: a: namespace a c: rq 1 b: namespace b c: namespace c mydata: rq 1 end namespace end namespace end namespace |
|||
01 Oct 2021, 21:17 |
|
revolution 01 Oct 2021, 22:38
Tomasz Grysztar wrote: Perhaps it would have been less confusing if I named this directive NAMESPACEOF instead of plain NAMESPACE. I could still introduce that as a synonym. |
|||
01 Oct 2021, 22:38 |
|
bitRAKE 02 Oct 2021, 14:03
The brief name for the directive makes sense in light of the overall philosophy used - which is analogous with assembly language programming. Directives tend to do what is sufficient and not too much as to be overly restrictive, imho.
|
|||
02 Oct 2021, 14:03 |
|
sylware 02 Oct 2021, 15:15
@Tomasz okay! My mental picture of fasmg objects is improving. Then if the "in-between" namespaces do not exist, "where" is going the definition then? The identifier is actually "a.b.c.mydata" in the "top" namespace?
@others: usually, it is just a matter of tuning to the manual. |
|||
02 Oct 2021, 15:15 |
|
Tomasz Grysztar 02 Oct 2021, 17:31
sylware wrote: Then if the "in-between" namespaces do not exist, "where" is going the definition then? And - by design - you can refer to symbols only in relative terms, which allows to encapsulate any module in a way that is not apparent from within. When you write something like "a.b.c", it is never absolute, it is anchored at the nearest "a" that is defined and visible to you (and if no "a" is defined anywhere, it is assumed to mean the one in the current namespace, even if it never gets defined). |
|||
02 Oct 2021, 17:31 |
|
sylware 02 Oct 2021, 20:05
I got several times the strong encapsulation feature (I never did expect something else to say the least).
Then, what are the general rules for hierarchical identifiers? For instance "a.b.c.d". I guess it will start from "a" : if no instance of expression class with such symbol in current namespace is found , it will start to walk upward the namespaces until one is found. If one is found, it will then be used as an "anchor" to walk downward the namespaces, but if b does not have any instance of expression class associated with it in namespace a, I'll get an error, right? Because it seems I can walk downward the namespace hierarchy without the need to have an instance of expression class associated with each symbol at each depth. Wrong? |
|||
02 Oct 2021, 20:05 |
|
Tomasz Grysztar 02 Oct 2021, 21:55
sylware wrote: Then, what are the general rules for hierarchical identifiers? For instance "a.b.c.d". I guess it will start from "a" |
|||
02 Oct 2021, 21:55 |
|
sylware 03 Oct 2021, 15:26
Allright!
In the light of this thread, where in the manual those topics are explicited? Because I did read a few times the manual, but it is so dense, I always manage to forget where to look and I end up posting on the message board. |
|||
03 Oct 2021, 15:26 |
|
Tomasz Grysztar 03 Oct 2021, 16:40
Small correction to my previous post: the definition of symbol may still matter for the name after the dot (like "b" in the example) if there is matching case-insensitive symbol defined, but no case-sensitive one. For example:
Code: a.B?: dd a.b.c ; looks for a.B?.c, as it first finds a.B? namespace and then looks for c in there Code: a.b: a.B?: dd a.b.c ; looks for a.b.c, case-sensitive takes precedence sylware wrote: In the light of this thread, where in the manual those topics are explicited? |
|||
03 Oct 2021, 16:40 |
|
sylware 03 Oct 2021, 21:15
I have to admit, I kind of dropped the case sensitive/unsensitive handling support and went full case sensitive.
I am still not decided about dropping the classic macro language to go full calm instructions. I wonder how much dropping the classic macro language (and now the case sensitive/unsensitive handling mechanics) would simplify the fasmg "specs" (implementation internals). |
|||
03 Oct 2021, 21:15 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.