Hygienic macro - CompWisdom
About us  |  Why use us?  |  Press  |  Contact us

 

Topic: Hygienic macro


  
 Scheme - Macros
When a macro use is transcribed according to the template of the matching <syntax rule>, pattern variables that occur in the template are replaced by the subforms they match in the input.
All macros defined using the pattern language are "hygienic" and "referentially transparent":
Since part of the task of hygienic macro expansion is to resolve identifier references, the fact that transformers are expanded in the same environment as the program means that identifier bindings in the program can shadow identifier uses within transformers.
http://www.cs.indiana.edu/scheme-repository/R4RS/r4rs_12.html

  
 Lispmeister.com : Dave Moon: S-expressions are a bad idea
Because of macros, the structure of lexical contexts is not simple block-structured nesting: an identifier can be referenced from a place in the code where it is not visible by name.
The representation used by macros (and by anyone else who wants to bypass the surface syntax) should be defined as just an interface, and the implementation underlying it should be up to the compiler.
I think you should limit the language to what you know how to implement, so the macro special-form should only be allowed in places where its complete flow is visible at compile time and should never be allowed to materialize as a run-time object.
http://lispmeister.com/cgi-bin/blosxom/lisp-news/moon-on-s-expressions.html

  
 [No title]
Macros that mimic functions are quite useful when a programmer absolutely, positively wants a function to be inlined.
If define macro were allowed inside of a block with local variables bound by let, local, or the exit-procedure feature of block, there would be a similar problem if the expansion of the macro includes free references to those variables.
In Moon's old macro proposal, this was solved by making a macro a funny kind of object and using existing constructs to bind variables to those objects.
http://www.cs.cmu.edu/afs/cs.cmu.edu/project/gwydion-1/dylan-history/1994/01/01751

  
 The Power of Irrelevance
Scope analysis was only done after macro expansion, so the reader would have to simulate the expansion in their head before that could use scope analysis.
The reader of a fragment of a Scheme program that might be using hygienic macros must still do everything listed above before scope analysis allows them to disqualify any of the program from relevance to their question.
As with the for-loop, rather than constrain macros only to produce expansions that preserve the scope analysis, we can instead reject just those programs that cause an expansion that would disrupt the pre-expansion scope analysis.
http://www.erights.org/data/irrelevance.html

  
 Re: semantics of ?=
Every identifier that is mentioned by a macro template (or pattern default) and that is not a toplevel identifier in the macro definitions environment is hygienic.
But a name "it" is not defined in the same toplevel environment as the macro "pig-out".
Consider the case where "it" _had_ a toplevel binding where \pig-out is defined and the macro was defined thus: define macro pig-out {pig-out(?_where:expression)} => {let where = ?_where; awhile(poll(where)) it := ?=it; eat() end} define variable it = #f; define function eat() format-out("Eating %s\n", it); end; With your interpretation the assignment would be a no-op.
http://www.ai.mit.edu/~gregs/info-dylan-archive-html-2002/msg00499.html

  
 Scheme Macro Programming
Macros -- that is, syntax transformers and syntax objects -- can be stored in variables, passed to ordinary procedures and applied at run-time.
In the specific case of R5RS macros, we present a stronger result: systematic developing of R5RS macros by a translation from the corresponding Scheme procedures.
The evaluation occurs in different ways, yet the idea of delaying an action and passing its promise as a first-class object is universal.
http://okmij.org/ftp/Scheme/macros.html

  
 Macros - source to source transformation
Good news: hygienic macros in a language with syntax are possible.
M4, a more powerful macro package, provides limited computational abilities, but must avoid syntax clashes with a language that uses it.
Dylan has syntactic macros which are currently proprietary.
http://openmap.bbn.com/~kanderso/building/macro

  
 Abstrct
Macros defined using this system are automatically hygienic and referentially transparent.
In particular, automatic hygiene, referential transparency, and the ability to use patterns extend to all macro definitions, and there is never any need to explicitly manipulate syntactic environments of any kind.
This article describes a pattern-based hygienic macro system for Scheme and provides numerous examples of its use.
http://www.cs.indiana.edu/~dyb/pubs/tr356-abstract.html

  
 Diary for chalst
