davidtaylor
2017-8-8 14:17:58

@davidtaylor has joined the channel


notjack
2017-8-8 19:57:55

did the installer script for the current snapshot change in any way recently? context: https://github.com/racket/rackunit/issues/68


samth
2017-8-8 19:58:44

when did it change? and did it affect any other travis jobs (such as TR)?


notjack
2017-8-8 19:59:18

I’m guessing it changed yesterday, as it was last night’s nightly travis run that broke


notjack
2017-8-8 19:59:35

rerunning the build does not fix the issue, it fails in the same way


notjack
2017-8-8 20:00:04

haven’t checked any other repos yet


lexi.lambda
2017-8-8 20:27:44

I want to write a defdata scribble form for documenting Hackett algebraic datatypes. I’ve peeked at the source for defstruct, but it is pretty complicated! Is there any simpler way to define a custom documentation form? If not, is there something that could help me understand how to write one myself?


lexi.lambda
2017-8-8 20:28:17

I’ll also want to do the same thing for typeclasses.



stamourv
2017-8-8 20:29:16

Or defthing.


lexi.lambda
2017-8-8 20:32:21

@stamourv Thanks, that’s helpful. I guess copying all that stuff out of scribble/private is currently the only way to do that? :/


stamourv
2017-8-8 20:33:48

I think that’s the best way @robby found. ;)


robby
2017-8-8 20:34:29

its just work! :slightly_smiling_face:


robby
2017-8-8 20:34:49

“just a small matter of programming” is the phrase that comes to mind.


lexi.lambda
2017-8-8 20:36:35

I’ll be the first to admit I find the scribble internals a little scary :)


lexi.lambda
2017-8-8 21:46:09

@robby what is the purpose of the use of datum-intern-literal in *defls?


lexi.lambda
2017-8-8 23:36:51

