Re: Keywords reduced Lassi Kortela 18 Oct 2019 22:24 UTC

> What implementations did you measure this on?  Chez is a very different
> matter from Chibi.

Only on Chez. On Chibi the slowdown is about 10x, except the 1-arg case
about 30x (it probably optimizes 1-arg calls to ordinary procedures).

The benchmark runs 100K calls. Wouldn't you switch to a faster
implementation for jobs like that?

>> Calling with one or two keywords is 2-10x
>> slower, but you have to do like 100K calls per second for it to matter.
>
> What concerns me is if you have 100 keyword args of which only a few are
> usually supplied at any given time, but then someone comes along and
> supplies all or most of them.

Someone comes along and supplies close to 100 keyword arguments in one
call? Benchmark says calling with 100 kw args 100 times takes 1 second
for Chibi. Chez does it in 0.25 seconds. Both with naive plists.

In real code, more than 10 arguments is getting into
<https://thedailywtf.com/> territory. This is starting to look like
intentionally designing the worst possible way to attack a problem, then
iteratively making it worse. We're not yet at remote procedure calls :)

To me, Lisp keyword args have always had a bit of that "ordering fast
food at 2 AM" vibe. A bit dodgy and you know it, but sometimes the most
expedient option. That's why these attempts to turn it into fine art are
still a bit mystifying to me, though there may be a point to it, just
like there are Michelin-starred restaurants that serve burgers.

> You pointed out in another email that keyword-call is rather long-winded,
> and I agree.  How about changing it to something compact like just a
> colon?  I think this is a clear-cut case where such a short identifier is
> justified.  You will have to make sure that systems accept it as a normal
> identifier and not a malformed keyword.

I haven't checked whether or not a single colon is portable. I'd err on
the side of caution since compatibility with any Scheme is so important.

As a separate concern, recall that we need the keyword args in a
separate sublist as in (keyword-call a b (c d)). This is due to
limitations in syntax-rules pattern matching, and also finding some
other "keyword arguments start here" marker would be hard since we don't
have portable keyword read syntax.

(keyword-call a b (c d)) is already about the maximum amount of
weirdness I'd be comfortable imposing on library programmers who are
just wanting to get a job done and get on with other problems. (: a b (c
d)) is quite a bit of magic in one expression. I guess it could be (: a
b : c d) but that's also quite magic, and can syntax-rules handle it?

A simple alternative would be changing the names to kw-lambda and
kw-call. Or klambda and kcall (maybe "k" is too brief?)