Re: Reviewing named and optional parameters
Marc Feeley 09 Jun 2021 10:24 UTC
> On Jun 9, 2021, at 5:42 AM, Daphne Preston-Kendal <xxxxxx@nonceword.org> wrote:
>
>>
>> If we get rich enough syntactic abstractions, I already wondered (in the context of SRFI 177) whether there is really a need for first-class procedures that take keyword arguments or whether they should all become special forms (with absolutely no runtime overhead). After all, an unknown procedure (a procedure passed around as a first-class value) would very seldom be called with keyword arguments.
>
> I considered the possibility of making everything a macro, but I decided losing first-class status of procedures was too high a price to pay, on principle if nothing else. True, it's unlikely (though not impossible) that an arbitrary higher-order procedure (as in map, fold and their respective first arguments) will use keyword arguments, but I can imagine not-so-contrived situations where it would still be useful to pass them around.
I too can imagine situations where having keyword arguments only on macros would be restrictive:
1) In an object oriented programming style where you call a virtual method through generic call. The generic call site specifies keyword arguments and there is a dispatch to the actual procedure that does the work that consumes the keyword arguments.
2) In higher order procedures whose procedure parameter accepts keyword arguments. Syntax isn’t a first-class object that can be passed around.
3) In a FFI between Scheme and a foreign language that supports keyword arguments (Python, Ruby, Common Lisp, Ada, C#, Fortran, R, PHP, Scala, Smalltalk, etc).
Marc