Chris Riesbeck <Chris.Riesbeck@gmail.com> wrote:
+---------------
| danbensen@att.net wrote:
| > Kaz Kylheku <kkylh...@gmail.com> wrote:
| >> You might as well support numbered ones, like _1, _2, ...
| >> Then _ acts like the highest-numbered one, if mixed with the numbered ones.
| >
| > That's an interesting thought. I would use dollar signs for numbered
| > arguments, and I would keep them as a separate alternate syntax. I
| > would first scan the form for an underline, and ignore all other
| > arguments if one or more is found. If there's no _, then I would scan
| > for numbered arguments $1, $2, etc..
|
| For contrast, here's a straight macro version. Every _ is replaced by a
| gensym, every _n is replaced by a previous _ variable (one-based). Any
| other use of _xxx is left alone.
...
| > (mapcan (_ (and (> _ _) (list _1))) '(3 5 7) '(1 6 5))
| (3 7)
+---------------
I understand that you can back-reference already used "_"s, but
how do you specify order *without* backreference. E.g., how do you
do the same as the following in my "#$" readmacro:
> (mapcar #$(list $2 $1) '(3 5 7) '(1 6 5))
((1 3) (6 5) (5 7))
>
The only way I could figure out how to do it with your syntax was
to create "do nothing" uses of "_" to anchor the back-references to:
> (mapcar (_ _ _ (list _2 _1)) '(3 5 7) '(1 6 5))
((1 3) (6 5) (5 7))
>
Am I missing something obvious?
-Rob
p.s. Thanks for the reminder that a one- or two-character plain ol'
macro is quite sufficient for this sort of LAMBDA abbreviation stuff.
Readmacros really *aren't* needed here!
I already have a FN macro which is a simple abbrevation
for LAMBDA. If I add scanning for "$n" variables, it would
enable *both* styles:
(fn (x y) (list y x) ; still useful when nesting, to avoid arg capture
or:
(fn (list $2 $1)) ; implicit arglist
All that "#$" would buy then is one fewer set of parens and a space:
#$(list $2 $1)
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607