Re: Reviewing named and optional parameters
Daphne Preston-Kendal 09 Jun 2021 09:00 UTC
On 8 Jun 2021, at 07:38, Per Bothner <xxxxxx@bothner.com> wrote:
> One correction (in section "Keyword arguments to procedures"):
>
> In Racket, a special form ... is needed to call procedures with keyword arguments with dynamic argument lists;
> in Kawa, this does not appear to be possible at all.
>
> Kawa has "arguments list" as a distinct type that generalizes list.
> See http://www.gnu.org/software/kawa/Application-and-Arguments-Lists.html
> and especially the "Explicit argument list objects" subsection.
>
> The "splice" syntax forms @EXPRESSION and @:EXPRESSION (earlier on the same page)
> combined with the argvector/arglist types provide powerful tools to build dynamic argument lists.
Could you give an example of how I can use this to call apply using a quoted keyword object (or by extension a keyword object I might have lying around in a variable for example)? No matter what I try, I keep getting gnu.mapping.WrongArguments. (Kawa 3.1.1.)
(define (f #!key k) k)
None of these work:
(apply f (arglist 'k: 1))
(apply f (arglist @:(arglist 'k: 1)))
(apply f (arglist @:(list 'k: 1)))
or the same with @ or argvector instead of arglist.
> --
> --Per Bothner
> xxxxxx@bothner.com http://per.bothner.com/
Daphne