flat assembler
Message board for the users of flat assembler.

Index > Main > [fasmg] dot notation use cases...

Author
Thread Post new topic Reply to topic
com2434



Joined: 11 Oct 2017
Posts: 1
com2434 11 Oct 2017, 16:34
Can anybody describe dot notation use cases in fasmg with exact description?
Post 11 Oct 2017, 16:34
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 11 Oct 2017, 17:32
I don't know if you'd prefer just the basic use cases or even an exotic ones. I'll try to start with just a simple ones.

The basic idea is simple - a dot means that the symbol that follows is in the namespace of the "parent" symbol that preceded the dot:
Code:
A = 'A'
A.a = 'A.a'
A.a.a = 'A.a.a'

namespace A
        display a, 13,10                ; A.a
        display a.a , 13,10             ; A.a.a
        namespace a
                display a, 13,10        ; A.a.a
                display A, 13,10        ; A
        end namespace
end namespace    
With NAMESPACE directive we can "enter" any given namespace and this changes the scope. Symbol that was defined as "A.a" outside, inside the "A" namespace can be accessed with just "a". Note that symbols from the outer namespaces can still be accessed simply by name, as long as there is no local symbol that would "overshadow" the global one:
Code:
B = 'B'
B.B = 'B.B'
B.B.b = 'B.B.b'

namespace B
        display B, 13,10                ; B.B
        namespace B
                display B, 13,10        ; B.B (because there is no B.B.B)
                display b, 13,10        ; B.B.b
        end namespace
end namespace    

When a symbol starts with a dot, it lies in the namespace of a label in the current namespace that was the most recently defined:
Code:
C:
.a = 'C.a'

namespace C
        display a, 13,10                ; C.a
end namespace

D:
D.a:
.b = 'D.b'

display D.b, 13,10                      ; D.b    
Note that the label "D.a" is a symbol named "a" in the "D" namespace. Therefore it does not change what label is the most recent one in the current (outermost) namespace, it is still "D".
Post 11 Oct 2017, 17:32
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.