Re: [racket-users] Struct initialization?

2018-03-13 Thread Philip McGrath
I've written an experimental macro `structure` that tries to make it convenient to write custom wrappers for the constructor and the match expander that use the name of the struct: http://docs.racket-lang.org/adjutor/Experimental.html#%28form._%28%28lib._adjutor%2Fmain..rkt%29._structure%29%29 If y

Re: [racket-users] Struct initialization?

2018-03-09 Thread Milo Turner
You can also set! the extra constructor #lang racket (struct foo [a b c] #:extra-constructor-name -foo #:transparent) (define ((foo* make-foo) a b) (make-foo a b (+ a b))) (set! -foo (foo* -foo)) (foo 1 2) ; -> (foo 1 2 3) (match (foo 1 2) [(foo _ _ c) c]) ; -> 3 However I usually jus

Re: [racket-users] Struct initialization?

2018-03-09 Thread Jon Zeppieri
On Fri, Mar 9, 2018 at 9:35 PM, Kevin Forchione wrote: > Is it possible to initialize a struct field based on values from > previously defined fields? Something equivalent to let* where > > >(struct foo (A B C)) > >(foo 1 2) would produce (foo 1 2 3) for example? > > > As far as I