kellysmith12.21
2020-7-31 11:22:05

Are the attributes of syntax classes similar to the attributes of Knuth & Wegner’s attribute grammars (https://en.wikipedia.org/wiki/Attribute_grammar)?


soegaard2
2020-7-31 12:24:32

@kellysmith12.21 Yes.


kellysmith12.21
2020-7-31 13:13:47

Is there a paper that formally defines Racket’s syntax/parse and syntax class facilities?




soegaard2
2020-7-31 13:16:40

(there is also the Reference of course)


kellysmith12.21
2020-7-31 13:24:29

Thanks!


ego
2020-7-31 18:49:11

I hope this is a meaningful question, but how do I see a full stack trace in DrRacket? I got this error just now: . . ../../Applications/Racket v7.7/share/pkgs/datalog/stx.rkt:55:10: for-each: contract violation expected: list? given: #<void> …and that’s all it shows

if I open the file datalog/stx.rkt and look at line 55 I don’t see a for-each as named in the error, just:


ego
2020-7-31 18:49:13

(eval-statement (datalog-stmt stmt)))


ego
2020-7-31 18:50:18

is there something like a debugger (eg pdb in python)?


sorawee
2020-7-31 18:52:22

If you are using DrRacket, you should have these icons when error appears


sorawee
2020-7-31 18:52:30

sorawee
2020-7-31 18:52:45

Click the left icon. That will show a detailed “stacktrace”


sorawee
2020-7-31 18:53:06

Also make sure that it says: “Language: racket, with debugging”


sorawee
2020-7-31 18:54:04

if it simply says “Language: racket” (without “with debugging”), you need to adjust a setting via the language menu.


ego
2020-7-31 19:03:48

thanks, that now shows


ego
2020-7-31 19:04:53

how do I get deeper in?


sorawee
2020-7-31 19:43:48

That’s as detailed as it can provide you, assuming that you have “with debugging” on.


sorawee
2020-7-31 19:44:04

Perhaps you can say what do you expect to happen


ego
2020-7-31 19:44:11

yes it’s “with debugging”


ego
2020-7-31 19:45:58

I’m used to a debugger where I can go up and down the stack(?) and inspect values at each level - is there anything like that? here I think I’m still not seeing the actual code that raised the error, just some outer layer


soegaard2
2020-7-31 19:46:35

Is this #lang racket or datalog?


ego
2020-7-31 19:47:27

its #lang racket and I did the datalog stuff in racket syntax


sorawee
2020-7-31 19:47:56

Can you provide me program that you are working on?


sorawee
2020-7-31 19:48:39

I actually just have a discussion with people on how to improve this stack trace a few days ago (though I don’t think that improvement would help your situation)


ego
2020-7-31 19:49:02

for context… I am passing an impersonated hash into datalog as the theory for sure the problem is in my impersonator implementation in this case the code is probably simple enough for me to solve by bisect it/stare hard at the code/trial and error

but it’s more of a general question about how to debug things in Racket


sorawee
2020-7-31 19:50:52

Quick info for you: you can’t “inspect values at each level” because Racket is free to eliminate any bindings that is no longer needed.


sorawee
2020-7-31 19:51:19

But if the stack trace is not helpful, that should be fixed


sorawee
2020-7-31 19:51:41

So if you can provide an example of a program that causes this problem, that would be great.


sorawee
2020-7-31 19:52:55

Ah


sorawee
2020-7-31 19:52:58

I think what happens here


sorawee
2020-7-31 19:53:11

is that errortrace couldn’t instrument code in datalog library


sorawee
2020-7-31 19:53:20

because datalog is already compiled to bytecode


sorawee
2020-7-31 19:53:38

I could be wrong though.


ego
2020-7-31 20:18:46

thanks, I don’t totally understand the first part but I will try to read more about it

I’ll put my code in a gist, there’s not much to it at the moment

if I click the “Builtins” tab I get some deeper parts of the stack trace (I think…) but it has highlighted some very large chunks of code like datalog/runtime.rkt: 73:0 and that’s the whole (define (prove thy q)...) function, about 75 lines


sorawee
2020-7-31 20:21:43

Also, I’m not totally free right now. Will try to find some free time tonight to look into this.


ego
2020-7-31 20:28:22

no worries, I will research elsewhere as well, thanks for your help

here is the gist in case it helps re better stack traces: https://gist.github.com/anentropic/976121f288e7f0a2e91e8de082f44096 (see comment at the bottom)


noahstorym
2020-8-1 02:20:22

I want to write a function my-apply which behaves like apply in typed/racket, so I query the type of apply: > (:print-type apply) (All (a b) (-> (-> a * b) (Listof a) b)) It seems that apply only accepts 2 arguments, I’m a little confused. Do I miss something?


sorawee
2020-8-1 02:23:12

It used to be the case that apply accepts only two arguments I think?


sorawee
2020-8-1 02:23:20

At least that’s how it was in some versions of Scheme


noahstorym
2020-8-1 02:42:06

Thanks, I don’t know how to write my-apply , can you give me some advice?


samth
2020-8-1 02:42:21

apply is a little weird — if you use it as a higher-order function it has a less-useful type than if you use it directly


samth
2020-8-1 02:42:36

To write my-apply, you have to use apply.


noahstorym
2020-8-1 02:45:52

what should my-apply type look like? This is where I am confused.


samth
2020-8-1 02:48:08

Is this what you want: #lang typed/racket (: my-apply (All (a b) (-> (-> a * b) (Listof a) b))) (define (my-apply f l) (apply f l))


noahstorym
2020-8-1 02:49:49

Thanks, I hope my-apply can work like this: > (apply + 1 2 3 '(2)) - : Integer [more precisely: Positive-Integer] 8 > (my-apply + 1 2 3 '(2)) ; -> 8


samth
2020-8-1 02:53:08

Unfortunately you can’t describe that type in Typed Racket


noahstorym
2020-8-1 02:56:01

I understand now. Thank you.


samth
2020-8-1 02:58:33

We’ve actually thought about adding that capability to ->* but it’s a bunch of complexity for something not that useful outside of the type of apply.


samth
2020-8-1 03:01:48

noahstorym
2020-8-1 03:02:13

Thanks!


sorawee
2020-8-1 06:12:17

It looks like my diagnosis is wrong. DrRacket already instruments datalog library


sorawee
2020-8-1 06:13:51

Here’s an output from the errortrace in the command-line


sorawee
2020-8-1 06:13:53

for-each: contract violation expected: list? given: #<void> errortrace...: /Users/sorawee/git/racket/racket/share/pkgs/datalog/runtime.rkt:103:4: (for-each (lambda (clause) (define renamed (rename-clause clause)) (define selected (clause-head ....)) (cond ((....) ....))) (get thy (subgoal-question sg))) /Users/sorawee/git/racket/racket/share/pkgs/datalog/eval.rkt:37:5: (prove (current-theory) (query-question s)) /Users/sorawee/git/racket/racket/share/pkgs/datalog/stx.rkt:55:10: (idY21 lifted/18 (idY300 lifted/18 (list (bytes->path (....)) (quote ....) (....) ....) (idY127 lifted/18 (....) ....))) /Users/sorawee/git/racket/racket/share/pkgs/datalog/stx.rkt:53:9: (->substitutions (lambda (g1) (let-values (((g12) g1)) (let-values (....) ....))) (idY21 lifted/18 (idY300 lifted/18 (list ....) (....))))


sorawee
2020-8-1 06:14:30

so it shows that (subgoal-question sg) evaluates to (void)