h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
310 stars 23 forks source link

Accessing ROOT from in operator bodies via parent-scope symbol #149

Closed ghost closed 3 years ago

ghost commented 3 years ago
( symbol test
    (==>)
    (
        scope parent-scope puts!
    )
) ::

test

Result:

{;module}

That module which printed isn't ROOT however it must be ROOT. parent-scope in operator bodies seems doesn't work very well.

ghost commented 3 years ago

Okay, if somebody has same problem like as mine then one just can do:

; ROOT

( symbol test ; Scope-1
    (==>)
    ( ; Scope-2
        scope parent-scope parent-scope puts!
    )
) ::

test

I understood why did i get the wrong module. I'll hope you understand too:

The body is two scope away from ROOT . So one more parent-scope is needed to access ROOT.