-
Notifications
You must be signed in to change notification settings - Fork 0
Callstack and Scopes
A scope is a part where different data types are valid. This means that the parameters that are specified by the caller of the message (for example by using the getMessage
-method) are not availiable for every single other message and the same name of the parameter could have a different value based on the context.
The scope only changes with the callstack and not inside a message itself. If a message is being called the scope that was accessed before is being passed down and if a term (or a function) is being called only the parameters that are being specified are being passed down.
This means that when the message message
with the parameters of $text = "everything"
and $number = 42
would be called in this file the result would be nothing
:
message = { submessage }
submessage = { -term(number: $number, text: "something") }
-term = { -another-term(text: "nothing") }
-another-term = { last-message }
last-message = { $text }
If you are calling terms and messages you should always check if a message or a term is calling itself somewhere down the callstack as it could mean that it would call itself forever and throw a StackOverflowError
.