1. 20
    1. 5

      Ah, I love when this site is posted on lobste.rs. Every article deals with something interesting. Thank you!

    2. 4

      The proposed implementations are Chicken specific; the proposed semantics are not.♥

    3. 2

      Note that the fancy defines are mentioned in the manual and noted as an extension to standard define:

      As an extension to R5RS, CHICKEN allows curried definitions, where the variable name may also be a list specifying a name and a nested lambda list. For example,

      (define ((make-adder x) y) (+ x y))

      is equivalent to

      (define (make-adder x) (lambda (y) (+ x y)))

      This type of curried definition can be nested arbitrarily and combined with dotted tail notation or DSSSL keywords.

      1. 2

        I saw! After stumbling upon them, I found them in docs for Chicken, Guile and Racket. That’s what I meant by

        scoured the docs

        BTW I’m having a lot of fun with my new macro stuff:

        (define-ir-syntax* aif
          ((aif test yes no)
           `(let ((,(inject 'it) ,test))
              (if ,(inject 'it) ,yes ,no))))

        PS: you mean the curried defines. The post goes on to describe some other defines. That’s the main reason why I wrote the post, the new define-closure and match-define shortcuts.

        1. 2

          I added it to gerbil last year, https://github.com/vyzo/gerbil/commit/1dae8300e4fa57a0015dbb17f72c584afc0213a1

          It’s only for gerbil’s def, because vyzo thinks it’s better to keep define simple, https://github.com/vyzo/gerbil/issues/507

          1. 1

            Also add define-closure and match-define and match-define-closure ♥

            1. 1

              You may want to read what gerbil has, https://cons.io/reference/core-prelude.html#prelude-macros Check out def* and case-lambda. It’s not always clear what is the best syntactic forms to have in a base prelude. I think your define-closure is a bit confusing. Besides, the examples rely on evaluation order, which is implementation dependent.

              1. 1

                Huh? They don’t depend on evaluation order other than to show how different each call is.

                You mean
                ⇒ ((6 9) (7 8) (8 7))
                ⇒ (1 2 # 1 2)

                That’s not really core to what I was trying to show.
                I just wanted to, in one line, show that the code worked. No other result depended on those evals.

                As far as Gerbil’s prelude goes, which I am familiar with, they neither have define-closure (nor something similar) nor match-define; case-lambda can only dispatch on arity, it can’t destructure, so something like the Haskell-style my-map can’t work (the counter ’reset could, as long as all the messages have different arity).

                I mean, yet. That’s not meant as a slag on Gerbil. It’s programmable so you can add it if you wanna, or not if you don’t.♥

                1. 1

                  I guess it’s a balance of adding just enough sugar to sweeten things a bit. There are so many ways to do pattern matching (https://cons.io/reference/core-prelude.html#pattern-matching) and putting all that to a single name may not be clear enough. Of course different people like different levels of sweetness.

    4. 1

      Oh, interesting! I had no idea this feature existed, or that it was already in SRFI 201. Guess I found another feature to add to Schemepunk.