Can’t require pollen/setup for syntax
Under Racket BC 7.7/Pollen 3.1.2526.1362, running this in a file saved as pollen.rkt:
#lang racket
(require (for-syntax pollen/setup))
Produces this error:
pollen/setup: defective `setup` submodule in "/Users/joel/Documents/code/sandbox/pollen.rkt"
pollen/setup: defective `setup` submodule in "/Users/joel/Documents/code/sandbox/pollen.rkt"
standard-module-name-resolver: cycle in loading
at path: /Users/joel/Documents/code/sandbox/pollen.rkt
paths:
/Users/joel/Documents/code/sandbox/pollen.rkt
This used to work, and doesn’t anymore. But I actually can’t figure out why it used to work.
As with #228, I think this is another error that was formerly suppressed, now revealed. Whenever pollen/setup is loaded, it needs to resolve certain values by looking inside pollen.rkt. So off the top of my head, it seems like what you’re trying to do should cause an error, because indeed it is a cycle in loading.
Still — what are you trying to accomplish by doing (require (for-syntax pollen/setup))? Maybe there’s a workaround. Or maybe the failure should be allowed in this case.
Still — what are you trying to accomplish by doing (require (for-syntax pollen/setup))?
I’ve been doing this in support of a macro for defining tag functions that branch to other functions automatically depending on current-poly-target. (The macro itself references setup:poly-targets.)
As with #228, I think this is another error that was formerly suppressed, now revealed. Whenever pollen/setup is loaded, it needs to resolve certain values by looking inside pollen.rkt. So off the top of my head, it seems like what you’re trying to do should cause an error, because indeed it is a cycle in loading.
This is what I thought, too. The weird thing is though, I am pretty sure the macro used to work as expected: if I changed (define poly-targets '(html)) to (define poly-targets '(html pdf)) inside my pollen.rkt setup module, I would start getting errors about pdf-tagname being an unbound identifier (because I hadn’t written those functions yet). If in older versions of Pollen there was an exception being suppressed, wouldn't it fall back on the default value and never include 'pdf in setup:poly-targets?
When I reset to commit 67c0c95422857d1d0be7785d97426dfd7e439504 (before pollen/setup became more strict) and run this pollen.rkt:
#lang racket
(require (for-syntax pollen/setup))
(begin-for-syntax
(println (setup:poly-targets)))
(module setup racket/base
(provide (all-defined-out))
(define poly-targets '(html pdf txt)))
The result I get is '(html) (the default value) not '(html pdf txt).
It does seem in principle like you might end up having to say “you just can’t use macros in pollen.rkt that depend on pollen/setup in phase 1”. If that were the case, it would be a mild bummer. Maybe the workaround in this case would be just to define the list of output formats outside my setup module, or define it in two separate places and keep them in sync manually.
Right: you could define poly-targets in an external file, let’s say "exts.rkt":
#lang racket
(provide (all-defined-out))
(define poly-targets '(html pdf txt))
Then in your "pollen.rkt", you could import it twice, making the value available in both places:
#lang racket
(require pollen/setup (for-syntax "exts.rkt"))
(module setup racket/base
(provide (all-defined-out))
(require (prefix-in ext: "exts.rkt"))
(define poly-targets ext:poly-targets))
Thereby breaking the loading cycle.
Thanks, I will take that route!
I think this means the fourth pollen tutorial (on poly output targets) is currently broken.
#lang racket/base
(require racket/date txexpr pollen/setup)
(provide (all-defined-out))
(module setup racket/base
(provide (all-defined-out))
(define poly-targets '(html txt ltx)))
When I paste that as-is into Dr Racket, it gives the defective setup submodule error.
That file shouldn’t produce an error (and doesn’t, for me). Try deleting any neighboring compiled directories to make sure Racket isn’t getting confused.
That file shouldn’t produce an error (and doesn’t, for me). Try deleting any neighboring
compileddirectories to make sure Racket isn’t getting confused.
Hmmm, well you're right, I'm having no problem re-testing it today. I'm not sure what's changed, but it could well be that I've removed compiled directories which has fixed it.
Thank you!