flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Main > [fasmg] dot notation use cases...

Author
Thread Post new topic Reply to topic
com2434



Joined: 11 Oct 2017
Posts: 1
[fasmg] dot notation use cases...
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
Assembly Artist


Joined: 16 Jun 2003
Posts: 6633
Location: Kraków, Poland
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 a13,10                ; A.a
        display a.a , 13,10             ; A.a.a
        namespace a
                display a13,10        ; A.a.a
                display A13,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 B13,10                ; B.B
        namespace B
                display B13,10        ; B.B (because there is no B.B.B)
                display b13,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 a13,10                ; C.a
end namespace

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

display D.b13,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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.