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

@mflatt said yesterday it would get updated this weekend

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

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

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

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

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

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?

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

Bad. Thank you!:+1:

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.


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.

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)

I can’t reproduce the behavior you described

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

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.

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
>

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

Here’s the output

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

> (start)
1
2
0

Yup

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

And I’d ideally like a single file.

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

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

Odd. The standard Racket (not Racket CS)?

Yup, but 7.5

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

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

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

Thanks! Works fine!

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?


Presumably this commit