unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: when should a variable to quoted?
Date: Sat, 13 Sep 2008 14:29:13 +0200	[thread overview]
Message-ID: <87fxo49qli.fsf@hubble.informatimago.com> (raw)
In-Reply-To: 48f57bb9-232f-4c11-9639-50b071cb06af@b30g2000prf.googlegroups.com

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	other threads:[~2008-09-13 12:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-13  9:11 when should a variable to quoted? sunway
2008-09-13  9:38 ` Pascal J. Bourguignon
2008-09-13 10:21   ` Eli Zaretskii
2008-09-13 11:06   ` sunway
2008-09-13 12:29     ` Pascal J. Bourguignon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fxo49qli.fsf@hubble.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).