Standard version of HTML Tidy for SRFI documents
Lassi Kortela
(11 Sep 2020 05:41 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Arthur A. Gleckler
(11 Sep 2020 15:52 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Marc Nieper-Wißkirchen
(11 Sep 2020 16:00 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Arthur A. Gleckler
(11 Sep 2020 18:45 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Arthur A. Gleckler
(12 Sep 2020 02:00 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Marc Nieper-Wißkirchen
(12 Sep 2020 07:45 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Arthur A. Gleckler
(12 Sep 2020 13:45 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Lassi Kortela
(12 Sep 2020 13:47 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Arthur A. Gleckler
(12 Sep 2020 15:21 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Marc Nieper-Wißkirchen
(12 Sep 2020 16:45 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Arthur A. Gleckler
(12 Sep 2020 18:36 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents
Marc Nieper-Wißkirchen
(12 Sep 2020 19:12 UTC)
|
Re: Standard version of HTML Tidy for SRFI documents Marc Nieper-Wißkirchen (12 Sep 2020 19:47 UTC)
|
Arthur, I just added the section <h3>Examples</h3> below. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>SRFI ###: Namespaces for Scheme Macro Systems</title> <link href="/favicon.png" rel="icon" sizes="192x192" type="image/png"> <link rel="stylesheet" href="https://srfi.schemers.org/srfi.css" type="text/css"> <meta name="viewport" content="width=device-width, initial-scale=1"></head> <body> <h1><a href="https://srfi.schemers.org/"><img class="srfi-logo" src="https://srfi.schemers.org/srfi-logo.svg" alt="SRFI logo" /></a>###: Namespaces for Scheme Macro Systems</h1> <p>by Marc Nieper-Wißkirchen</p> <h2 id="status">Status</h2> <h2 id="abstract">Abstract</h2> <p>This SRFI defines library name spaces where common extensions of the <code>syntax-rules</code> macro facility can be located and which can be tested against in <code>cond-expand</code> forms. </p> <h2 id="issues">Issues</h2> <h2 id="rationale">Rationale</h2> <p>Various Scheme implementations define extensions to the <code>syntax-rules</code> macro facility that can be found in <a href="https://small.r7rs.org/">R7RS</a>, for example explicit renaming macros, <code>syntax-case</code>, identifier macros or variable transformers. While different implementation of the same extension will usually be compatible, they cannot usually be found under the same namespace.</p> <p>This SRFI therefore defines a number of standard libraries under which supporting implementations export the identifiers of those <code>syntax-rules</code> extensions they implement so that portable code can be written without loading implementation specific libraries. </p> <p>It's not the purpose of this SRFI to define the meaning of these identifiers as these are documented elsewhere by the various extensions to <code>syntax-rules</code>. </p> <h3>Example</h3> <p>Let us assume that we want to write a library that exports the macro <code>skip</code>. The arguments of the <code>skip</code> macro are a non-negative exact integer <em>n</em> and a number of body forms. A <code>skip</code> macro is evaluated by dropping the first <em>n</em> n body forms and evaluating the rest as a body.</p> <p>Writing such a macro is not possible with <code>syntax-rules</code>, but it is possible both with <code>er-macro-transformer</code> and <code>syntax-case</code>. With the following code, the library works on all implementations that support at least <code>er-macro-transformer</code> or <code>syntax-case</code>, and this SRFI, of course.</p> <pre><small> (define-library (skip) (export skip) (import (scheme base)) (cond-expand ((library (srfi ### syntax-case)) (import (srfi ### syntax-case)) (begin (define-syntax skip (lambda (x) (syntax-case x () ((_ n b ...) (with-syntax (((b ...) (list-tail (syntax->datum #'n) #'(b ...)))) #'(letrec* () b ...)))))))) ((library (srfi ### er-macro-transformer)) (import (srfi ### er-macro-transformer)) (begin (define-syntax skip (er-macro-transformer (lambda (e r c) `(,(r 'letrec*) () ,@(list-tail (cddr e) (cadr e))))))))))</small></pre> <h2 id="specification">Specification</h2> <h3>Libraries</h3> <p>An implementation does not have to provide all the libraries below. If it provides a library, it has to provide it as a whole and not just a subset of it.</p> <p><code>(srfi ### er-macro-transformer)</code></p> <p>The <code>er-macro-transformer</code> facility as documented by William Clinger in <cite><a href="http://mumble.net/~campbell/tmp/clinger91exrename.pdf">Hygienic Macros Through Explicit Renaming</a></cite>. Exports the identifiers</p> <ul> <li><code>er-macro-transformer</code></li> <li><code>identifier?</code></li> </ul> <p><code>(srfi ### syntax-case)</code></p> <p>The <code>syntax-case</code> system as documented in the <a href="http://www.r6rs.org">R6RS</a>. Exports the identifiers</p> <ul> <li><code>syntax-case</code></li> <li><code>syntax</code></li> <li><code>identifier?</code></li> <li><code>bound-identifier=?</code></li> <li><code>free-identifier=?</code></li> <li><code>syntax->datum</code></li> <li><code>datum->syntax</code></li> <li><code>generate-temporaries</code></li> <li><code>with-syntax</code></li> <li><code>quasisyntax</code></li> <li><code>unsyntax</code></li> <li><code>unsyntax-splicing</code></li> <li><code>syntax-violation</code></li> </ul> <p><code>(srfi ### identifier-syntax)</code></p> <p>The <code>identifier-syntax</code> transformer documented in the R6RS. If this library is present, a macro transformer will be invoked if its associated keyword is referenced as an expression. The more general form of <code>identifier-syntax</code> permitting the transformer to determine what happens when <code>set!</code> is used, may not be available unless the <code>(srfi ### variable-transformer)</code> library is present as well. Exports the identifier</p> <ul> <li><code>identifier-syntax</code></li> </ul> <p><code>(srfi ### variable-transformer)</code></p> <p>The <em>variable transformer</em> facility as documented in the R6RS. Exports the identifier</p> <ul> <li><code>make-variable-transformer</code></li> </ul> <p><code>(srfi ### with-ellipsis)</code></p> <p>The <code>with-ellipsis</code> special form <a href="https://www.gnu.org/software/guile/manual/html_node/Syntax-Case.html#Custom-Ellipsis-Identifiers-for-syntax_002dcase-Macros">documented by Guile</a>, which allows to express <code>syntax-rules</code> with its <a href="https://srfi.schemers.org/srfi-46/srfi-46.html">SRFI 46</a> extensions in terms of <code>syntax-case</code>. Exports the identifier</p> <ul> <li><code>with-ellipsis</code></li> </ul> <p><code>(srfi ### syntax-parameter)</code></p> <p>Syntax parameters as documented by <a href="https://srfi.schemers.org/srfi-139/srfi-139.html">SRFI 139</a>. Exports the identifiers</p> <ul> <li><code>define-syntax-parameter</code></li> <li><code>syntax-parameterize</code></li> </ul> <h2 id="implementation">Implementation</h2> <p>The implementation is necessarily distinct for every Scheme implementation but in any case almost trivial. The identifiers of each supported extension of <code>syntax-rules</code> just have to be re-exported in the standardized libraries defined above. </p> <h2 id="acknowledgements">Acknowledgements</h2> <p>Thanks to the inventors and implementers of the various extensions to the <code>syntax-rules</code> macro facility that are covered by this SRFI. </p> <h2 id="copyright">Copyright</h2> <p>© 2020 Marc Nieper-Wißkirchen.</p> <p> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p> <p> The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.</p> <p> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p> <hr> <address>Editor: <a href="mailto:srfi-editors+at+srfi+dot+schemers+dot+org">Arthur A. Gleckler</a></address></body></html> Am Sa., 12. Sept. 2020 um 21:11 Uhr schrieb Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de>: > > Sure. Give me 15 minutes. The children are in bed now. :) > > Am Sa., 12. Sept. 2020 um 20:36 Uhr schrieb Arthur A. Gleckler > <xxxxxx@speechcode.com>: > > > > On Sat, Sep 12, 2020 at 9:45 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote: > >> > >> Of course, I had to try out your validator, so I wrote a short SRFI, > >> which I had in the back of my mind for some time now. It just > >> standardized libraries where various extensions of the syntax-rules > >> macro facility can be found by application code. You just have to > >> replace "###" with the next free SRFI number. :) > > > > > > Looks great. I'm almost finished preparing it. Would you please add one short example first? That should make the motivation immediately clear.