Default value of keyword arguments
John Cowan
(03 Nov 2019 02:38 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(03 Nov 2019 10:25 UTC)
|
Re: Default value of keyword arguments
John Cowan
(03 Nov 2019 21:24 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(03 Nov 2019 21:44 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(03 Nov 2019 21:52 UTC)
|
Re: Default value of keyword arguments
John Cowan
(03 Nov 2019 22:30 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(03 Nov 2019 22:40 UTC)
|
Re: Default value of keyword arguments
John Cowan
(03 Nov 2019 23:27 UTC)
|
Re: Default value of keyword arguments
Marc Nieper-Wißkirchen
(03 Mar 2020 10:06 UTC)
|
Re: Default value of keyword arguments Lassi Kortela (03 Mar 2020 11:04 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(03 Mar 2020 11:33 UTC)
|
Re: Default value of keyword arguments
Marc Nieper-Wißkirchen
(03 Mar 2020 12:50 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(03 Mar 2020 13:19 UTC)
|
Re: Default value of keyword arguments
Marc Feeley
(03 Mar 2020 13:40 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(03 Mar 2020 13:53 UTC)
|
Re: Default value of keyword arguments
Marc Nieper-Wißkirchen
(03 Mar 2020 14:34 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(03 Mar 2020 15:00 UTC)
|
Re: Default value of keyword arguments
Marc Nieper-Wißkirchen
(03 Mar 2020 15:11 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(03 Mar 2020 15:27 UTC)
|
Re: Default value of keyword arguments
Marc Nieper-Wißkirchen
(03 Mar 2020 15:51 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(03 Mar 2020 16:06 UTC)
|
Re: Default value of keyword arguments
John Cowan
(03 Mar 2020 23:09 UTC)
|
Re: Default value of keyword arguments
John Cowan
(04 Mar 2020 17:09 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(04 Mar 2020 17:20 UTC)
|
Re: Default value of keyword arguments
Lassi Kortela
(04 Mar 2020 17:33 UTC)
|
Re: Default value of keyword arguments
Marc Nieper-Wißkirchen
(04 Mar 2020 17:59 UTC)
|
> Does this have a resolution yet? > > Why not add to lambda/kw a special form called `(default? <keyword>)' so > that we can write: > > (lambda/kw (file (zip save)) > (let ((save (or (default? save) save))) > ...)) > > The special form `(default? <keyword>)' evaluates to `#t' if the keyword > argument was not given. The keyword argument itself evaluates to `#f' > if not given. My verdict is: The feature is okay, but too advanced for 177. As the author of 177, I'd like to make a decision in this case to omit it from the SRFI. I've used keyword args extensively in Common Lisp, and keyword-like optional arguments extensively in Emacs Lisp, and came to the conclusion after many years that default values other than #f are not useful in practice, cause unnecessary confusion for callers, and add unnecessary code to the keyword-lambda definition. I cannot remember a single instance where a non-nil default would have been more useful than the simplicity afforded by all-nil defaults. You can invert the sense of a boolean flag so that the #f default makes sense. Being able to assume that the default is always #f is a relief on programmers' overworked brains, especially when working with unfamiliar code in a large system. Emacs is a wonderful proving ground in this sense - it's so big that you are constantly using features you don't fully understand. Any reasonable way to make things simpler is good. That being said, your proposal of a (default? ...) primitive is also reasonable, and it should be possible to implement it so it's fully backward-compatible with old keyword systems, which is great. However, the simplicity of 177 is backed by a lot of experience using more complex lambda-list syntax. I'd encourage anyone who wants more features to try using those features in a program that is so large you cannot learn or remember the details of the procedures you are calling. You'll come to appreciate the simplicity of always being able to rely on #f :) Abstraction is about service, and service is about removing unnecessary concerns.