emacs-devel
[Top][All Lists]
Advanced

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

Re: "(setq name)": Is this a bug?


From: Ian Eure
Subject: Re: "(setq name)": Is this a bug?
Date: Tue, 14 Jul 2009 09:47:20 -0700

On Jul 14, 2009, at 9:01 AM, Alan Mackenzie wrote:

Hi, Emacs,

In .../lisp/files.el, function set-auto-mode, L2553, appears the strange
invocation:

   (setq name)

.  One of my analysis tools tripped up on it.  According to setq's doc
string, this is invalid. In each [SYM VAL] in (setq [SYM VAL] ...), the
VAL is not optional.  Surely?

I suspect the documentation just isn't clear. From a brief reading of the source, setq supports 0/1/odd arguments, with `nil' being used in the case of non-mod-two argument arity.

In a nutshell, it loops over the arguments two at a time until they're empty, setting the car of the args_left to the evaluated cadr of args_left. If you're at the end of a list, the cdr is `nil', and the car of `nil' is also `nil'.

So if you give it an odd number of arguments, the last value will be nil.

 - Ian




reply via email to

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