help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: when should a variable to quoted?


From: Pascal J. Bourguignon
Subject: Re: when should a variable to quoted?
Date: Sat, 13 Sep 2008 14:29:13 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux)

sunway <sunwayforever@gmail.com> writes:

> "elisp lacks of lexical variable", if this happens to the C
> programming language:
> int a=10;
> foo(a);
> may be "a" will be changed to 9 ?
>
> if so, I really hate this feature....

1- not in C, but in C++ you can have:
   void foo(int& v){ v=0; }
   void f(){
      int a=10;
      foo(a);
      assert(a==0);
   }

2- even in C, soon enough you have types such as it is possible. eg.
   typedef struct node { int item, struct node* next; } *Node_type;
   void f(void){
       Node_type a=make_node(10);
       foo(a);
       assert(a->item==0);
   }


elisp lack of lexical variables implies only that for all variable,
the symbol naming that variable holds its value and can be used as a
"pointer".  With lexical variables, once compiled there remains no
link between the symbol naming a variable and the variable.  On the
other hand, in these lisp we have real closures, so we can build a
"pointer" also named "locative" with closures.
   
-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

PUBLIC NOTICE AS REQUIRED BY LAW: Any use of this product, in any
manner whatsoever, will increase the amount of disorder in the
universe. Although no liability is implied herein, the consumer is
warned that this process will ultimately lead to the heat death of
the universe.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]