laurent.orseau
2021-3-1 11:05:57

I thought there was a way to say which was the main file in an info.rkt when invoking racket -l mycollection. It defaults to main.rkt but I would like it to be something else. Isn’t this possible? (Also, it’s surprisingly hard to find information about this in the docs)


mflatt
2021-3-1 13:18:02

No, that’s not possible. Using a single-element collection path always refers to “main.rkt”.


laurent.orseau
2021-3-1 13:19:20

Ok, no worries, I’ll just change my main file to main.rkt then. Thanks.


greg
2021-3-1 15:45:52

I was surprised, too. If you want to step-debug your program, then “just” rewrite your program to be a step-debuggable version of your program. After marinating in that awhile, I realized it’s “just” a matter of degree. IIUC a “real” debugger modifies the original program to (at least) insert break interrupt instructions. The rewriting that Racket does is more extensive, since you have to express breaks in terms of Racket conditionals, and you need more instrumentation to view local variables, etc. etc. etc.


greg
2021-3-1 15:47:08

So I mean they are very different approaches, in details and extent.


greg
2021-3-1 15:47:46

But to the extent your computer just runs programs, then on some level a debugger needs to arrange for at least a slightly different program to be run, in order to be debuggable. :slightly_smiling_face:


greg
2021-3-1 16:16:32

If the former I suggest an alias like call/nc or perhaps call/nc-17 (apologies for US-centric joke).


samth
2021-3-1 16:39:23

@greg I think racket-mode should require the configure-runtime submodule (when available) when it runs a module




greg
2021-3-1 16:42:41

What makes you say that? Is there some edge case I’m missing?


samth
2021-3-1 16:43:19

The following program doesn’t seem to do it right: #lang htdp/bsl (rest '())


samth
2021-3-1 16:44:11

the error message I get from C-c C-c in Racket mode is the one I get from > (require "that-file.rkt") instead of the one from racket that-file.rkt


greg
2021-3-1 16:47:46

You mean rest: expects a non-empty list; given: '() vs. rest: expected argument of type <non-empty list>; given: '() ?


samth
2021-3-1 16:47:54

yes


samth
2021-3-1 16:48:18

I guess it’s possible that’s a different problem than configure-runtime


greg
2021-3-1 16:48:35

Sorry I don’t know htdp/bsl which one is desired/correct?


samth
2021-3-1 16:48:53

the former is what both drracket and racket at the command line give


samth
2021-3-1 16:49:20

(this came up becase I’m looking at a different case where those two error message differ)


greg
2021-3-1 16:49:53

The former; the non require example. OK.


greg
2021-3-1 16:50:15

I think I’m mirroring DrRacket’s configure-runtime handling pretty closely but I can double-check.


greg
2021-3-1 16:50:38

If it’s about error messages then I suppose it could be something about Racket Mode’s error display handler, instead and/or also.


samth
2021-3-1 16:51:59

but I don’t think the error display handler for racket at the command line is any different than racket-mode’s


greg
2021-3-1 16:53:51

I get the same result using racket-run, which runs main and test submodules automatically — unlike racket-run-submodule-at-point which is bound to C-c C-c. Didn’t expect that to differ but when I hear “BSL” that’s the first thing I double-check.


samth
2021-3-1 16:54:23

yeah that was my first guess but it didn’t seem to be that


greg
2021-3-1 16:56:16

The error display handler for Racket Mode is somewhat different from the command-line default. Among other things I’m in a constant battle with things that helpfully elide complete pathnames, and trying to de-lossify that.


greg
2021-3-1 16:57:11

Also there’s the exn:srclocs-accessor wrinkle, and how some things duplicate a message in exn-message but others don’t.



greg
2021-3-1 16:59:51

But I don’t understand exactly what htdp/bsl is doing with its error messages, or why. So if you have any hints, that would be great, otherwise I’ll open an issue and try to dig into this a bit, soon but later.


samth
2021-3-1 17:00:28

someone somewhere is supposed to be calling code in lang/private/rewrite-error-message


samth
2021-3-1 17:00:39

but I don’t know how the mechanism works either


greg
2021-3-1 17:02:37

Thanks at least that’s a breadcrumb from where I can start.


samth
2021-3-1 17:02:54

I’m also trying to understand this, so I’ll let you know what I find


