Re: Keyword arguments...

Subject: Re: Keyword arguments...
From: Brandon Ibach <bibach@xxxxxxxxxxxxxx>
Date: Thu, 6 Aug 1998 10:59:33 -0500 (CDT)
Norman Walsh said:
> Is it the case, as it appears to be, that in user-defined
> functions with keyword arguments, the keyword arguments must
> always appear last?
> I'd like to define a function, "make-element", so that it could
> be used just like the sgml backend's "make element" function.
>   (make-element gi: "foo" attributes: '() some-sosofo)
> But it seems I'm stuck with either
>   (make-element some-sosofo gi: "foo" attributes: '())
> or 
>   (make-element gi: "foo" attributes: '() sosofo: some-sosofo)
> Is that the case, or am I overlooking something?
   There is a very specific order to how actual arguments are assigned
to formal arguments.  I believe it's covered in the DSSSL spec in the
section on lambda.  I don't have the spec here, but as I recall,
regular formal arguments are *always* assigned first, then keywords,
then optionals (the order of those last two may be reversed... not
sure), then anything that's left gets assigned to the rest arguemnt.
So, I expect the definition for make would be something like
     (define make (lambda class #!key gi attributes #!rest soso) ...)
   Pardon my sloppy syntax if I didn't do that quite right, but you
get the idea.  Any arguments you want to list *after* keyword
assignments would have to be lumped into the "rest" and pulled back
out by the function.
   But, then, I could be wrong... :)

-Brandon :)

 DSSSList info and archive:

Current Thread
  • Keyword arguments...
    • Norman Walsh - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id KAA18411Thu, 6 Aug 1998 10:45:24 -0400 (EDT)
      • Alexander Taranov - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id LAA19001Thu, 6 Aug 1998 11:00:23 -0400 (EDT)
      • Paul Prescod - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id LAA21125Thu, 6 Aug 1998 11:58:55 -0400 (EDT)
      • Brandon Ibach - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id LAA21156Thu, 6 Aug 1998 11:59:10 -0400 (EDT) <=
      • James Clark - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id MAA21957Thu, 6 Aug 1998 12:13:10 -0400 (EDT)
        • Norman Walsh - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id MAA22678Thu, 6 Aug 1998 12:27:48 -0400 (EDT)