<jcowan>
In MFTL all functions are keyword functions unless they have exactly one or two arguments (in which case they are operators) or zero arguments.
vraid has quit [Ping timeout: 252 seconds]
iclon__ has joined #racket
iclon_ has quit [Ping timeout: 246 seconds]
orivej has quit [Ping timeout: 255 seconds]
caltelt has quit [Remote host closed the connection]
Fernando-Basso has quit [Remote host closed the connection]
badkins has joined #racket
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
Arcaelyx has joined #racket
lavaflow has joined #racket
orivej has joined #racket
orivej has quit [Ping timeout: 250 seconds]
johnjay has quit [Quit: WeeChat 2.3]
dbmikus_ has quit [Ping timeout: 268 seconds]
johnjay has joined #racket
dbmikus_ has joined #racket
vraid has quit [Disconnected by services]
efm has joined #racket
vraid has joined #racket
notzmv has quit [Ping timeout: 255 seconds]
Fernando-Basso has joined #racket
notzmv has joined #racket
efm has quit [Ping timeout: 250 seconds]
soegaard has joined #racket
sauvin has quit [Ping timeout: 252 seconds]
ubLIX has joined #racket
ubLIX has quit [Ping timeout: 250 seconds]
acarrico has quit [Ping timeout: 252 seconds]
Arcaelyx has quit [Ping timeout: 255 seconds]
ricekrispie2 has joined #racket
ricekrispie has quit [Ping timeout: 258 seconds]
notzmv has quit [Ping timeout: 244 seconds]
pera has quit [Ping timeout: 255 seconds]
<vraid>
i wrote some struct macros a while back to let me do (struct/kw foo (a b)), and then (foo/kw #:b 2 #:a 1) in place of just (foo 1 2). looking back at it, i'd like to replace it with something to let me do (foo/fields [b 2] [a 1]) as it looks a bit cleaner. is there an obvious way to do this? it's been some time since i wrote macros
ubLIX has joined #racket
<vraid>
foo/fields would have to be a macro in itself, would it? foo/kw was simply a function accepting keyword arguments
<soegaard>
One strategy: Let (foo/fields [b 2] [a 1]) expand to (foo/kw #:b 2 #:a 1)
<vraid>
that was my first thought. i'm not sure how to handle field order otherwise
<vraid>
it still has to be a macro, right?
<soegaard>
Yes.
<soegaard>
Otherwise [b 2] is seen as an application.
<selimcan>
do racketeers think that rust is a reasonable guy to be treated with respect?
v88m has joined #racket
Arcaelyx has joined #racket
FreeFull has joined #racket
pera has joined #racket
nullcone has joined #racket
nullcone has left #racket [#racket]
emacsomancer has joined #racket
ubLIX has quit [Quit: ubLIX]
selimcan has quit [Remote host closed the connection]
keep_learning has quit [Ping timeout: 246 seconds]
pierpal has quit [Ping timeout: 244 seconds]
<vraid>
soegaard: so i'm giving the macro a (_ id [field value] ...) signature, and the call should be something like #'(constructor (syntax->keyword field) value ...), but i can't quite get the ellipses right
<soegaard>
You have the same number of fields and values so (list (syntax->keyword field) value)) ... will work (here field and value is paired.
<soegaard>
I got the parens wroong before: (flatten (list (list (syntax->keyword field) value) ...)
<vraid>
ah, of course. so #'(cons constructor (flatten ...))
<soegaard>
Or (apply constructor (flatten ...
mSSM has quit [Ping timeout: 250 seconds]
<vraid>
ah yes
lmln_ has joined #racket
efm has joined #racket
<vraid>
hmm, next issue is that the call to (struct/fields foo (a b)) should define a foo/fields, which holds a reference to the foo/kw function.. this might be obvious, but how do i easiest capture a variable when creating that macro
<soegaard>
Is the macro foo/kw defining foo/fields ?
<vraid>
(struct/kw foo (a b)) defines both foo/kw and foo/fields, where (foo/fields [b 2] [a 1]) should expand to (foo/kw #:b 2 #:a 1)
selimcan has joined #racket
efm has quit [Ping timeout: 258 seconds]
<soegaard>
If (struct/kw foo (a b)) defines both foo/kw and foo/fields, why is there an struct/fields too?
<vraid>
oh, my mistake. struct/kw was the old name, i meant to write struct/fields
<soegaard>
ok
<vraid>
in essence, (struct/fields ...) is an extension of (struct ...)
<soegaard>
If structs/fields are defined them both, then foo/kw is in scope where foo/fields is defined - so things ought to work out of the box.
nullman` has quit [Ping timeout: 245 seconds]
<vraid>
struct/fields will return syntax including something like #'(begin (define-syntax foo/fields (syntax-parser ..)) then?
<vraid>
i can use.. any character for ellipsis? hah
<soegaard>
When a macro needs to insert a literal ... one can write (... ...). But that's a bit cumbersone, so I like to give it a name (and yes you decide what to call it).
<vraid>
now this one has a duplicate of (define-syntax constructor/fields, due to two branches of struct/fields; one handling struct super-ids, and one not
<vraid>
could the duplication be removed?
orivej has joined #racket
Arcaelyx has quit [Read error: Connection reset by peer]
Arcaelyx has joined #racket
lmln_ has quit [Quit: Connection closed for inactivity]