Hi bard !

I seems to me this issue has to do with dynamic vs lexical scope (for variables). Dynamic scope lets you use any variable you want (even if its not an argument) in any function, as long as it has been defined at some previous context, while lexical scope requires you to declare more excplicitly what is the scope of your variables. I think Common lisp is lexically scoped (while Emacs lisp is dynamically scoped, thus lets you do things like you said). Lexical scope lets you create closures, like
(defun generate_incrementor (n)
(return #’(lambda (x) (+ x n))))

while with dynamic scope that doesn't work (unles there's a dynamic binding for 'n' at the time the generator is invoked.

I would think dynamic binding is more of an issue in multi-threaded environments, althought I dont know the matter very much. But for shure, these 'global variables' suck some of the magic in functional programming.
Anyway, the erlang process dictionary is per-process, so that shouldn't be an issue.

you can always pass a 'hash' with the remaining arguments, (but that way we may well end passing algways just a 'hash'' of arguments to every function we create, but isn't it what ruby does with named arguments ?). anyway, the question is who should be aware of what are the names of the arguments, and what are their types ?

maybe we could create a new language where there's always a final argument which is a hash, that comes passed from upper contexts, with 'uninteresting arguments from lower functions' then every function would declare which arguments it's interested in and they would be unpacked from this hash, this way, down the road, only the interested function would get these variables and they would still come as an argument.... but this brings me to the question: isn't the global scope some kind of universal hash-table for arguments ? hmmm I think I didn't solve the problem. :P

best regards !!

elias

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor and to prevent automated spam submissions.