Can’t require pollen/setup for syntax #229

Closed
opened 5 years ago by otherjoel · 10 comments
otherjoel commented 5 years ago (Migrated from github.com)

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.

Under Racket BC 7.7/Pollen 3.1.2526.1362, running this in a file saved as `pollen.rkt`: ```racket #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.
mbutterick commented 5 years ago (Migrated from github.com)

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.

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.
otherjoel commented 5 years ago (Migrated from github.com)

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.)

> Still — what are you trying to accomplish by doing (require (for-syntax pollen/setup))? I’ve been doing this in support of [a macro][1] for defining tag functions that branch to other functions automatically depending on `current-poly-target`. (The macro itself references `setup:poly-targets`.) [1]: https://thelocalyarn.com/code/artifact?udc=1&ln=64-77&name=8f4969ddcf0bdf33
otherjoel commented 5 years ago (Migrated from github.com)

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?

> 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`?
mbutterick commented 5 years ago (Migrated from github.com)

When I reset to commit 67c0c95422 (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).

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)`.
otherjoel commented 5 years ago (Migrated from github.com)

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.

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.
mbutterick commented 5 years ago (Migrated from github.com)

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.

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.
otherjoel commented 5 years ago (Migrated from github.com)

Thanks, I will take that route!

Thanks, I will take that route!
oldmankit commented 3 years ago (Migrated from github.com)

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.

I think this means the [fourth pollen tutorial](https://docs.racket-lang.org/pollen/fourth-tutorial.html) (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.
mbutterick commented 3 years ago (Migrated from github.com)

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 `compiled` directories to make sure Racket isn’t getting confused.
oldmankit commented 3 years ago (Migrated from github.com)

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.

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!

> 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. 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!
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#229
Loading…
There is no content yet.