[admin] Project hosting request

jtdubs at ncsu.edu jtdubs at ncsu.edu
Fri Apr 9 14:14:03 UTC 2004


> Justin Dubs <jtdubs at eos.ncsu.edu> writes:
>> I have an ASDF system called cl-lambda-shorthand that I was wondering
>> if you would be interested in hosting.  It was developed by myself,
>> Justin Dubs, and is under the MIT license.
>
> Well - the real question is if you think this merits a project of its
> own :-)

I really don't know if it merits being it's own project.  I find it to be
useful on occasion, and I thought it was possible that others might as
well.  I can host it myself, starting in a few months, if you guys don't
want it.

> Erik, Nikodemus, what do you think?
>
> I sometimes wonder if we should create an "extensions" umbrella
> project for this kind of thing.
>
> In any case, if you think that this merits a project of its own, I do
> not see any major (nor minor) problem.
>
> Now, completely unrelated to that issue:
>
>> Basically, it provides a shorthand for anonymous functions by making
>> use of the #L dispatching macro character.  This way you can say:
>>
>> (mapcar #L(+ 1) '(1 2 3) '(4 5 6))
>> => (6 8 10)
>
> Well. What happens with
>
>   (mapcar #L(- 1) '(1 2 3) '(4 5 6))
>
> or
>
>   (mapcar #L(/ 2) '(1 2 3) '(4 5 6))

If no positional or anonymous arguments are found in the form (I'll
explain what they are in a bit), then a lambda is created which takes a
&rest parameter and #'apply's the function to the rest of the form and the
&rest parameter.

So:

#L(- 1 2 3) => (lambda (&rest #:REST01)
                 (declare (ignore #:REST01))
                 (apply #'- 1 2 3 #:REST01))

(mapcar #L(- 1) '(1 2 3) '(4 5 6)) => (-4 -6 -8)
(mapcar #L(/ 2) '(1 2 3) '(4 5 6)) => (1/2 1/5 1/9)

If you wanted a function to divide something by two, you would use #L(/ _
2)...

>> (mapcar #L(+ _ (* 2 _)) '(1 2 3) '(4 5 6))
>> => (9 12 15)
>
> So the first _ is the first variable, and the second one the second?
> To be honest, this does not seem to me to be such a good idea.

If you saw the rest of the syntax, it might make more sense.  The form
after the #L is checked for anonymous arguments (ie. '_') and postional
arguments (ie. $2, $5 and $10).  You can only use one of the two kinds of
arguments in a given form.

Anonymous arguments become parameters of the generated lambda in
left-to-right order.

Positional arguments become parameters of the generated lambda at offsets
corresponding with their numbers.

So, if you want control over where things end up, you can do this:

#L(- $2 $1) => (lambda (x y) (- y x))
#L(- $3 $1) => (lambda (x unused y) (- y x))
#L(list $1 $1) => (lambda (x) (list x x))

If the form after the #L is an atom, then it generates a constantly function:

#L5 => (lambda (&rest args) 5)
#Lx => (lambda (&rest args) x)

I hope that makes things more clear.  As to whether or not you guys want
to host it and where you want to host it, it doesn't really matter to me
one way or the other.  Let me know what you think the right thing to do
it, and I'll go with it.

Justin Dubs




More information about the Admin mailing list