Re: scope of function definition

Raymond Martin <[email protected]>
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
Ralf,

> Following your reasoning, what's the purpose of defvar then? We don't
> need it and should get rid off it?

Check the Lush documentation for defvar. It says right in there, as well as in other Lisps, that
the purpose of defvar is to create global variables. Therefore, it should work no matter
what environment you use from to set a variable in the toplevel.

> ? (let ((f 2)) (defvar f 1) f)
> = 2
> ? f
> = 1

Your example proves this point. defvar sets f to 1 in the global environment.
Within the let f is assign 2 so that is what is returned.

> I'm not sure what behavior of de/df/dm is better. A disadvantage of
> the current behavior is that it might confuse lisp programmers that
> come newly to lush and expect de to behave like defvar.
> In any case, it should be spelled out in the help texts.

I don't think anyone who knows de (defun in common Lisp) and defvar would confuse 
them at all. defvar just sets aside a place in memory at the toplevel and assigns 
it a value. de are similar in implementation to lexical closures of lambda expressions.
Thus they are very different things and it is hard to see how a variable can be 
confused with a function.

With regard to the help texts, I started to revise some of the language in there
a while ago but haven't had enough time to get past the first few sections. Perhaps
there are things to be changed, but it will have to wait until I have more time 
and any serious technical points need to be given the okay by Yann or Leon first
before they get changed.

Raymond














-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.