Collection of Great Applications and Programs using Macros
Asked Answered
D

8

60

I am very very interested in Macros and just beginning to understand its true power. Please help me collect some great usage of macro systems.

So far I have these constructs:

Pattern Matching:

Andrew Wright and Bruce Duba. Pattern matching for Scheme, 1995

Relations in the spirit of Prolog:

Dorai Sitaram. Programming in schelog. http://www.ccs.neu.edu/home/dorai/schelog/schelog.html

Daniel P. Friedman, William E. Byrd, and Oleg Kiselyov. The Reasoned Schemer. The MIT Press, July 2005

Matthias Felleisen. Transliterating Prolog into Scheme. Technical Report 182, Indiana University, 1985.

Extensible Looping Constructs:

Sebastian Egner. Eager comprehensions in Scheme: The design of SRFI-42. In Workshop on Scheme and Functional Programming, pages13–26, September 2005.

Olin Shivers. The anatomy of a loop: a story of scope and control. In International Conference on Functional Programming, pages 2–14, 2005.

Class Systems:

PLT. PLT MzLib: Libraries manual. Technical Report PLT-TR2006-4-v352, PLT Scheme Inc., 2006. http://www.plt-scheme.org/techreports/

Eli Barzilay. Swindle. http://www.barzilay.org/Swindle.

Component Systems:

Ryan Culpepper, Scott Owens, and Matthew Flatt. Syntactic abstraction in component interfaces. In International Conference on Generative Programming and Component Engineering, pages 373–388, 2005

Software Contract Checking

Matthew Flatt and Matthias Felleisen. Units: Cool modules for HOT languages In ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 236–248, 1998

Oscar Waddell and R. Kent Dybvig. Extending the scope of syntactic abstraction.In Symposium on Principles of Programming Languages, pages 203–215, 199

Parser Generators

Scott Owens, Matthew Flatt, Olin Shivers, and Benjamin McMullan. Lexer and parser generators in Scheme. In Workshop on Scheme and Functional Programming, pages 41–52, September 2004.

Tools for Engineering Semantics:

Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. Semantics Engineering with PLT Redex. MIT Press, August 2009.

Specifications of Compiler Transformations:

Dipanwita Sarkar, Oscar Waddell, and R. Kent Dybvig. A nanopass framework for compiler education. Journal of Functional Programming,15(5):653–667, September 2005. Educational Pearl.

Novel Forms of Execution

Servlets with serializable continuations Greg Pettyjohn, John Clements, Joe Marshall, Shriram Krishnamurthi, and Matthias Felleisen. Continuations from generalized stack inspection. In International Conference on Functional Programming, pages216–227, 2005.

Theorem-Proving System

Sebastian Egner. Eager comprehensions in Scheme: The design of SRFI-42. In Workshop on Scheme and Functional Programming, pages 13–26, September 2005.

Extensions of the Base Language with Types

Sam Tobin-Hochstadt and Matthias Felleisen.The design and implementation of typed scheme. In Symposium on Principles of Programming Languages, pages 395–406, 2008.

Laziness

Eli Barzilay and John Clements. Laziness without all the hard work:combining lazy and strict languages for teaching. In Functional and declarative programming in education, pages 9–13, 2005.

Functional Reactivity

Gregory H. Cooper and Shriram Krishnamurthi. Embedding dynamic dataflow in a call-by-value language. In European Symposium on Programming, 2006


Reference:

Collected from Ryan Culpepper's Dissertation

Derrek answered 28/12, 2010 at 19:20 Comment(6)
+1 Nice question. I think it would be useful to ask it at cstheory.SE or migrate it there, because it looks like similar questions, for example What's new in purely functional data structures since Okasaki?, have much more views there.Chil
I posted it there. But I am getting downvotes.Derrek
@Yasir and kujaan, this is not a research-level question, so doesn't belong on cstheory, it might belong on programmers thoughFazeli
If you want usage examples, it's not particularly theoretical eitherFazeli
Btw., why 'hygiene' tag? At least half of the listed examples are of the common lisp-style macros.Lombardi
SK-logic: every macro listed above is currently implemented using hygenic macros, and almost all of them were originally implement that way (except the ones from the 80s).Caught
C
9

