nsensfel / tonkadur

Narrative scripting/programming tool. Write stories in your favorite editor using a feature-rich language, compile them into a very small and simple language to easily integrate them into your game.
https://tonkadur.of.tacticians.online
Apache License 2.0
3 stars 0 forks source link

Local Variable Troubles #8

Closed nsensfel closed 4 years ago

nsensfel commented 4 years ago
(global int my_var)
(local int my_var)

The result is amusing: the main context only sees the local variable, all other contexts see the global one. This warrants a warning.


While not allowing access to local variables of a different context still sounds like a good idea, there is the issue of scope within the instruction hierarchy:

(if_else (var my_test)
   (
      (local int my_var)
      ;; my_var is defined
      ;; my_other_var is likely not defined
   )
   (
      (local int my_other_var)
      ;; my_other_var is defined
      ;; I think my_var is also defined.
   )
)
;; both my_var and my_other_var are likely defined.

This is very counter-intuitive. Thus, the usual "access only own and parent's local variables" restrictions should apply within the instruction hierarchy.


There are no local variables in computations, but a (let ((type name computation) ... ) computation) construct would be useful.

nsensfel commented 4 years ago

Done.