Re: First comments Linus Björnstam 10 Jun 2020 07:17 UTC

I have a little bit of code implementing a recursively searching "megacut" with a clojuresque lambda shorthand:

https://hg.sr.ht/~bjoli/megacut/browse/readme.txt?rev=default

if there is interest I could codify this as a srfi using cut-like syntax. Currently it is not as hygienic as it could be in how it checks for nested usage, but that is simple to solve. The lambda shorthand cannot be portably implemented.

It could be worded in a way to allow for syntax-rules implementation, allowing limiting it to <1> to <10>, <> and <...>.

I would not want to write that syntax-rules macro though :)

--
  Linus Björnstam

On Wed, 10 Jun 2020, at 08:16, Marc Nieper-Wißkirchen wrote:
> Am Mi., 10. Juni 2020 um 00:19 Uhr schrieb Arne Babenhauserheide
> <xxxxxx@web.de>:
> >
> >  Lassi Kortela <xxxxxx@lassi.io> writes:
> >
> >  >>>> (chain (floor/ 5 2)
> >  >>>> (- <2> <1>))
> >  >>
> >  >> It would be possible by replacing `<2>' with `(<> 2)'.
> >
> >  Could <2> not be a shorthand for (<> 2) — for single-digit numbers?
> >  That would give brevity and flexibility.
>
> Sure, you can do
>
> (define-syntax <2> (identifier-syntax (<> 2)))
>
> but you will always have a bounded number of such definitions in a
> program. That said, `<1>', ..., `<10>' are probably more than enough.
>
> But being explicit (by naming the intermediate results) is probably
> still much better.
> >
> >  >> But at least in this case, `(receive (x y) (floor/ 5 2) (- y x))' is
> >  >> much clearer (and no new syntax for Scheme programmers).
> >  >
> >  > +1. We Schemers are already prone to obfuscating our code with "cadr"
> >  > and "cdar" instead of giving clear names to the intermediate things :)
> >
> >  How would this look for three steps? Like this?
> >
> >  (receive (a b) (receive (x y) (floor/ 5 2)
> >  (values (- y x) (+ y x)))
> >  (* a b))
>
> You would use `let*-values':
>
> (let*-values (((x y) (floor/ 5 2))
>  ((a b) (values (- y x) (+ y x))))
>  (* a b))
>
> I think this is pretty concise and clear.
>