4 ms·
Is there a tutorial on how the variable scoping works in this language? I have never understood how scoping works in Rebol-likes; as far as I can tell, it is si
by HexDecOctBin 2y ago
Is there a tutorial on how the variable scoping works in this language? I have never understood how scoping works in Rebol-likes; as far as I can tell, it is similar to a closure passed in form of an f-expr, but I'm not sure on the details.
- middayc 2y agoRebol has something named definitional scoping. Interesting document about that was called "bindology" (If I remember correctly). We don't have a tutorial about this. In Rye this is still partially open to experimentation. If in Rebol dialects were the most interesting part. Rye also has multiple dialects, but I think in Rye contexts (scopes) are the most interesting aspect of the language. In very short. Code is always evaluated inside a specific context. This also determines what certain words mean (from "core" words, like if, for, fn, ... up). Contexts can be linked together (you can define a parent context), created, manipulated, isolated at runtime. We have functions like do\in do\par(ent) and also fn\in and fn\par that evaluate code in context you provide. Lookup for a word happens in current context and then if not found in it's parent contexts if there are any. This is lookup ... "read" operation, but you can change (set or mod) only words in a current context. There is no syntax to change a value in parent or sub-context (there is no global context). You can call functions in (send messages to) contexts in your view and convention is if functions change values in-place their name must end with !. That is current idea in very short, but this is all still open to be tested in practice and potentially changed.
- draegtun 2y agoHopefully these two links will help: - Definitional Scoping / Rebol actually does not have scoping at all - https://stackoverflow.com/q/21964110/12195 https://stackoverflow.com/q/21964110/12195 - Bindology - https://en.wikibooks.org/wiki/Rebol_Programming/Advanced/Bindology https://en.wikibooks.org/wiki/Rebol_Programming/Advanced/Bin...
- middayc 2y agoUh ... BrianH and Ladislav ... two of the real Rebol magicians. I can't wait to read the second again, and the first for the first time!