prevent loading cycle with `pollen/mode`

pull/105/head
Matthew Butterick 9 years ago
parent da2d9fd40d
commit 0cc56ffd3a

@ -43,7 +43,7 @@ so that everything will work correctly in 6.0.
[else (other-get-info key default)]))))
(module* reader racket/base
(require syntax/module-reader pollen/world
(require syntax/module-reader
(only-in (submod ".." at-reader) make-at-readtable))
(provide (rename-out [at-read read]
@ -54,7 +54,7 @@ so that everything will work correctly in 6.0.
(λ args
(parameterize ([current-readtable (make-at-readtable #:datum-readtable 'dynamic
#:command-readtable 'dynamic
#:command-char (world:current-command-char))])
#:command-char (dynamic-require 'pollen/world 'world:command-char))])
(apply p args))))
(define-values (at-read at-read-syntax at-get-info)

@ -931,14 +931,15 @@ Here, both @tt{(home-link)} and @tt{(home-link-pollen-mode)} will produce the sa
@terminal{'(a ((href "index.html")) "Click to go home")}
Of course, you can use @racketmodname[pollen/mode] in any Racket source file, not just @filepath{pollen.rkt}.
Keep in mind that @racketmodname[pollen/mode] is just a syntactic convenience. It doesn't change any of the underlying semantics of your Racket source file. Your Pollen-mode commands are being translated into Racket commands and compiled along with everything else.
@bold{Major caveat}: @racketmodname[pollen/mode] only works with Pollen's default command character, namely the lozenge (@litchar{◊}). If you've overridden this command character in your @filepath{pollen.rkt} file, your custom command character will work everywhere @italic{except} in @racketmodname[pollen/mode]. This limitation is necessary to prevent the intractable situation where @filepath{pollen.rkt} relies on @racketmodname[pollen/mode], but @racketmodname[pollen/mode] relies on a config setting in @filepath{pollen.rkt}.
Also keep in mind that @racketmodname[pollen/mode] is just a syntactic convenience. It doesn't change any of the underlying semantics of your Racket source file. Your Pollen-mode commands are being translated into Racket commands and compiled along with everything else.
Another good way to use Pollen-mode commands in Racket is for unit tests with @racketmodname[rackunit]. With @racketmodname[pollen/mode], you can write your unit tests in Pollen mode or Racket mode (or mix them).
@margin-note{Unit tests are little one-line tests you put into your code to verify it does what you expect. You do this with the @racketmodname[rackunit] library, which is beloved by all Racket programmers. For more, see @secref["quick-start" #:doc '(lib "rackunit/scribblings/rackunit.scrbl")].}
@margin-note{Unit tests are little one-line tests you put into your code to verify that it does what you expect. You make these with the @racketmodname[rackunit] library, which is beloved by all Racket programmers. For more, see @secref["quick-start" #:doc '(lib "rackunit/scribblings/rackunit.scrbl")].}
@fileblock["pollen.rkt" @codeblock|{
#lang pollen/mode racket/base

@ -4,7 +4,9 @@
;; This file is named .foo so that `raco test` doesn't try to run it automatically.
;; (the `test-omit` flag doesn't work in 6.0)
;; pollen/mode only works with default ◊ command char, even though it's overridden in pollen.rkt here
(define (proc)
(apply string-join (string-split ∆string-append{foo bar zam}) ∆'{X}))
(apply string-join (string-split ◊string-append{foo bar zam}) ◊'{X}))
(provide proc)
Loading…
Cancel
Save