If I have a macro call (m arg), the macro can create arbitrary computational contexts for arg: it may refer to variables that do not occur in the current computational context, its evaluation may be delayed until varius I/O operations are performed, or various updates to global variables are performed, or some other such thing.
The main application I find myself using macros for, and crucial to the `little languages' approach, is the ability to control the environment in which computations are performed.
The body of the let is not evaluated in the environment in which the let occurs (which is the only option with normal functions), but in a new environemnt which has a set of variables defined in it.
http://www.advogato.org/person/chalst/diary.html?start=43

  
 Dylan Programming: 21.2 Macro hygiene
A hygienic or referentially transparent macro system is one that prevents accidental collisions of macro variables with program variables of the same name.
Dylan's hygienic macros solve this problem by differentiating between the value introduced by the macro and any other
There is a possibility that this variable could conflict with another variable in the surrounding code.
http://www.gwydiondylan.org/books/dpg/db_331.html

  
 The Little Calculist: April 2005
In this case, rebinding the keyword identifiers will just cause invocations of the macro to fail with a syntax error, because the use of the keyword at the invocation site doesn't have the same binding as the use of the keyword in the macro definition.
Yeah, if I were teaching macros I'd start without pattern matching.
Some might claim you can write macros in a hygienic macro system without understanding properly lexically scoped macros, since they're just taken care of for you.
http://calculist.blogspot.com/2005_04_01_calculist_archive.html

  
 [No title]
The environment in effect when the syntax-lambda expression was evaluated is remembered as part of the macro.
But for ordinary value definitions it must be possible to invoke macros defined within the same LETREC, because otherwise it would be pointless to mix the two together in the first place.
In the process of trying to understand various problems related to lexically scoped hygienic macros I came across a seemingly interesting question.
http://martigny.ai.mit.edu/pipermail/rrrs-authors/1995-July.txt

  
 [No title]
I think that the user of the macro should be aware of the literal matches it makes and have to plan accordingly in his use of variables.
Because it causes the programmer to be forced to extend his knowledge from just where the macro is used to having the macro be affected by the entire lexical scope.
Users of macros are already aware that capture could occur so the macro writers should use GENSYM and the users should use obscure variable names.
http://tunes.org/~nef/logs/scheme/04.03.02

  
 SCM - Syntactic Hooks for Hygienic Macros
or a lexical environment passed to a macro expander.
must be a lexical environment passed to a macro transformer during macro expansion.
will be returned, if the macro was defined in Scheme, then a macro expansion will be returned.
http://www.cs.jcu.edu.au/~marianne/scm/scm_47.html

  
 Ovidiu Predescu's Weblog: Java hygienic macros
This is the case in most implementations of Scheme, which have a very small core and everything else is implemented as macros.
One thing I liked about the system is that it's procedural, thus potentially easier to understand and master than the declarative syntax macros in Scheme.
Even then however, it could still be a challenge to understand and master.
http://www.webweavertech.com/ovidiu/weblog/archives/000118.html

  
 [No title]
JTS is a language development system for building domain-specific languages using preprocessor (macro processing) approach.
If both checks are performed, no parse errors can occur as a direct consequence of macro expansion.
http://www.cis.uab.edu/cs693/Lecture17-18.ppt

  
 [No title]
Put simply: there are two environments we care about: the environment that obtains during the macro definition (call this the 'transformer environment') and the environment that obtains when the macro is called (call this the 'runtime environment').
the one in which the macro was defined --, and the resulting expression is by default closed in the environment of the user of the macro.
A name's denotation might be a macro transformer (so, after defining AIF thus, the symbol AIF would be mapped to its macro transformer), or it might be an absolute reference to a name in a module.
http://tunes.org/~nef/logs/scheme/05.01.09

  
 Macro
Macro Magic provides you with unlimited ways to snuff-out all of your repetitive tasks.
This page describes the term macro and lists other pages on the Web where you can find additional information.
Microsoft's Excel spreadsheet program provides an alternative environment for many of the computations required for Macro-Investment Analysis.
http://infowide.info/?q=macro

  
 [No title]
On the other hand, this eliminates the need to resort to procedural macros or implementation-specific extensions to do these simple things, which is good.
Change to the phrase grammar in the Dylan Macros specification: Add "?= word" to the possible right-hand sides for replacement-element.
AESTHETICS: One more feature to learn, which is bad.
http://www.cs.cmu.edu/afs/cs.cmu.edu/project/gwydion-1/dylan-history/1994/09/03202

  
 archive: Re: macro
Hygienic macros implicitly capture environments, in effect, so
macro, you probably don't need something like this.
>>> E. g., by using the env arg it is possible to write a macro capturing
http://www.red-bean.com/guile/guile/old/1190.html

  
 Scheme programming language - Wikipedia, the free encyclopedia
Scheme's macro facilities allow it to be adapted to many different problem domains.
Purely functional programs have no state and don't have side-effects, and are therefore automatically thread-safe and considerably easier to verify than imperative programs.
The advantage of a hygienic macro system (as found in Scheme and other languages such as Dylan) is that any name clashes in the macro and surrounding code will be automatically avoided.
http://en.wikipedia.org/wiki/Scheme_programming_language

  
 Syntactic abstraction: More information
Chapter 8 of this book describes the syntax-case macro system and gives numerous examples of its use.
This article describes the design, motivation behind, and implementation of the syntax-case macro system.
An older version of Chapter 8 of The Scheme Programming Language.
http://www.cs.indiana.edu/~dyb/synbib.html

  
 [No title]
(cadr x) '...)))) ;syntax-rules (define syntax-rules (macro (keywords.
(cdr (hyg:flatten ',in-pattern)),keywords-sym) '()))) (hyg:untag (mbe:expand-pattern (car tagged-out-pattern+alist) (mbe:get-bindings ',in-pattern,arg-sym,keywords-sym),keywords-sym) (cdr tagged-out-pattern+alist) '()))))) clauses) (else (error ',macro-name 'no-matching-clause ',clauses))))))) (define define-syntax (macro arg (cons 'define arg))) (define let-syntax (macro arg (cons 'let arg))) (define letrec-syntax (macro arg (cons 'letrec arg))) ;end of file
*gentemp-counter* (+ *gentemp-counter* 1)) (string->symbol (string-append "GenTemp%" (number->string *gentemp-counter*))))) ;Hygiene (define hyg:rassq (lambda (k al) (let loop ((al al)) (if (null?
http://cvs.sourceforge.net/viewcvs.py/jscheme/jscheme/src/elf/mbe.scm?rev=1.2

  
 Programming languages
Gema is a macro processor based on pattern-matching string rewriting.
Pico is a minimalistic Scheme-like language with infix syntax, based on `tables' rather than lists.
Twelf includes the LF framework with type reconstruction, the Elf constraint logic programming language and an inductive meta-theorem prover for LF.
http://www.computerscience.nl/people/franka/lang

  
 The Dylan Reference Manual: Hygiene
