I have had some problems figuring out the best way to define functions in KAP. I wrote a post about it. I understand most people will not find this interesting, but there may be a few that does. https://write.as/loke/function-definition-syntax-in-kap
@loke some random thoughts, perhaps they inspire something: in Perl, my $foo is a lexical variable, local $foo is a dynamic variable (elisp dynamic binding), and our $foo is a global binding. So I use ‘our’ whenever my code loads config files that might want to modify said variables. Sounds like a similar case.
@loke perhaps you can use extra symbols to declare a global function instead of having all of the, be global by default. It’s like an “export this” symbol. ∀ probably already has a meaning, but something like:∀ ∇ (arg0;arg1) functionName (arg2;arg3) { ... }
@kensanata Hmm. It's not terrible. It does require the caller to know the behaviour of the thing it calls though, which can be tricky.
The problem is (and this is self-inflicted, I know) that if you assign to a previously unassigned variable, then the assignment is local and will only apply to the current scope.
However, if you assign to a variable which has been assigned in a higher scope, then it will change that variable. In other words, if your included file contains something as simple as foo ← bar, then foo will be local. But if a higher scope has referenced foo before, then it will affect that variable.
@loke hm, is there a way to define a new local variable of the same name? Perhaps you need this to avoid called code in libraries from clobbering your variables?