soegaard2
2019-9-30 15:23:47

This error is easy to get: module: identifier already required ; at: foo ; in: "bar.rkt" It usually means that we are requiring two modules that both provide a binding foo. But which module is “the other one”? Is there a way to get that information?


ben
2019-9-30 15:37:56

syntax-sloc has some counting tools, but could use more https://github.com/alexknauth/syntax-sloc


samth
2019-9-30 16:17:49

I don’t know of one


samth
2019-9-30 16:20:33

but adding it to the error message seems pretty reasonable; the code is here: https://github.com/racket/racket/blob/master/racket/src/expander/expand/require+provide.rkt#L321


sorawee
2019-9-30 19:01:25

I have a code that looks like this:

(current-compile (let ([orig-compile (current-compile)])
                   (lambda (stx im?)
                     (define compiled (orig-compile stx im?))
                     (when (... (syntax-source stx))
                       (with-output-to-file (syntax-source stx) #:exists 'replace
                         (thunk (display compiled))))
                     compiled)))

(dynamic-require ...)

This works fine on a single Racket file, but when the required file has dependencies, I get this message:

hash-ref: no value found for key
  key: 'data
  context...:
   compiled-module->dh+h+data-instance+declaration-instance
   eval-module8
   standard-module-name-resolver
   module-path-index-resolve
   [repeats 1 more time]
   module-declared?

Do you know how to fix the problem?


sorawee
2019-9-30 19:01:36

@mflatt @samth


kevinforrestconnors
2019-9-30 19:07:40
file: dataset.rkt

#lang racket

(module dataset racket

  (provide lorem-ipsum)

  (define lorem-ipsum (list "a" "b" "c"))

  )

file: main.rkt

#lang racket


(require "dataset.rkt")

lorem-ipsum


kevinforrestconnors
2019-9-30 19:07:44

why doesn’t this work?


kevinforrestconnors
2019-9-30 19:07:50

lorem-ipsum: unbound identifier in: lorem-ipsum


notjack
2019-9-30 19:09:39

@kevinforrestconnors The lorem-ipsum binding isn’t being provided by the dataset.rkt module, it’s being provided by a submodule of the dataset.rkt module. You can require it like this: (require (submod "lorem-ipsum" dataset))


notjack
2019-9-30 19:10:27

Putting code inside a (module foo ...) form in a file puts it in a submodule named foo. The file itself is already a whole module on its own, assuming you’re using #lang racket or #lang racket/base.


kevinforrestconnors
2019-9-30 19:10:49

ohh


kevinforrestconnors
2019-9-30 19:11:22

so if I don’t want to require a submodule, I can just write: (provide lorem-ipsum) (define lorem-ipsum (list "Lorem ipsum dolor"))


kevinforrestconnors
2019-9-30 19:11:29

it works!


kevinforrestconnors
2019-9-30 19:11:30

thank you


soegaard2
2019-9-30 19:12:33

Does anyone have an example for hsjunnesson ? He wants to embed Racket in a game. https://www.reddit.com/r/Racket/comments/dbbv6a/some_guidance_in_setting_up_racket_as_a_game/


notjack
2019-9-30 19:22:55

@kevinforrestconnors happy to help!


samth
2019-9-30 19:24:46

That really looks like a bug


samth
2019-9-30 19:27:08

The relevant code is on line 359 of racket/src/expander/eval/module.rkt


sorawee
2019-9-30 19:31:36

Thanks! Is there any workaround meanwhile?


samth
2019-9-30 19:32:02

I don’t know what’s going on so I can’t recommend anything


sorawee
2019-9-30 19:45:36

I mean, what I really want to do is to perform a syntax transformation (at the core form level), and save it as a file so that I can run it later. I can’t just write (syntax->datum stx) because the lexical context is lost and I would get unbound id when I attempt to run the file. So I try this approach instead. But if this approach doesn’t work, do you have any other idea?


samth
2019-9-30 19:49:16

I think you’re overwriting a file that contains a linklet bundle with just a single modules’ compilation, but really I’m just guessing


soegaard2
2019-9-30 20:41:18

Hi All. Racket Stories is now live and will stay live. Hopefully everything works. Things to try: Create a user. Submit a new link. Go to your profile and link your Github.


samth
2019-9-30 20:46:35

What’s the URL?


soegaard2
2019-9-30 20:46:50

soegaard2
2019-9-30 20:47:10

(url? small detail…)


mflatt
2019-9-30 20:50:01

@sorawee The error should be better, but I think the solution is to call orig-compile always with #f as the second argument, because you want to use the result in a way other than immediate evaluation. (Specifically, you want to write it.)


sorawee
2019-9-30 20:50:19

Ah, thanks!


aymano.osman
2019-9-30 21:16:01

Already creating value for me. I appreciate the Oculus and Papers We Love links, thanks!