If such a named value reference does not refer to a local binding created by the macro expansion then it must have the same meaning as would a named value reference with the same name adjacent to the macro definition.
gets looked up in the environment of the macro definition, not the environment of the macro call.
Sometimes it is necessary for a macro to violate the hygienic property, for example to include in a macro expansion a named value reference to be executed in the lexical context where the macro was called, not the lexical context where the macro was defined.
http://www.gwydiondylan.org/books/drm/drm_85.html

  
 MIT/GNU Scheme release notes
This is a complete rewrite of the syntax engine, so any program that uses macros should be rewritten to use the new engine.
Release 7.7.1 fixes several bugs in IMAIL; fixes a bug that prevented the use of server sockets on Windows systems; and fixes a bug that caused the debugger to generate errors in common circumstances.
macro was also changed to use these new facilities.
http://www.gnu.org/software/mit-scheme/release.html

  
 archive: Re: modules and macros
Idea about how this might be implemented in Guile:
In reply to: Mikael Djurfeldt: "Re: modules and macros"
> > There is no contextual information attached to the result of macro
http://www.red-bean.com/guile/guile/old/0694.html

  
 [No title]
environment of macro expanders is not consistent interpreted code closes macros in the usual lexical environment, the compiler closes them in the *root-strcucture* since the lexical environment of the compiled file doesn't exist Xerox scheme closes all macros in the `initial environment', this would provide consistency, but would break existing code !
Measure this by adding an extra vector slot, and counting the number of vm instructions executed (and dividing by the length of the code-string?) Another option is to generate direct-threaded code from the bytecode (and cache it).
[ I have an experimental low-level hygienic macro implementation, but it's a long way from being useful ] - do JIT compilation of bytecode where profitable there's now GNU lightning, a VCODE-like system, using C macros to do portable runtime code generation Only do this for _heavily_ used bytecode subrs.
http://www.mit.edu/afs/dev/user/ghudson/third/librep/TODO

  
 [plt-scheme] defmacro (define-macro) and hygienic macros
You'd have to use some convention to denote annotations to the source code and then you're back in Emacs Lisp "if the cadr is the symbol foo the rest of the list is interpreted as..." hell.
The difference is they also make use of the additional information stored in a syntax-object, which defmacro doesn't.
Basically there is nowhere to store additional information (such as the inferred types of expressions for a compiler, or environment information for a hygenic macro system).
http://www.cs.brown.edu/pipermail/plt-scheme/2003-March/002039.html

  
 Scheme Macros for Common Lisp
macro could be defined using MBE as follows (we will use
Here is an example of a disjunction form
These macro definers, also called macro by example (MBE), use simple patterns, including ellipsis, to specify how a macro should be expanded.
http://www.ccs.neu.edu/home/dorai/mbe/mbe-lsp.html

  
 [No title]
?z) (list ?x (list ?y...) ?z))))) (foo 1 2 3 4 5)) ; => (1 (2 3 4) 5) -- Reference implementation -- There are two example macro expanders here provided that implement the proposed extensions, Alexpander & EIOD.
(k ((?var ?init)...) (?body1 ?body2...))))))) ;;; The next example uses two other macros that we don't define here: ;;; SYNTACTIC-SYMBOL?
Alexpander is a complete, sophisticated expander for the syntax-rules macro system; EIOD is an implementation of R5RS's EVAL that obviously requires a macro expander internally.
http://srfi.schemers.org/srfi-46/srfi-synrules-exts.txt

  
 [No title]
