laurent.orseau
2021-1-5 14:28:29

Just finished a package for pass-through default values (wrapper functions) and simplifying keyword arguments: https://docs.racket-lang.org/define2/index.html It should have very little runtime overhead (if any).

Happy to receive feedback regarding names (is any chosen name ambiguous/bad to you?) or if something in the API should be enhanced


laurent.orseau
2021-1-5 14:29:05

Thanks!


laurent.orseau
2021-1-5 14:32:04

Using this package, I can finally finish a struct form that uses keyword arguments for constructors and works with inheritance, here’s a test submodule:


laurent.orseau
2021-1-5 14:33:03

I’m wondering if I should push this to the same define2 package, or a different package the depends on it.


laurent.orseau
2021-1-5 18:31:22

I think I nailed the <https://docs.racket-lang.org/define2/index.html#%28form.%28%28lib.define2%2Fmain..rkt%29.~ce~bb%29%29|grammar for lambda> compared to the buggy one in the <https://docs.racket-lang.org/reference/lambda.html#%28form.%28%28lib.racket%2Fprivate%2Fbase..rkt%29.~ce~bb%29%29|main docs> :grin:


laurent.orseau
2021-1-5 18:33:18

To avoid the two lines with/out . rest, I wanted to write something like: args = (formals ...) \| (formals ... . rest-id formals ... = pos-id ... [opt-id opt-expr] ... kw-arg ... but formals ... is not permitted on the lhs :confused:


laurent.orseau
2021-1-5 18:35:08

I could have written args = (formals) \| (formals . rest-id) formals = pos-id ... [opt-id opt-expr] ... kw-arg ... but I felt it was harder to read


kellysmith12.21
2021-1-5 18:35:14

Your grammar is much more readable. Also, I think that being able to mix optional and mandatory arguments in the lambda can lead to confusion; having a specific order is nice.