From: ·············@gmail.com
Subject: &allow-other-keys forces me to use dummy keyword ...
Date: 
Message-ID: <e2bba1cf-e8f3-4e43-bc60-db6bf69e1918@n75g2000hsh.googlegroups.com>
or does it ?

Hi,

I have a spline-drawing defun which accepts many keywords:

(defun spline (points-list &key
	       (type *spline-type*)
	       (line-style *line-style*)
	       (thickness *thickness*)
	       (pen-color *pen-color*)
	       (fill-color *fill-color*)
	       (depth *depth*)
	 ...

I have a wrapper routine, that by itself does not need any keywords,
but I would like to pass keywords to spline.  The only way I managed
to do it included a use of a dummy keyword:

(defun roi (points &rest spline-kwrds &key dummy &allow-other-keys)
  "Defines a region of interest"
  (identity dummy)
  (apply #'spline
   (loop for point in points  ;; this part has to do with adapting the
roi argument to the spline argument
      collecting (append point '(1.0)))
   :type (getf *spline-types* :closed-approximated-spline)
   :allow-other-keys t spline-kwrds))

If I don't include "&key dummy" in the argument list, I get an error.
(this is on SBCL).  I really don't mind having to do it.  I am just
curious if I am missing something.  Oh, silly me.  I must be.  The
question should be: what am I missing?

Thank you,

Mirko

PS. um, sorry, but I seem to be hooked on loops these days -- I
promise to try harder in the near future to wean myself of them :-)
(If you don't know what I am talking about, just ignore).

From: Marco Antoniotti
Subject: Re: &allow-other-keys forces me to use dummy keyword ...
Date: 
Message-ID: <bb68c728-b5c8-451d-8d01-9ce512cf8432@e23g2000prf.googlegroups.com>
On Mar 25, 9:23 pm, ·············@gmail.com wrote:
> or does it ?
>
> Hi,
>
> I have a spline-drawing defun which accepts many keywords:
>
> (defun spline (points-list &key
>                (type *spline-type*)
>                (line-style *line-style*)
>                (thickness *thickness*)
>                (pen-color *pen-color*)
>                (fill-color *fill-color*)
>                (depth *depth*)
>          ...
>
> I have a wrapper routine, that by itself does not need any keywords,
> but I would like to pass keywords to spline.  The only way I managed
> to do it included a use of a dummy keyword:
>
> (defun roi (points &rest spline-kwrds &key dummy &allow-other-keys)
>   "Defines a region of interest"
>   (identity dummy)
>   (apply #'spline
>    (loop for point in points  ;; this part has to do with adapting the
> roi argument to the spline argument
>       collecting (append point '(1.0)))
>    :type (getf *spline-types* :closed-approximated-spline)
>    :allow-other-keys t spline-kwrds))
>
> If I don't include "&key dummy" in the argument list, I get an error.
> (this is on SBCL).  I really don't mind having to do it.  I am just
> curious if I am missing something.  Oh, silly me.  I must be.  The
> question should be: what am I missing?
>

You should be able to write

(defun roi (points &rest spline-kwrds &key &allow-other-keys) ...)


Marco
From: Thomas A. Russ
Subject: Re: &allow-other-keys forces me to use dummy keyword ...
Date: 
Message-ID: <ymilk46o0fz.fsf@blackcat.isi.edu>
Marco Antoniotti <·······@gmail.com> writes:

> On Mar 25, 9:23��pm, ·············@gmail.com wrote:
> > or does it ?
> >
> > Hi,
> >

> > I have a wrapper routine, that by itself does not need any keywords,
> > but I would like to pass keywords to spline. �The only way I managed
> > to do it included a use of a dummy keyword:
> >
> > (defun roi (points &rest spline-kwrds &key dummy &allow-other-keys)
> > � "Defines a region of interest"
> > � (identity dummy)
> > � (apply #'spline
> > � �(loop for point in points �;; this part has to do with adapting the
> > roi argument to the spline argument
> > � � � collecting (append point '(1.0)))
> > � �:type (getf *spline-types* :closed-approximated-spline)
> > � �:allow-other-keys t spline-kwrds))
> >
> > If I don't include "&key dummy" in the argument list, I get an error.
> > (this is on SBCL). �I really don't mind having to do it. �I am just
> > curious if I am missing something. �Oh, silly me. �I must be. �The
> > question should be: what am I missing?
> >
> 
> You should be able to write
> 
> (defun roi (points &rest spline-kwrds &key &allow-other-keys) ...)

Or even simpler:

  (defun roi (points &rest spline-kwrds) ...)

since if you don't care about keyword processing in the body and you are
allowing all keywords, you might as well just use a &rest parameter.  I
guess the one thing you lose is potential compiler detection of an
odd-length keyword argument list, but otherwise it should work fine.



-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Marco Antoniotti
Subject: Re: &allow-other-keys forces me to use dummy keyword ...
Date: 
Message-ID: <3d724496-d26d-4411-8b9a-6b09a4a7a478@d62g2000hsf.googlegroups.com>
On Mar 26, 1:20 am, ····@sevak.isi.edu (Thomas A. Russ) wrote:
> Marco Antoniotti <·······@gmail.com> writes:
> > On Mar 25, 9:23Ž pm, ·············@gmail.com wrote:
> > > or does it ?
>
> > > Hi,
>
> > > I have a wrapper routine, that by itself does not need any keywords,
> > > but I would like to pass keywords to spline.  The only way I managed
> > > to do it included a use of a dummy keyword:
>
> > > (defun roi (points &rest spline-kwrds &key dummy &allow-other-keys)
> > >   "Defines a region of interest"
> > >   (identity dummy)
> > >   (apply #'spline
> > >    (loop for point in points  ;; this part has to do with adapting the
> > > roi argument to the spline argument
> > >       collecting (append point '(1.0)))
> > >    :type (getf *spline-types* :closed-approximated-spline)
> > >    :allow-other-keys t spline-kwrds))
>
> > > If I don't include "&key dummy" in the argument list, I get an error.
> > > (this is on SBCL).  I really don't mind having to do it.  I am just
> > > curious if I am missing something.  Oh, silly me.  I must be.  The
> > > question should be: what am I missing?
>
> > You should be able to write
>
> > (defun roi (points &rest spline-kwrds &key &allow-other-keys) ...)
>
> Or even simpler:
>
>   (defun roi (points &rest spline-kwrds) ...)
>
> since if you don't care about keyword processing in the body and you are
> allowing all keywords, you might as well just use a &rest parameter.  I
> guess the one thing you lose is potential compiler detection of an
> odd-length keyword argument list, but otherwise it should work fine.
>
> --
> Thomas A. Russ,  USC/Information Sciences Institute

Duh!  Of course....

Marco
From: Edi Weitz
Subject: Re: &allow-other-keys forces me to use dummy keyword ...
Date: 
Message-ID: <u63va8uqd.fsf@agharta.de>
On Tue, 25 Mar 2008 12:23:14 -0700 (PDT), ·············@gmail.com wrote:

> or does it ?

  (defun foo (&key &allow-other-keys)
    nil)

  http://www.lispworks.com/documentation/HyperSpec/Body/03_da.htm

Edi.

-- 

European Common Lisp Meeting, Amsterdam, April 19/20, 2008

  http://weitz.de/eclm2008/

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: ·············@gmail.com
Subject: Re: &allow-other-keys forces me to use dummy keyword ...
Date: 
Message-ID: <76608849-9416-4799-994d-91ffa4ff18d3@m3g2000hsc.googlegroups.com>
On Mar 25, 3:32 pm, Edi Weitz <········@agharta.de> wrote:
> On Tue, 25 Mar 2008 12:23:14 -0700 (PDT), ·············@gmail.com wrote:
> > or does it ?
>
>   (defun foo (&key &allow-other-keys)
>     nil)
>
>  http://www.lispworks.com/documentation/HyperSpec/Body/03_da.htm
>
> Edi.
>
> --
>
> European Common Lisp Meeting, Amsterdam, April 19/20, 2008
>
>  http://weitz.de/eclm2008/
>
> Real email: (replace (subseq ·········@agharta.de" 5) "edi")


Thank you (and to Marco).  That works.
From: Peder O. Klingenberg
Subject: Re: &allow-other-keys forces me to use dummy keyword ...
Date: 
Message-ID: <ksd4pio7pq.fsf@beto.netfonds.no>
·············@gmail.com writes:

> (defun roi (points &rest spline-kwrds &key dummy &allow-other-keys)
>   "Defines a region of interest"
>   (identity dummy)
>   (apply #'spline
>    (loop for point in points  ;; this part has to do with adapting the
> roi argument to the spline argument
>       collecting (append point '(1.0)))
>    :type (getf *spline-types* :closed-approximated-spline)
>    :allow-other-keys t spline-kwrds))
>
> If I don't include "&key dummy" in the argument list, I get an error.
> (this is on SBCL).  I really don't mind having to do it.  I am just
> curious if I am missing something.  Oh, silly me.  I must be.  The
> question should be: what am I missing?

I see you have gotten good answers already.  Mine is more of a
followup question, directes as much to those who replied as to you.
But since you already collect the lot into a &rest list, what's the
point of specifying &key &allow-other-keys at all?

What's wrong with simply

(defun roi (points &rest spline-kwrds)
  (apply #'spline (massage points) ... spline-kwrds))

?

Maybe, with an odd number of elements in the spline-kwrds list, you'd
get an error message earlier if you use &key &allow-other-keys, but
are there other benefits that I'm missing?

...Peder...
-- 
I wish a new life awaited _me_ in some off-world colony.
From: ·············@gmail.com
Subject: Re: &allow-other-keys forces me to use dummy keyword ...
Date: 
Message-ID: <05e854d2-cf70-4a2b-ae69-8022c3e8290f@b1g2000hsg.googlegroups.com>
On Mar 25, 4:43 pm, ·····@news.klingenberg.no (Peder O. Klingenberg)
wrote:
> ·············@gmail.com writes:
> > (defun roi (points &rest spline-kwrds &key dummy &allow-other-keys)
> >   "Defines a region of interest"
> >   (identity dummy)
> >   (apply #'spline
> >    (loop for point in points  ;; this part has to do with adapting the
> > roi argument to the spline argument
> >       collecting (append point '(1.0)))
> >    :type (getf *spline-types* :closed-approximated-spline)
> >    :allow-other-keys t spline-kwrds))
>
> > If I don't include "&key dummy" in the argument list, I get an error.
> > (this is on SBCL).  I really don't mind having to do it.  I am just
> > curious if I am missing something.  Oh, silly me.  I must be.  The
> > question should be: what am I missing?
>
> I see you have gotten good answers already.  Mine is more of a
> followup question, directes as much to those who replied as to you.
> But since you already collect the lot into a &rest list, what's the
> point of specifying &key &allow-other-keys at all?
>
> What's wrong with simply
>
> (defun roi (points &rest spline-kwrds)
>   (apply #'spline (massage points) ... spline-kwrds))
>
> ?
>
> Maybe, with an odd number of elements in the spline-kwrds list, you'd
> get an error message earlier if you use &key &allow-other-keys, but
> are there other benefits that I'm missing?
>
> ...Peder...
> --
> I wish a new life awaited _me_ in some off-world colony.

I think Thomas replied to that already.  I'm still too wobbly on my
skates to answer that.  I'll give it a shot.

Thanks,

Mirko