emacs-devel
[Top][All Lists]
Advanced

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

Re: Elisp info request: function parameter passing


From: Stefan Monnier
Subject: Re: Elisp info request: function parameter passing
Date: Tue, 09 Dec 2008 14:44:36 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

> I just found elisp is different in function parameter passing than C, or we
> can say elisp is reference passing style. That is, the variable in function

You are confused.

> (setq x '(1 2 3 "one" "two" "three"))
> (defun fun (arg)
>   (if (eq arg x)
>       (message "they are eq, the same one")
>     (message "they are different")))
> (fun x)


Try the equivalent C code:

  char *x = "hello";

  fun (char *arg)
  {
    if (arg == x)
      printf ("they are eq\n");
    else
      printf ("they are different\n");
  }

  main ()
  {
    fun (x);
  }


-- Stefan




reply via email to

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