[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `defun' doesn't complain when arglist is missing.
From: |
Pascal J. Bourguignon |
Subject: |
Re: `defun' doesn't complain when arglist is missing. |
Date: |
Thu, 24 Oct 2013 23:23:17 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:
> Alex Bennée <kernel-hacker@bennee.com> writes:
>> You can happily C-x C-e eval-last-sexp both of those defuns without
>> complaint. The error in the defun only shows up when you try and execute
>> them.
>
> I was caught by this a few times. Wouldn't it make sense to add
>
> (unless (and (listp arglist)
> (null (delq t (mapcar #'symbolp arglist))))
> (error "Malformed arglist: %s" arglist))
>
> near the beginning of "defun" in byte-run.el ? Or am I being naive
> again ?
>
>
> I guess it's not there for a reason, but what is it ?
(require 'cl)
(unless (and (listp arglist) (every (lambda (arg) (and arg (symbolp arg)))
arglist))
(error "Malformed arglist: %s" arglist))
or if you insist on not using cl,
(dolist (arg (if (listp arglist) arglist '("")))
(unless (and arg (symbolp arg))
(error "Malformed arglist: %s" arglist)))
--
__Pascal Bourguignon__
http://www.informatimago.com/