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)
No, that’s not possible. Using a single-element collection path always refers to “main.rkt”.
Ok, no worries, I’ll just change my main file to main.rkt
then. Thanks.
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.
So I mean they are very different approaches, in details and extent.
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:
If the former I suggest an alias like call/nc
or perhaps call/nc-17
(apologies for US-centric joke).
@greg I think racket-mode
should require the configure-runtime
submodule (when available) when it runs a module
What makes you say that? Is there some edge case I’m missing?
The following program doesn’t seem to do it right: #lang htdp/bsl
(rest '())
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
You mean rest: expects a non-empty list; given: '()
vs. rest: expected argument of type <non-empty list>; given: '()
?
yes
I guess it’s possible that’s a different problem than configure-runtime
Sorry I don’t know htdp/bsl
which one is desired/correct?
the former is what both drracket and racket at the command line give
(this came up becase I’m looking at a different case where those two error message differ)
The former; the non require
example. OK.
I think I’m mirroring DrRacket’s configure-runtime handling pretty closely but I can double-check.
If it’s about error messages then I suppose it could be something about Racket Mode’s error display handler, instead and/or also.
but I don’t think the error display handler for racket at the command line is any different than racket-mode’s
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.
yeah that was my first guess but it didn’t seem to be that
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.
Also there’s the exn:srclocs-accessor
wrinkle, and how some things duplicate a message in exn-message
but others don’t.
So ATM it looks like this: https://github.com/greghendershott/racket-mode/blob/master/racket/error.rkt
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.
someone somewhere is supposed to be calling code in lang/private/rewrite-error-message
but I don’t know how the mechanism works either
Thanks at least that’s a breadcrumb from where I can start.
I’m also trying to understand this, so I’ll let you know what I find
Is there no way to turn off backslash escapes in the reader?
(inside strings)
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.
I think you’d have to adjust the mapping for #\"
in a readtable.
(thread-try-receive)
is pretty cheap, but polling a variable or box would be even cheaper.
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.
@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?
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.)
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.
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.
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.
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.
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 :)
I’m working on a command line tool to group and sort tasks (possibly inside groups) from one or more todo.txt
files.
Which of course is the definition of “preemptive” which I didn’t think about properly ;)
The current code is at https://hg.sr.ht/~sschwarzer/todoreport-racket/browse/ .
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.
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.
So I’ll probably go with renaming group
to task-group
. :slightly_smiling_face:
At the moment, I use the names sort/tasks
and group/tasks
for the sort and group actions (not accessors).
I’m not sure who manages the Twitter account, but the pinned tweet should probably be updated to 8.0.
That’s @pocmatos