mixfix and racket 2

95 views
Skip to first unread message

Roger Keays

unread,
Mar 23, 2021, 11:59:50 AM3/23/21
to racket...@googlegroups.com
From racket-news [1]:

mixfix (pkg/src) library allows users to define and use mixfix operators in Racket, by Sorawee Porncharoenwase.

From the mixfix docs [2]:

> (define-mixfix-rule (c {~datum ?} t {~datum :} e)
(if c t e))
> (#true ? 1 : 2)
1

This is what I expected to be able to do when I first started experimenting with various LISPs and Schemes. Supporting only prefix macros seemed like a bit of limitation to me. If mixfix macros were supported out of the box rather than hacking #%app, it would be easier to combine syntax libraries. Possible for Racket 2?

[1] https://racket-news.com/2021/03/racket-news-issue-48.html
[2] https://docs.racket-lang.org/mixfix/

jackh...@gmail.com

unread,
Mar 24, 2021, 12:16:55 AM3/24/21
to Racket Users
Honu's enforestation is approximately this. See https://www.cs.utah.edu/plt/publications/gpce12-rf.pdf. There's been some discussion about whether to base rhombus on a similar approach.

Roger Keays

unread,
Mar 24, 2021, 1:03:22 PM3/24/21
to Racket Users
Looks promising. The extra enforestation phase does add another layer of complexity though. Also, operators don't use pattern matching, so I presume to support Sorawee's example below, you'd have to parse the syntax after the ? yourself.

I think there is some value to considering zero-precendence 'mixfix' macros. AFAICT, they wouldn't require the enforestation phase, which would make the language model simpler. It does complicate the idea of an 'operator' though. Matching them efficiently could also be a problem. Still, I'm happy to trade operator precedence for simplicity.
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to racket-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/
> racket-users/198c4676-08de-4803-9a8b-719d9c298159n%40googlegroups.com.

Jay McCarthy

unread,
Mar 24, 2021, 1:20:18 PM3/24/21
to Roger Keays, Racket Users
I agree with Roger that the zero-precedence `mixfix` system is a
really elegant middle-ground between Honu and a whole big language.
Something I really like about Pyret is that it doesn't have precedence
and requires parens for legibility.

--
Jay McCarthy
Associate Professor @ CS @ UMass Lowell
http://jeapostrophe.github.io
Vincit qui se vincit.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/sigid.171729a446.20210324170310.GA6862%40papaya.papaya.
Reply all
Reply to author
Forward
0 new messages