pavpanchekha
2021-3-1 18:34:44

Is there no way to turn off backslash escapes in the reader?


pavpanchekha
2021-3-1 18:34:46

(inside strings)


badkins
2021-3-1 21:09:44

What is the most efficient way for a thread to yield control to another thread?

I’ll have two threads - one that is an I/O loop communicating with a human, and another one that is 100% CPU bound. So, I’d like to periodically yield control from the CPU bound thread to the other one - in the least amount of time. My hunch is that something like (thread-try-receive) is too expensive, but that’s just a hunch.


mflatt
2021-3-1 21:19:57

I think you’d have to adjust the mapping for #\" in a readtable.


mflatt
2021-3-1 21:24:42

(thread-try-receive) is pretty cheap, but polling a variable or box would be even cheaper.


badkins
2021-3-1 21:27:31

I just ran a quick test, and it looks like (thread-try-receive) is pretty cheap - about 2.8 μs ! It might be handy to communicate some things via thread mailboxes, so I think that’ll work.

I wasn’t aware that polling a variable or box would yield control - that’s pretty fine grained.


badkins
2021-3-1 21:30:09

@mflatt maybe I’ve misunderstood the threading model - I was assuming that since my CPU bound thread wasn’t doing anything such as I/O, that it would starve the other thread, but it seems that there are a number of things besides blocking on I/O that would automatically yield control to other threads, is that right?


mflatt
2021-3-1 21:31:45

Threads are pre-emptive, so you don’t need to explicitly yield to let another thread to run. (I assumed you were interested in having one thread pause for a while when notified by another thread.)


badkins
2021-3-1 21:33:47

Right, I knew Racket threads weren’t cooperative (i.e. requiring an explicit yield), but I guess I thought the CPU bound thread wasn’t doing any of the operations that would allow a switch to another thread. I think I probably have a non-issue then :) I mainly need to allow the human-communicating thread to signal the other thread to stop it’s processing prematurely.


badkins
2021-3-1 21:36:36

Now I’m curious re: which operations allow Racket to switch threads. It seems like if the mechanism is too fine grained, it would be inefficient, and if it’s too coarse grained, concurrency would be impaired.


mflatt
2021-3-1 21:41:39

There’s no particular operation required. Racket (really Chez Scheme) polls for timeout events at a fine granularity, roughly at each function call, including tail calls that implement loops. The poll is implemented as a decrement on value referenced through a thread-context pointer in a register.


sschwarzer
2021-3-1 21:44:02

The task is a struct for the todo entries in https://github.com/todotxt/todo.txt#todotxt-format-rules . I have fields completed?, creation-date etc. A group is supposed to consist of a heading and a list of tasks. In that sense, task-group instead of group would be ok, but this gives an accessor task-group-tasks , which looks a bit odd. Also, the group struct is in the task.rkt module, so the “task” part would be even more redundant.


badkins
2021-3-1 21:44:32

Cool - thanks for the explanation. I think I can probably just have the two threads communicate via a variable protected by a semaphore then. I’m glad I don’t have to worry about starvation myself :)


sschwarzer
2021-3-1 21:45:02

I’m working on a command line tool to group and sort tasks (possibly inside groups) from one or more todo.txt files.


badkins
2021-3-1 21:45:07

Which of course is the definition of “preemptive” which I didn’t think about properly ;)


sschwarzer
2021-3-1 21:46:59

notjack
2021-3-1 21:47:55

I think task-group is a good name. The task-group-tasks name is a little wordy, but it’s less awkward than changing the naming formats of the other functions. Plus “group” is a really vague and general term, I think clarifying that this is a group of tasks is useful.


sschwarzer
2021-3-1 21:49:47

I was thinking that group would be meaningful enough since it’s in the task.rkt file. But then, when used from another module, the source file wouldn’t be obvious anymore.


sschwarzer
2021-3-1 21:50:18

So I’ll probably go with renaming group to task-group. :slightly_smiling_face:


sschwarzer
2021-3-1 21:51:20

At the moment, I use the names sort/tasks and group/tasks for the sort and group actions (not accessors).


philip.mcgrath
2021-3-2 02:21:26

I’m not sure who manages the Twitter account, but the pinned tweet should probably be updated to 8.0.


samth
2021-3-2 02:34:43

That’s @pocmatos