unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* edebug and defun* &key
@ 2011-01-07 14:32 Le Wang
  2011-01-07 14:44 ` Tassilo Horn
       [not found] ` <mailman.6.1294411469.3795.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Le Wang @ 2011-01-07 14:32 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

Hi all,

I really like the clarity of defun* forms when specifying optional
parameters.  However, edebug doesn't seem to be able to unserstand these
forms very well.  Has anyone got a workaround?

e.g.

(defun* foo (&optional &key (arg t)))

<M-x>edebug-defun

-- 
Le

[-- Attachment #2: Type: text/html, Size: 407 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: edebug and defun* &key
  2011-01-07 14:32 edebug and defun* &key Le Wang
@ 2011-01-07 14:44 ` Tassilo Horn
  2011-01-07 18:54   ` Le Wang
       [not found] ` <mailman.6.1294411469.3795.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Tassilo Horn @ 2011-01-07 14:44 UTC (permalink / raw)
  To: help-gnu-emacs

Le Wang <l26wang@gmail.com> writes:

Hi!

> I really like the clarity of defun* forms when specifying optional
> parameters.
>
> (defun* foo (&optional &key (arg t)))

I don't know about edebug and defun*, but for optional parameters, you
don't need defun*.

  (defun foo (&optional baz bla))

is perfectly valid standard elisp.  For &key, you need defun*.  But
keyword parameters are optional anyway, so your above definition should
read like

  (defun* foo (&key (arg t)))

Bye,
Tassilo




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: edebug and defun* &key
  2011-01-07 14:44 ` Tassilo Horn
@ 2011-01-07 18:54   ` Le Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Le Wang @ 2011-01-07 18:54 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

On Fri, Jan 7, 2011 at 10:44 PM, Tassilo Horn <tassilo@member.fsf.org>wrote:

>  (defun foo (&optional baz bla))
>

I'm no lisp expert but something like (foo-func nil nil t nil) is just so
much less clean than (foo-func :truncate-blanks nil).


> is perfectly valid standard elisp.  For &key, you need defun*.  But
> keyword parameters are optional anyway, so your above definition should
> read like
>



>  (defun* foo (&key (arg t)))
>

Bingo.  That fixed it.  Thanks.

-- 
Le

[-- Attachment #2: Type: text/html, Size: 1065 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: edebug and defun* &key
       [not found] <mailman.5.1294410734.3795.help-gnu-emacs@gnu.org>
@ 2011-01-07 22:58 ` Tim X
  2011-01-07 23:04   ` Tim X
  0 siblings, 1 reply; 6+ messages in thread
From: Tim X @ 2011-01-07 22:58 UTC (permalink / raw)
  To: help-gnu-emacs

Le Wang <l26wang@gmail.com> writes:

> Hi all,
>
>
> I really like the clarity of defun* forms when specifying optional parameters.
>  However, edebug doesn't seem to be able to unserstand these forms very well.
>  Has anyone got a workaround?
>
> e.g.
>
> (defun* foo (&optional &key (arg t)))
>
> <M-x>edebug-defun

The defun* is a CL compatibility macro and not a part of standard elisp.
i.e. you have to load the 'cl package to get it. 

Elisp can handle the &optional and &key parameter types in normal defun.
IIRC the only real difference is that elisp cannot set default values
for optional parameters - they are nil if not supplied and thats it. 

When you say edebug does not understand these forms very well, what do
you mean?

Tim

-- 
tcross (at) rapttech dot com dot au


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: edebug and defun* &key
  2011-01-07 22:58 ` Tim X
@ 2011-01-07 23:04   ` Tim X
  0 siblings, 0 replies; 6+ messages in thread
From: Tim X @ 2011-01-07 23:04 UTC (permalink / raw)
  To: help-gnu-emacs

Tim X <timx@nospam.dev.null> writes:

> Le Wang <l26wang@gmail.com> writes:
>
>> Hi all,
>>
>>
>> I really like the clarity of defun* forms when specifying optional parameters.
>>  However, edebug doesn't seem to be able to unserstand these forms very well.
>>  Has anyone got a workaround?
>>
>> e.g.
>>
>> (defun* foo (&optional &key (arg t)))
>>
>> <M-x>edebug-defun
>
> The defun* is a CL compatibility macro and not a part of standard elisp.
> i.e. you have to load the 'cl package to get it. 
>
> Elisp can handle the &optional and &key parameter types in normal defun.
> IIRC the only real difference is that elisp cannot set default values
> for optional parameters - they are nil if not supplied and thats it. 
>
> When you say edebug does not understand these forms very well, what do
> you mean?
>
> Tim

Correcting myself - elisp doesn't have &key - a mistake I make all the
time because I'm often moving between elisp and cl and constantly get
some of this mixed up. Sorry for any confusion I caused.

Tim

-- 
tcross (at) rapttech dot com dot au


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: edebug and defun* &key
       [not found] ` <mailman.6.1294411469.3795.help-gnu-emacs@gnu.org>
@ 2011-01-08 19:25   ` Raffaele Ricciardi
  0 siblings, 0 replies; 6+ messages in thread
From: Raffaele Ricciardi @ 2011-01-08 19:25 UTC (permalink / raw)
  To: help-gnu-emacs

On Jan 7, 3:44 pm, Tassilo Horn <tass...@member.fsf.org> wrote:
> Le Wang <l26w...@gmail.com> writes:
>
> Hi!
>
> > I really like the clarity of defun* forms when specifying optional
> > parameters.
>
> > (defun* foo (&optional &key (arg t)))
>
> I don't know about edebug and defun*, but for optional parameters, you
> don't need defun*.
>
>   (defun foo (&optional baz bla))
>
> is perfectly valid standard elisp.  For &key, you need defun*.  But
> keyword parameters are optional anyway, so your above definition should
> read like
>
>   (defun* foo (&key (arg t)))
>
> Bye,
> Tassilo

Moreover, you shouldn't be mixing &optional and &key:

http://gigamonkeys.com/book/functions.html

Read paragraph "Mixing Different Parameter Types".



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-08 19:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-07 14:32 edebug and defun* &key Le Wang
2011-01-07 14:44 ` Tassilo Horn
2011-01-07 18:54   ` Le Wang
     [not found] ` <mailman.6.1294411469.3795.help-gnu-emacs@gnu.org>
2011-01-08 19:25   ` Raffaele Ricciardi
     [not found] <mailman.5.1294410734.3795.help-gnu-emacs@gnu.org>
2011-01-07 22:58 ` Tim X
2011-01-07 23:04   ` Tim X

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).