typesetting examples in my documentation is making me realize that some Hackett forms are totally broken at the top level :(


lexi.lambda
2017-8-8 23:39:25

when evaluating something at the top level with the shape (begin (define-syntax foo ....) (some-macro ....)), is it possible to arrange for foo to have been bound by the time some-macro is expanded?


lexi.lambda
2017-8-8 23:41:43

though, actually, it seems like maybe that does normally happen. so I’m not sure why my tangled macro code is seeing otherwise. :(


lexi.lambda
2017-8-8 23:58:34

Ah… the real issue is that I’m expanding to something like this: (begin (define-for-syntax a ....) (define-syntax (b stx) .... a ....)) …and when b is expanded, a’s use produces a use-before-definition error for some reason.


lexi.lambda
2017-8-8 23:59:49

I have no idea why this is the case, much less how to work around it. @mflatt or @samth, can either of you give me some advice here?


lexi.lambda
2017-8-9 00:00:39

This program reproduces the error: #lang racket (require syntax/parse/define) (define-simple-macro (f m:id) (begin (define-for-syntax x "prop value") (define-syntax (m stx) x #'(void)))) > (f m) > (m) x: undefined; cannot reference an identifier before its definition phase: 1


samth
2017-8-9 00:03:19

Short answer: the top level is hopeless


lexi.lambda
2017-8-9 00:03:42

I know that, but I would like users to be able to define datatypes in the REPL. :)


samth
2017-8-9 00:04:38

I think one of Matthew’s posts in my gist on that topic discussed this issue but I’m not certain


lexi.lambda
2017-8-9 00:04:49

lemme dig that gist up, then…


mflatt
2017-8-9 00:05:52

I think the long answer is to use the (define-syntaxes (x) (values)) hack - in this case under begin-for-syntax


mflatt
2017-8-9 00:06:15

But only when expanding in a top-level context


lexi.lambda
2017-8-9 00:07:23

I see that hack is alluded to here… http://lists.racket-lang.org/dev/archive/2009-October/001381.html …but I don’t really understand what it does.


lexi.lambda
2017-8-9 00:09:27

I guess it’s documented in the reference under “Macro-Introduced Bindings”, but some of this makes my head spin.


lexi.lambda
2017-8-9 00:12:09

Hmm… that hack doesn’t actually work here, though, anyway, unless I’m doing it wrong. This program produces the same error: (define-simple-macro (f m:id) (begin (define-for-syntax x "prop value") (define-syntaxes [x] (values)) (define-syntax (m stx) x #'(void))))


lexi.lambda
2017-8-9 00:13:36

The thing that makes me think this is something different is that the issue is not an unbound identifier error, merely a use-before-definition error.


lexi.lambda
2017-8-9 00:14:06

The empty-(values) trick seems to be for a forward declaration, but I don’t need a forward declaration here.


lexi.lambda
2017-8-9 00:22:19

I realized I was doing the forward declaration wrong, but doing it right doesn’t change anything, as far as I can tell. :p


robby
2017-8-9 02:37:26

@lexi.lambda just looked at that code and I have no idea!


robby
2017-8-9 02:39:22

I guess there must an eq or an eq hash somewhere. sorry I’m of no use


lexi.lambda
2017-8-9 02:41:48

That’s fine! I removed it and it seems to work okay, so I’m just hoping there isn’t some important reason that I’ll find out about later.


robby
2017-8-9 02:46:02

I think it was only performance. This appears to be the commit where it was introduced:



robby
2017-8-9 02:46:27

Of course, something somewhere may accidentally depend on eq-ness. (One of the reasons I don’t like eq!)


mflatt
2017-8-9 03:11:57

@lexi.lambda I think you’re seeing something different than the problem that can be solved with (define-syntaxes [x] (values)). Your example only fails for me in DrRacket if I haven’t saved the module to a file, which maybe has to do with how DrRacket treats the module; more importantly, I don’t see the problem when using the new expander implementation. I think it’s yet another bug in the old expander’s implementation of module->namespace.


lexi.lambda
2017-8-9 03:13:28

Ah, hmm, perhaps a DrRacket issue then. That means the actual issue in my code is probably something else, and that test case was oversimplified.


lexi.lambda
2017-8-9 03:14:33

Thank you for looking into it. I’ll try digging into it some more.


mflatt
2017-8-9 03:22:14

My guess is that DrRacket is sometimes masking the bug, and the problem you’re seeing is in module->namespace


lexi.lambda
2017-8-9 03:22:48

How would the old expander be relevant here? I’m running a very new version of Racket.


mflatt
2017-8-9 03:25:24

I guess there are too many “old” expanders now. To me, the current release and main Racket development branch are an old expander (i.e,. the one in C); the new expander (in Racket) is in the racket7 repo


lexi.lambda
2017-8-9 03:27:27

Oh, I see. I am evidently not keeping up with the pace of innovation in the Racket ecosystem. :)


mflatt
2017-8-9 03:28:37

I’ll look into fixing the problem tomorrow


lexi.lambda
2017-8-9 03:29:51

It’s not a big deal if that is, in fact, a red herring. I’ll try and do some more diligent testing to see if it’s actually related to the problem in my real code or not.


mflatt
2017-8-9 03:30:21

Does your real problem involve top-level evaluation?


lexi.lambda
2017-8-9 03:31:12

It does—I’m trying to get something working in the REPL, mostly so that I can use it with scribble/example.


mflatt
2017-8-9 03:34:32

Likely related, then; it seems clearly to be a bug to fix, in any case


lexi.lambda
2017-8-9 03:36:09

Alright, well, if you get around to fixing it before I figure out what’s wrong with my code, I can let you know if it was the culprit or not.


lexi.lambda
2017-8-9 04:35:28

@mflatt I’m seeing behavior I don’t understand, but I am also having trouble reproducing it in a self-contained test case. I’ve inserted some printfs in my code, and I’m seeing (local-expand stx 'expression '()) return stx unchanged, where stx is some identifier. However, (identifier-binding stx (syntax-local-context) #t) returns #f. This only happens at the top level; when the same code is encountered while expanding a module, (identifier-binding stx) is non-#f, and local-expand actually expands to something.

I’m very confused by this behavior. Is there some situation in which local-expand can pass an identifier through unchanged even though identifier-binding seems to claim it is unbound? I would expect an unbound identifier error in that scenario, but I also don’t know how the top level treats local-expand.


lexi.lambda
2017-8-9 05:56:32

Alright, I think I hunted down what was causing that strange error. I think, ultimately, it was user error, though I still don’t understand why local-expand was behaving that way. Anyway, I’ve run into a different issue, and this program is even smaller. Unfortunately, this fails to compile: #lang racket (require (for-syntax (for-syntax racket/base) racket/syntax syntax/transformer) syntax/parse/define) (define-simple-macro (mac id:id) #:with val (generate-temporary #'id) (begin (begin-for-syntax (define-syntaxes [val] (values)) (define val #'"something")) (define-syntax id (make-variable-like-transformer val)))) (begin-for-syntax (local-expand #'(mac foo) 'top-level '())) This produces this error: foo1: unbound identifier in the transformer environment; also, no #%top syntax transformer is bound in: foo1 I tried the define-syntaxes hack, but it doesn’t seem to help here.


lexi.lambda
2017-8-9 05:59:04

I also tried splitting up the definitions in mac into multiple macros to try and delay expansion, but that didn’t accomplish anything. I’m pretty lost about how to make this sort of macro cooperate with the top level.