For example, to get the old class system, use (require (lib "class-old.ss")) * The core syntax system is hygienic; `define-macro' has been replaced by `define-syntax'.
Inside MzScheme: * "process" in function, type, and macro names was replaced by "thread".
The "defmacro.ss" library in the "mzlib" collection defines `define-macro' for compatibility purposes: (require (lib "defmacro.ss")) The macro procedure cannot access global bindings as in previous versions, however.
http://www.cs.utah.edu/~mflatt/tmp/MzScheme_200.txt

  
 [No title]
I recommend defining keywords as syntax parameters instead of creating macros that non-hygienically introduce identifiers.
So, these keywords work as expected, and macros can easily and correctly expand to uses of `class' and `class*'.
Thus, macros that would naturally expand to `class' or `class*' had to expand to `class*/names', instead, because expanding to a non-hygienic macro usually does not work.
http://download.plt-scheme.org/chronology/mzmr299.14.html

  
 implementing dynamic-wind
The main question I had is: Can dynamic-wind be implemented without complicating the basic evaluation system?
The main question I had is: Can > dynamic-wind be implemented without complicating the basic evaluation > system?
In fact I am so far with it that I feel up to the challenge of implementing some of the weirder parts of the R5RS - hygienic macros and dynamic-wind.
http://www.codecomments.com/message271060.html

  
 Rooster Graph
Boost Graph Library, but it does go a bit further by having both strict- and lazy-evaluated methods; the user of the graph has pause/continue/stop control and is not constrained by memory.
CHICKEN Scheme, although porting it to other Scheme implementations would be quite easy.
uses Scheme macros to get the benefit of speed while having generic operations.
http://www.nongnu.org/rgraph

  
 John Greiner's Research
