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
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
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.
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.
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.
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.
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
Here's an example of a pretty awesome use of scheme macros to create efficient robotics systems written in scheme
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.
来源:https://stackoverflow.com/questions/4548768/collection-of-great-applications-and-programs-using-macros