yfangzhe
2019-11-23 10:12:22

It seems that it always needs some days to update documents every time after a new version of Racket released.


samth
2019-11-23 13:57:01

@mflatt said yesterday it would get updated this weekend


ryanc
2019-11-23 14:41:32

@willbanders The problem with your last bit of code is that you can’t use #:with inside of patterns like that; it gets interpreted as just a keyword to match literally, and the things after it are also just interpreted as patterns. That means syntax-parse thinks you have a pattern variable called l.v in addition to l:bound2 which I assume binds l.v as a nested attribute. That’s where the error is coming from.


ryanc
2019-11-23 14:43:00

Your second bit of code should work, but if it’s in another syntax class, you probably have to export the attributes explicitly. Here’s an example:

(define-syntax-class bound2 (pattern [v i])) (define-syntax-class thing #:attributes (l.v l.i) (pattern (_ (~optional l:bound2 #:defaults ([l.v #'1] [l.i #'2]))))) (syntax-parse #'(x [y z]) [t:thing #'t.l.v]) ;; => #'y (syntax-parse #'(x) [t:thing #'t.l.v]) ;; => #'1


willbanders
2019-11-23 17:24:04

@ryanc Yep, you’re exactly right that #:with was getting interpreted as input - figured that out eventually xD. Specifying the attributes is also something that allowed me to remove a lot of unnecessary #:with renaming. The rest of things I managed to piece together with the main help being (~bind) . Here’s the current result:

(define-splicing-syntax-class bounds #:attributes(l.v l.i u.v u.i) (pattern (~seq (~optional l:bound #:defaults([l.v #'null] [l.i #'null])) u:bound)) (pattern (~seq (~optional (~seq (~or (~seq #:incl (~bind [l.i #'#t])) (~seq #:excl (~bind [l.i #'#f]))) l:value) #:defaults([l.v #'null] [l.i #'null])) (~or (~seq #:incl (~bind [u.i #'#t])) (~seq #:excl (~bind [u.i #'#f])) (~seq (~bind [u.i #'l.i]))) u:value))))


willbanders
2019-11-23 17:24:55

Thanks a lot for your suggestions though, really helped me clean things up a bit. I’m sure there’s probably more though xD


soegaard2
2019-11-23 18:15:33

I am missing something obvious, but what? This doesn’t work:

#lang racket (require racket/place) (define p1 (place ch1 1)) (place-wait p1) (displayln "done")


dmitryhertz
2019-11-23 18:40:55

Hello colleagues! I’ve a question about subbytes efficiency, does it copy a byte-string or just return a pointer which tells from where to start/end?


soegaard2
2019-11-23 18:42:13

It allocates a new byte string and copies the old one over.


dmitryhertz
2019-11-23 18:42:40

Bad. Thank you!:+1:


sorawee
2019-11-23 18:57:22

Not sure if this is relevant. I’ve never used place myself:

> As part of the dynamic-require, the current module body is evaluated in the new place. The consequence of this second feature is that place should not appear immediately in a module or in a function that is called in a module’s top level; otherwise, invoking the module will invoke the same module in a new place, and so on, triggering a cascade of place creations that will soon exhaust memory.



soegaard2
2019-11-23 19:01:00

Yep. That’s it. Since I used (place ch 1) at the top-level, the dynamic-require will evaluate the same place expression, which will result in a new dynamic-require etc.


soegaard2
2019-11-23 19:06:34

Next question. Why does this program finish almost instantaneously? I was expecting to wait a minute before seeing any output:

#lang racket/base (require racket/place) (define (worker n) (sleep 60) (displayln n)) (define (start) (define p1 (place ch1 (worker 1))) (define p2 (place ch2 (worker 2))) (place-wait p1) (place-wait p2)) (start)


sorawee
2019-11-23 19:39:23

I can’t reproduce the behavior you described


sorawee
2019-11-23 19:40:47

As I understand, you should not (start) at the top-level, due to the same reason (dynamic-require creates places that calls dynamic-require, etc.)


sorawee
2019-11-23 19:42:45

I follow the instruction on that tutorial page, pasting your code in DrRacket. Remove the last line. Save the file. Then, go to the REPL and enter (start) . Then the program waits for 60s before printing output, as expected.


soegaard2
2019-11-23 19:43:38

I am on 7.4 and ran it in DrRacket with “no debugging or profiling”. The output:

Welcome to DrRacket, version 7.4 [3m]. Language: racket/base [custom]; memory limit: 1024 MB. #<place> 2 #<place> 1 0 >


sorawee
2019-11-23 19:45:05

I am on Racket 7.5 with “no debugging or profiling”


sorawee
2019-11-23 19:45:10

Here’s the output


soegaard2
2019-11-23 19:45:12

Oh! Calling start from the repl does wait 60 secs.


sorawee
2019-11-23 19:45:20

> (start) 1 2 0


sorawee
2019-11-23 19:45:41

Yup


soegaard2
2019-11-23 19:46:05

I was looking at the Mandelbrot benchmark and wanted to add places.


soegaard2
2019-11-23 19:46:17

And I’d ideally like a single file.


soegaard2
2019-11-23 19:47:46

Still don’t get why the sleep call doesn’t have any effect.


sorawee
2019-11-23 20:09:31

If I run your original code (with the call to start), then I get an out of memory error.


soegaard2
2019-11-23 20:13:03

Odd. The standard Racket (not Racket CS)?


sorawee
2019-11-23 20:13:48

Yup, but 7.5


soegaard2
2019-11-23 20:21:16

Okay - I see the same as you on 7.5. And an out memory error I can understand (same reason as before).


elyandarin
2019-11-23 20:45:59

Probably a dumb question: How should I strip surrounding quotation marks from a string? (I’m trying to process strings in my tokenizer…)


soegaard2
2019-11-23 20:47:31

(string-trim str "\"" #:repeat? #t)


elyandarin
2019-11-23 20:52:44

Thanks! Works fine!


pavpanchekha
2019-11-24 06:12:03

Very interested in this line from the release notes for 7.5: “GNU MPFR operations run about 3x faster.” Any details or PRs/commits I could read?



shaobo
2019-11-24 07:35:09

Presumably this commit