Culpepper & Felleisen, Fortifying Macros, ICFP 2010

Culpepper, Tobin-Hochstadt and Felleisen, Advanced Macrology and the Implementation of Typed Scheme, Scheme Workshop 2007

Flatt, Findler, Felleisen, Scheme with Classes, Mixins, and Traits, APLAS 2006

Herman, Meunier, Improving the Static Analysis of Embedded Languages via Partial Evaluation, ICFP 2004

Caught answered 28/12, 2010 at 19:20 Comment(1)
"Scheme with Classes, Mixins, and Traits" was an impressive paper with very useful references. Thanks for recommending.Derrek
L
6

Shivers, Carlstrom, Gasbichler & Sperber (1994 & later) The Scsh Reference manual.

Has a lot of good examples of using macros to embed mini-languages into Scheme. Introduced me to the technique of defining macros that implicitly quote their argument. Look at the use of process forms, regular expressions, and the awk-like mini-languages. Scsh is my recommendation as a starting point for playing with macros.

Hilsdale & Friedman (2000) Writing Macros in Continuation-Passing Style.

Shows how the weak syntax-rules macros can be made powerful using continuation-passing style. Gives plenty of examples.

Flatt, Culpepper, Darais & Findler (submitted) Macros that Work Together - Compile-Time Bindings, Partial Expansion, and Definition Contexts.

Provides an overview of, and semantics for the approach to macros in Racket/PLT Scheme. Not a whole lot of examples, but I think the paper has something you are looking for.

Louannlouanna answered 9/2, 2011 at 7:0 Comment(0)
H
4

ReadScheme! Remember to check the extensive bibliography on ReadScheme.

http://library.readscheme.org/page3.html

One example I think you missed is embedding SQL syntax into Scheme. http://repository.readscheme.org/ftp/papers/sw2002/schemeunit-schemeql.pdf

Macros are also used to write supports for automated testing.

Homegrown answered 10/8, 2011 at 13:11 Comment(0)
L
3

Not a Scheme, but somewhat similar Lisp dialect with a very extensive use of macros: http://www.meta-alternative.net/mbase.html

There are macros implementing various kinds of pattern matching, list comprehensions, various parsers generators (including a PEG/Packrat implementation), embedded Prolog, ADT visitors inference (like scrap your boilerplate in Haskell), extensible syntax macros, Hindley-Milner type system, Scheme-like syntax macros, and many more. Parts of that functionality can be potentially ported to Scheme, other parts needs an extended macro system with explicit context.

Lombardi answered 9/2, 2011 at 13:7 Comment(0)
P
2

I would add "The Scheme standard library itself" to the list. Look at the file boot-9.scm in the guile distribution. Many of the most commonly-used Scheme forms - case, and, etc. - are defined there as macros.

Phenomenology answered 21/3, 2012 at 18:13 Comment(0)
B
1

Here's an example of a pretty awesome use of scheme macros to create efficient robotics systems written in scheme

Bainter answered 25/11, 2014 at 16:59 Comment(0)
F
0

This isn't particularly precise in so far as it is spread out over a large number of very old publications most of which i've never read, but IIRC large chunks of the Common Lisp Object System and the Meta-Object Protocol*, can be; are; or were initially, built with of macros...

* Which compose IMHO by far the most advanced OO system programming has ever seen

Fazeli answered 9/2, 2011 at 6:40 Comment(3)
This answer would be a whole lot better if you could name a particular paper as a good starting point.Louannlouanna
I know, but all the interesting papers were written in the '70s which makes them really hard to find :(Fazeli
@charles, +1, but i hoped googling the names was kinda implied as the next step ;)Fazeli
U
0

Check one of my favorites implementations of a REST API: the Slack api client, that isn't written in Scheme but it is in Racket.

octotep/racket-slack-api

Ultracentrifuge answered 7/6, 2017 at 21:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.