Racket Cheat Sheet

284 views
Skip to first unread message

Jay McCarthy

unread,
Oct 5, 2015, 10:24:23 PM10/5/15
to dev
I've just put together a "cheat sheet" for Racket based on some ideas
from Vincent and Asumu. You can get it with "raco pkg install
racket-cheat" and it will be at the top of your documentation index,
next to "Getting Started". It is currently online here:

http://pkg-build.racket-lang.org/doc/racket-cheat/

I would very much appreciate your pull requests to make it better. I
hope you will find the code very easy to hack and add/rearrange
things:

https://github.com/jeapostrophe/racket-cheat/blob/master/racket-cheat.scrbl

Presently it is restricted to things in main-distribution and only
those things that I think will be very generally applicable, but I am
not opposed to making it broader. This was just a place to start. In
particular, I think bringing a few things from math, plot, and gregor
might be good options. Furthermore, I think there should be a section
on Typed Racket.

Jay

--
Jay McCarthy
http://jeapostrophe.github.io

"Wherefore, be not weary in well-doing,
for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
- D&C 64:33

Greg Hendershott

unread,
Oct 6, 2015, 8:10:47 PM10/6/15
to Jay McCarthy, dev
This is wonderful!!


p.s. Opinion ahead:

Someday soon syntax/parse/* (including define-simple-macro) should be
promoted (in both senses of that word) as "the" Racket macro system.
As in, if you only learn about one, at first, you learn about that.

With syntax-case, syntax-rules, etc. being "deprecated" as
historically interesting simpler systems, which are worth knowing when
dealing with older code.

TL;DR Truly finish s/PLT Scheme/Racket/ wrt macros. (apply rackety macro-docs).

Maybe that's its own discussion, and largely orthogonal to a cheat
sheet. But adopting this could simplify that portion of the cheat
sheet.

Jay McCarthy

unread,
Oct 6, 2015, 8:26:48 PM10/6/15
to Greg Hendershott, dev
On Tue, Oct 6, 2015 at 8:10 PM, Greg Hendershott
<greghen...@gmail.com> wrote:
> This is wonderful!!
>
>
> p.s. Opinion ahead:
>
> Someday soon syntax/parse/* (including define-simple-macro) should be
> promoted (in both senses of that word) as "the" Racket macro system.
> As in, if you only learn about one, at first, you learn about that.
>
> With syntax-case, syntax-rules, etc. being "deprecated" as
> historically interesting simpler systems, which are worth knowing when
> dealing with older code.

You may notice that I only mention define-syntax-rule and
syntax-parse. That was on purpose. I read this as a suggestion that I
should replace define-syntax-rule with define-simple-macro.

> TL;DR Truly finish s/PLT Scheme/Racket/ wrt macros. (apply rackety macro-docs).
>
> Maybe that's its own discussion, and largely orthogonal to a cheat
> sheet. But adopting this could simplify that portion of the cheat
> sheet.

I think it's on topic. There are many things that I didn't include
because I don't think people should use them :)

Greg Hendershott

unread,
Oct 6, 2015, 9:01:23 PM10/6/15
to Jay McCarthy, dev
> You may notice that I only mention define-syntax-rule and
> syntax-parse. That was on purpose.

Aha. Nice.

> I read this as a suggestion that I
> should replace define-syntax-rule with define-simple-macro.

Yes, after expanding my ramble to actionable primitives, that is
really all that remains. :)

Thanks again!

Jack Firth

unread,
Oct 7, 2015, 2:01:14 PM10/7/15
to Racket Developers, greghen...@gmail.com, d...@racket-lang.org
On Tuesday, October 6, 2015 at 5:26:48 PM UTC-7, jay.mccarthy wrote:
You may notice that I only mention define-syntax-rule and
syntax-parse. That was on purpose. I read this as a suggestion that I
should replace define-syntax-rule with define-simple-macro.

On that topic, are there any opinions on changing the name from `define-simple-macro` to something else? It's always struck me as odd.

Jay McCarthy

unread,
Oct 7, 2015, 2:10:08 PM10/7/15
to Jack Firth, Racket Developers, Greg Hendershott, dev
I agree. I don't like the name. I think define-syntax-rule is a choice
choice name.
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-dev+...@googlegroups.com.
> To post to this group, send email to racke...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-dev/96bbbe2b-2e43-4c7f-9f1b-6fe57c7de165%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Alex Knauth

unread,
Oct 7, 2015, 2:12:19 PM10/7/15
to Jay McCarthy, Jack Firth, Racket Developers, Greg Hendershott, dev
What's wrong with define-simple-macro ? I think it's clearer about what it does than define-syntax-rule.

Jay McCarthy

unread,
Oct 7, 2015, 2:14:40 PM10/7/15
to Alex Knauth, Jack Firth, Racket Developers, Greg Hendershott, dev
I find "simple" to be very judgey. Unlike a full syntax-parse
expression with many rules and cases, define-simple-macro has just one
case or one rule, so you're defining a single rule not a set of rules.

Jay McCarthy

unread,
Oct 7, 2015, 2:15:00 PM10/7/15
to Alex Knauth, Jack Firth, Racket Developers, Greg Hendershott, dev
Also, we don't like to say "macro" :)

Matthias Felleisen

unread,
Oct 7, 2015, 3:34:40 PM10/7/15
to Jay McCarthy, Alex Knauth, Jack Firth, Racket Developers, Greg Hendershott, dev

define-syntax-parse
define-rule
define-rewrite
> --
> You received this message because you are subscribed to the Google Groups "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to racket-dev+...@googlegroups.com.
> To post to this group, send email to racke...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-dev/CAJYbDak4B3Zwct4C8MjYjS8UgjjjBEbMgDVZ5meZ5jENixSMqQ%40mail.gmail.com.

Jay McCarthy

unread,
Oct 7, 2015, 10:12:40 PM10/7/15
to Pierpaolo Bernardi, dev
Can you look at the document from the docs home page? It looks like
the error is unrelated to the document.

Jay

On Wed, Oct 7, 2015 at 9:59 PM, Pierpaolo Bernardi <olop...@gmail.com> wrote:
> The document appears to be installed, however I got this:
>
> raco setup: error: during making for <pkgs>/racket-cheat
> raco setup: open-output-file: cannot open output file
> raco setup: path: c:\Program Files\Racket-6.2.0.4\share\pkgs\gui-lib\framewo
> rk\private\compiled\tmp14442691701444269170929
> raco setup: system error: Accesso negato.; errno=5
> raco setup: compiling: <pkgs>/racket-cheat/racket-cheat.scrbl
> raco pkg install: packages installed, although setup reported errors
>> --
>> You received this message because you are subscribed to the Google Groups "Racket Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to racket-dev+...@googlegroups.com.
>> To post to this group, send email to racke...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-dev/CAJYbDakZmcCRNA2z9Fq%3DRWqxdyVrrE7v4xgB7wpQhkiXi8CgLQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.



Brian Mastenbrook

unread,
Oct 7, 2015, 10:16:04 PM10/7/15
to Matthias Felleisen, Jay McCarthy, Alex Knauth, Jack Firth, Racket Developers, Greg Hendershott, dev
(Re: changing the name of define-simple-macro)

On 10/07/2015 02:34 PM, Matthias Felleisen wrote:
> define-syntax-parse
> define-rule
> define-rewrite

What about just calling it define-syntax-rule? How many things would
actually break? If syntax-parse is The Way To Write Macros, shouldn't
the simple single-rule macro-defining syntax in #lang racket reflect
that? The same thing could probably be said for syntax-rules as well.
--
Brian Mastenbrook
br...@mastenbrook.net
https://brian.mastenbrook.net/

Alexis King

unread,
Oct 7, 2015, 10:47:58 PM10/7/15
to Jack Firth, Racket Developers, greghen...@gmail.com, d...@racket-lang.org
> On that topic, are there any opinions on changing the name from `define-simple-macro` to something else? It's always struck me as odd.

+1 for changing the name. It definitely comes off as strange in both the “simple” and “macro” terminology. ;)

> define-syntax-parse
> define-rule
> define-rewrite

We already have define-syntax-parser, so the first one could be confusing, and I think define-rule is a little too general to get the meaning across. define-rewrite comes closer, but it still doesn’t feel like the right phrase. What about mixing them: define-rewrite-rule?

> What about just calling it define-syntax-rule? How many things would actually break? If syntax-parse is The Way To Write Macros, shouldn't the simple single-rule macro-defining syntax in #lang racket reflect that? The same thing could probably be said for syntax-rules as well.

I like this idea in principle, but I think that would warrant a bigger overhaul than just changing the name of “define-simple-macro”. It feels like a good racket2 feature.
Reply all
Reply to author
Forward
0 new messages