Then I worked on improvements, primarily of the macro expansion of Scheme88 and ISWYM, which were unreleased modifications of Scheme84 and predecessors of Rice Scheme.
There I worked on Scheme and hygienic macros.
As a graduate student at Carnegie Mellon University, I originally was in the POP (Principles of Programming) group (cf.
http://www.cs.rice.edu/~greiner/my_research.html

  
 Languages It Influenced - Scheme
Common Lisp is used more widely than Scheme for the simple reason that it has more functionality "out of the box", making it a more suitable choice for most practical development projects.
Key among these is the improved number handling provided by the full numeric tower, and the hygienic macro system which owes its origins to Common Lisp's popular but somewhat less elegant macro implementation.
As Scheme developed through the carefully managed Revised Reports, ideas that had proved themselves in Common Lisp were occasionally rolled in to Scheme as well.
http://simon.incutio.com/uni/scheme?page=LanguagesItInfluenced

  
 LWN: Schemer's Gazette
Among other novel features, it addresses a large class of variable capture problems that are often overlooked in existing hygienic procedural macro systems.
This announces the availability for discussion of Scheme Request for Implementation 72 "Simple hygienic macros" by André van Tonder.
It also introduces a new primitive for breaking hygiene that leads to better behaviour of unhygienic macros under composition.
http://lwn.net/Articles/148166

  
 Lambda the Ultimate DSL
Thus, the system is based on concrete syntax rather the ASTs.
The tree processing language (the paper calls it the "macro language") was originally designed for HTML processing, and looks a bit like XSLT.
http://lambda-the-ultimate.org/classic/DSL.html

  
 CTO : Programming Languages
with linear continuations, distributed computation, Unicode support, and non-hygienic macros
Felix - A higher-order functional programming language, written in Ocaml, which compiles to and integrates with (embeds in) C++
http://cliki.tunes.org/Programming%20Languages

  
 Steve's Digicams - Breaking News - November 1999
When connected to a DVD player or a notebook computer, i- glasses provide an exceptional entertainment experience.
With the new Macro feature, PhotoStudio users can create and save a series of effects and enhancements as a single one-click command - allowing the user to apply the batch process on hundreds of images with a single click.
The multiple layer feature enables users to apply special effects or enhancements to each layer without affecting other layers - making it easy to change or alter any edits they may have at a later time.
http://www.steves-digicams.com/diginews_nov99.html

  
 LispMe Todo list
The implementation of the macro system is a kludge.
(or implementing the hygienic macro system of R
However, during compilation no events are accepted, so after a given maximum number of steps macro expanding is aborted.
http://www.lispme.de/lispme/doc/lm_todo.htm

  
 chicken-highlevel-macros.scm - CHICKEN - A practical and portable Scheme system. Version 1, Build 89
unit as used and install the macro system by hand, as in this example:
Normally you don't directly use this file, since it is loaded automatically by the compiler or interpreter, when the
) available at run-time (for example, for evaluating code at runtime that contains highlevel macros), declare the
http://www.call-with-current-continuation.org/manual/chicken_002dhighlevel_002dmacros_002escm.html

  
 Scheme as a Substrate for XEmacs
Scheme's hygienic macro system makes for much fewer nasty surprises than Common Lisp's no-holds-barred approach.
The module systems coming with modern Scheme substrates are substantially more powerful and scale up better than Common Lisp's.
Here's an introduction to hygienic macros spread across four files:
http://www-pu.informatik.uni-tuebingen.de/users/sperber/xemacs/next-generation/scheme.html

  
 LtU Classic Archives
The macro pattern language with all its "..." 's is a little hard to read sometimes.
make R5RS hygienic macros more palatable by rendering them, their arguments, and application results graphically as trees.
It's tempting to follow Simonyi's lead and make R5RS hygienic macros more palatable by rendering them, their arguments, and application results graphically as trees.
http://lambda-the-ultimate.org/classic/message3860.html

  
 Twobit Pass 1
Pass 1 also creates for each local variable a table containing all references, assignments, and procedure calls to that variable.
Pass 1 collects information needed for optimization while converting a Scheme definition or expression into the front end's intermediate form.
It performs hygienic macro expansion, eliminates internal definitions, checks syntax, and gives a unique name to each local variable (alpha conversion).
http://www.ccs.neu.edu/home/will/Twobit/pass1.html

  
 Miracles of the Qur'an - Harun Yahya
Scientific research shows that the cognitive development in breast-fed babies is greater than that in other babies.
This is a most important feature because in addition to food, babies also need liquid in the form of water.
Full hygiene may not be established in water or foodstuffs other than mother's milk.
http://www.harunyahya.com/miracles_of_the_quran_p1_08.php

  
 Gauche Reference Manual: Hygienic Macros
R5RS hygienic macro is based on a special pattern language, and guaranteed that no "variable capture" occurs.
This document was generated by Shiro Kawai on July, 1 2005 using texi2html
"Variable catpture" means that if you insert new variable bindings in the expanded form, the new bindings shadows the bindings in the form passed to the macro.
http://www.shiro.dreamhost.com/scheme/gauche/man/gauche-refe_42.html

  
 CLiki : syntax-case
and Scheme's SYNTAX-RULES (a hygienic macro facility defined in the R5RS Scheme standard), and which cannot be defined in terms of either.
SYNTAX-CASE is a system for macros proposed by R. Kent Dybvig in 1992 for Scheme (see "Syntactic Abstraction in Scheme", IUCS TR #355, link below), which generalises Common LISP's DEFMACRO?
It is controversial whether or not Common LISP would benefit from the addition of SYNTAX-CASE, and no implementations of SYNTAX-CASE for Common LISP are known of.
http://www.cliki.net/syntax-case

  
 Asci file: /home/jaffer/scm/ANNOUNCE
* eval.c (lookupcar): Added support for hygienic macros (evalatomcar): Added.
From Radey Shouman * scm.h (IM_DELAY) (IM_QUASIQUOTE) (IM_UNQUOTE) (IM_UQ_SPLICING) (IM_ELSE) (IM_ARROW): Added to support hygienic macros.
http://www.cs.bgu.ac.il/~elhadad/scm/README.html

Compwisdom
 About us   |  Why use us?   |  Press   |  Contact us

 Copyright © 2006 CompWisdom.com Usage implies agreement with terms.