jcoo092
2020-4-30 02:17:30

@jcoo092 has joined the channel


xuuexu
2020-4-30 04:49:06

[beginner question] can i manipulate syntax object directly without converting it to datum (I do worry about context thing) for example I want to count how many steps in specific stage, where should I start with? ^ ^;


jcoo092
2020-4-30 04:56:25

Hi Racket folks :slightly_smiling_face: Is there anybody lurking in here who knows about Futures and Places? I could use some advice and clarification on a point or two.


samdphillips
2020-4-30 04:57:36

Ask away, helpful folks are generally always around


jcoo092
2020-4-30 05:18:26

Basically, I am trying to write some small programs to test various language’s ability to use Concurrent ML-style programming in parallel, one of them being Racket (you can see the programs I writing here https://github.com/jcoo092/CML_benchmarks/tree/master/Racket). Currently, I am doing everything just using threads, but of course, that isn’t truly parallel. I am wanting to switch to using Futures or Places, since they are apparently the parallel options.

My first question is, which should I use? I am expecting to be doing numerical-processing-heavy work down the line. The documentation says that Places are better for on-going parallelism, which is what I’m expecting to be wanting later, but Futures seem more immediately recognisable as something I could use.

My second question is, what does the documentation mean when it says (at https://docs.racket-lang.org/guide/parallelism.html#%28part._effective-places%29) : > https://docs.racket-lang.org/reference/places.html#%28form._%28%28lib._racket%2Fplace..rkt%29._place%29%29\|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. Should I define anything that I plan to use with a Place in a separate module? I think I understand the issue described, but I’m not really clear on the correct approach to avoid it.

Lastly, on the topic of places, what I would like to do is essentially launch functions (possibly mutually recursive functions) that persist and do their thing for a while, communicating via channels as need be, before eventually returning. Is this how Places work? The existence of place-channels seems to suggest that, but the code examples don’t make that 100% clear to me either.


jcoo092
2020-4-30 05:32:14

(also, feel free to critique other parts of the programs if you wish - I can’t guarantee I’ll change things in response to it, but I’ll definitely listen :slightly_smiling_face: And before anybody feels the need to mention it, I fully intend to port these to Typed Racket and see how things go there, but I’d like to get them working properly in regular Racket before making such a move)


sorawee
2020-4-30 05:45:19

syntax->datum doesn’t mutate the syntax object. It leaves the original syntax object as it is. Therefore, if you want to count number of stages, (match (syntax->datum stx) [(list 'pipeline stages ...) (length stages)]) would do it.


sorawee
2020-4-30 06:01:59
  1. My impression is that future doesn’t really work, and place is the way to do things.
  2. I think the rule of thumb is that if you run racket <your-file.rkt>, then the place expression should NOT be evaluated. But when you run racket -tm <your-file.rkt>, then the expression should be evaluated. If you can structure your code satisfying the above condition, then you should be good.
  3. Yeah, that sounds like something that place can definitely do.

sorawee
2020-4-30 06:05:35

Robby gave an example program that uses place a while back at https://groups.google.com/d/msg/racket-users/FaFhN-71xd4/PtRFFtLoCgAJ. It might be helpful to take a look at it.


xuuexu
2020-4-30 06:09:38

hah, it helps


sorawee
2020-4-30 06:19:04

Alternatively, there is a less aggressive approach to convert to datum. E.g., syntax-e and syntax->list. For your case, syntax->list might be more suitable.