flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bitRAKE 10 Sep 2021, 15:33
This confused me for a great while (maybe still). I would write little tests to wrap my head around it. Namespace, in many ways, is not like namespace of other languages.
Code: banana equ namespace TacoLand ; change parent context banana. reequ 'banana0' ; existing local context overrides setting parent ; the symbol is shadowed define banana banana. reequ 'taco0' ; can't reach parent context once local context exists ; or if parent context doesn't exist (obviously) grape equ banana. define banana 'taco1' end namespace display 10,banana display 10,9,TacoLand.grape display 10,9,TacoLand.banana ; non-dot symbols search in the present namespace PizzaLand: define .banana 'pizza0' banana reequ 'banana1' ; can access both non-/dot banana .grape equ .banana define .banana 'pizza1' display 10,banana display 10,9,PizzaLand.grape display 10,9,PizzaLand.banana namespace NoodleLand ; get parent value broth: .grape equ banana. ; save real banana! ; change parent context banana. reequ 'banana2' define banana banana. reequ 'noodle0' grape equ broth.grape define banana 'noodle1' end namespace display 10,banana display 10,9,NoodleLand.grape display 10,9,NoodleLand.banana Presently, my use of namespace is to assign local symbols as needed - collapsing the hierarchy. I haven't tried maintaining a symbolic tree, yet. I did run some tests also to transport symbols from one namespace to another using calminstruction's transform. With no success unfortunately. Is resolving the second parameter to transform possible - must it always be a literal value and not a value defined by a parameter/symbol? |
|||
![]() |
|
bitRAKE 10 Sep 2021, 16:17
Here is another perspective:
Code: ; GreatParent name equ 'Adam' GrandParent: ; colon names create an anchor point in the hierarchy namespace GrandParent father equ name define name name reequ 'George' Parent: namespace Parent father equ name define name name reequ 'Michael' child: ; must use more complex paths at depth ; or unique names (linearize/flatten) .great equ GrandParent.father .grand equ father ; or GrandParent.name or Parent.father or GrandParent.Parent.father .father equ name ; or Parent.name .name equ 'Bobby' display 10,.great,'->',.grand,'->',.father,'->',.name end namespace end namespace |
|||
![]() |
|
sylware 10 Sep 2021, 16:58
Actually, until a symbol of expression class is attached to a namespace, it is not possible to "browse" it depth upward from its children, and sidewise from its siblings (of the same symbol class).
symbols of [labeled] instruction class seems to allow those though. Hope I am not too wrong there ![]() I ended explicitely "importing" the symbols of expression class in a child namespace from the namespaces of the parent/siblings. For "global" namespaces, I do add a symbol of expression class explicitely: Code: myglobalnamespace = 'visible' for instance: Code: libc = 'visible' linux = 'visible' It seems to enforce strong isolation of symbols of expression class in their namespaces: more typing, but provides an explicit inventory of what is 'imported' instead of to have to read the whole code. Code: namespace parent namespace sibling ... end namespace ; sibling label child.parent.symexpcls0 at parent.symexpcls0 label child.sibling.symexpcls1 at sibling.symexpcls1 namespace child ... end namespace ; parent end namespace ; child |
|||
![]() |
|
Melissa 18 Sep 2021, 11:57
namespaces are only needed if you work in teams, not to collide with others symbols or when you make library for same reasons
|
|||
![]() |
|
bitRAKE 18 Sep 2021, 15:39
The new features of fasmg make stuff like ...
Code: include 'ns04.fasmg',namespace Oh_Wow end namespace (If it wasn't written initially with that intention.) |
|||
![]() |
|
Melissa 18 Sep 2021, 21:11
Beautifull I bet future on fasmg.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.