unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Syntax Parameters documentation for guile
@ 2011-12-23 15:46 Ian Price
  2011-12-31  7:44 ` Eli Barzilay
  0 siblings, 1 reply; 11+ messages in thread
From: Ian Price @ 2011-12-23 15:46 UTC (permalink / raw)
  To: Guile Mailing List; +Cc: Eli Barzilay


Hello guilers,
I've taken the liberty of writing documentation for the syntax
parameters that were added to master a short while back. Comments kindly
requested. It is in org mode format, as I do not know texinfo at this
moment, but I will look into that shortly. It is also missing an
example, but I have to go and buy one last Christmas present, and will
do it this evening :).

Eli,
I'd especially appreciate it if you could clear up any misconceptions I
may have, or may be unintentionally imparting on others.

* Syntax Parameters

Syntax parameters[fn:1] are a mechanism for rebinding a macro definition
within the dynamic extent of a macro expansion. It provides a
convenient solution to one of the most common types of unhygienic
macro: those that introduce a special binding each time the macro is
used. Examples include an 'if' form that binds the result of the test
to an 'it' binding, or class macros that introduce a special 'self'
binding.

With syntax parameters, instead of introducing the binding
unhygienically each time, we instead create one binding for the
keyword, which we can then adjust later when we want the keyword to
have a different meaning. As no new bindings are introduced hygiene is
preserved. This is similar to the dynamic binding mechanisms we have
at run-time like parameters[fn:2] or fluids[fn:3].

** define-syntax-parameter keyword transformer [syntax]
Binds keyword to the value obtained by evaluating transformer as a
syntax-parameter. The transformer provides the default expansion for
the syntax parameter, and in the absence of syntax-parameterize, is
functionally equivalent to define-syntax.

** syntax-parameterize ((keyword transformer) ...) exp ... [syntax]
(note, each keyword must be bound to a syntax-parameter 

Adjusts each of the keywords to use the value obtained by evaluating
their respective transformer, in the expansion of the exp forms. It
differs from let-syntax, in that the binding is not shadowed, but
adjusted, and so uses of the keyword in the expansion of exp forms use
the new transformers.

** TODO example
if it, loop escape?, class?

* Footnotes
[fn:1] Eli Barzilay, Ryan Culpepper and Matthew Flatt. Keeping it
Clean with Syntax Parameters. In Proc. Workshop on Scheme and
Functional Programming, October 2011.

[fn:2] Marc Feeley. SRFI 39: Parameter objects, 2003.
http://srfi.schemers.org/srfi-39/.

[fn:3] https://www.gnu.org/software/guile/manual/guile.html#Fluids-and-Dynamic-States

-- 
Ian Price

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-01-08 13:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-23 15:46 Syntax Parameters documentation for guile Ian Price
2011-12-31  7:44 ` Eli Barzilay
2012-01-03 23:04   ` Ian Price
2012-01-04  0:33     ` Eli Barzilay
2012-01-06 18:47       ` Andy Wingo
2012-01-07  2:05         ` Ian Price
2012-01-07 17:37           ` Ian Price
2012-01-08  0:06             ` Andy Wingo
2012-01-08  2:39               ` Ian Price
2012-01-08 13:47                 ` Andy Wingo
2012-01-07  2:30         ` Eli Barzilay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).