mathstodon.xyz is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance for maths people. We have LaTeX rendering in the web interface!

Server stats:

2.7K
active users

#macros

0 posts0 participants0 posts today

My small overview of "JRM’s Syntax-rules Primer for the Merely Eccentric" paper about Scheme macros and useful tricks for writing them. Difficulty: medium-easy.

mpv youtu.be/A2vi3vQ15kM

Paper:
- phyast.pitt.edu/~micheles/synt
- hipster.home.xs4all.nl/lib/sch

Spoiler: at the end of the paper a minimal scheme evaluator implemented purely with macros.

youtu.be- YouTubeEnjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

Today I learned that Racket and Guile represent syntax objects for lists differently.

I don't know yet which one I prefer, because in Guile `syntax` not always returns a syntax-object as one could expect, sometimes it returns a list.

(use-modules (system syntax))
(syntax? (syntax (+ 3 4))) ;; => #f
(syntax? (syntax hi)) ;; => #t

On the other hand TSPL4 book says that #'(+ 3 4) returns a valid list.

Who read RnRS? What does it say for this case?

We use scalasql at work (yes, I'd recommend) and we had a bug where we mistakenly created nested transactions (which scalasql doesn't support -- but it does support savepoints).

Anyway, we found a clever way to statically prevent nesting transactions using macros, which I thought I'd share as an illustration of the helpfulness of macros
gist.github.com/aboisvert/c716

Illustration of using Scala macro to statically prevent nested transactions using the scalasql library - preventNestedTransaction.scala
GistIllustration of using Scala macro to statically prevent nested transactions using the scalasql libraryIllustration of using Scala macro to statically prevent nested transactions using the scalasql library - preventNestedTransaction.scala