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.
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.
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.
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))
and
⇒ (1 2 # 1 2)
right?
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.♥
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.
Ah, I love when this site is posted on lobste.rs. Every article deals with something interesting. Thank you!
The proposed implementations are Chicken specific; the proposed semantics are not.♥
Note that the fancy defines are mentioned in the manual and noted as an extension to standard
define
:I saw! After stumbling upon them, I found them in docs for Chicken, Guile and Racket. That’s what I meant by
BTW I’m having a lot of fun with my new macro stuff:
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
andmatch-define
shortcuts.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 keepdefine
simple, https://github.com/vyzo/gerbil/issues/507Also add define-closure and match-define and match-define-closure ♥
You may want to read what gerbil has, https://cons.io/reference/core-prelude.html#prelude-macros Check out
def*
andcase-lambda
. It’s not always clear what is the best syntactic forms to have in a base prelude. I think yourdefine-closure
is a bit confusing. Besides, the examples rely on evaluation order, which is implementation dependent.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))
and
⇒ (1 2 # 1 2)
right?
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.♥
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.
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.