
How about (in-range [1 n])
and (in-range [1 n))
, just like mathematical notation…:laughing:

@wanpeebaw That’s doable, if we change to: (in-range "[1,n]")
and (in-range "[1,n[")
. The in-range
transformer can handle expressions inside string literals without problems.
But the reason I wanted (range n m)
to return a struct, was to allow operations such as range-union
and range-intersection
.

Maybe extend range expression to express closed and open ended like (range n m '])
and (range n m '))

Maybe I should lobby for domain
to replace range
?
> ; A domain interval represents an interval, a subset of the real number line > ; of one of the following forms: > ; i) a<x<b open-open > ; ii) a<=x<b closed-open > ; iii) a<x<=b open-closed > ; iv) a<=x<=b closed-closed > > ; A domain consists of a list of intervals. > ; The invariant is: > ; I) the intervals doesn’t overlap > ; II) the intervals are sorted in ascending order I used them in MetaPict to represent the domain of functions (of which I wanted to plot their graph).
https://github.com/soegaard/metapict/blob/master/metapict/domain.rkt

I chose (open a b)
, (closed a b)
, (open-closed a b)
and (closed-open a b)
to construct the intervals ]a;b[, [a;b], ]a;b] and [a;b[ respectively.

@soegaard2 When talking about math, functions like range
always bug me, because range
is meant to be continuous, while domain
is a set. The Racket method (range 5)
technically returns a domain (0 1 2 3 4)
. The value 2.5
is not in that domain, but is in the range. If you’re really wanting math predicates, I’d probably do something along the lines of:
(define (in-range x start end #:start-open [so #t] #:end-open [eo #f]) ...)
And then in-domain
could be implemented as just member
or something similar.
My 2c.

How can I debug an “instantiate-linket” error: FAILURE
name: check-not-exn
location: typed-racket-test/main.rkt:88:31
expression: (check-not-exn thnk)
params: '(#<procedure:...acket-test/main.rkt:80:10>)
message: "Exception raised"
exception-message:
"instantiate-linklet: mismatch;\n reference to a variable that is not exported;\n possibly, bytecode file needs re-compile because dependencies changed\n name: Poly*178.1\n exporting instance: \"/home/runner/work/typed-racket/typed-racket/typed-racket-lib/typed-racket/rep/type-rep.rkt\"\n importing instance: (submod \"/usr/share/racket-7.7.0.6/pkgs/math-lib/math/private/array/array-parallel.rkt\" #%type-decl)"
exception:
#(struct:exn:fail:contract "instantiate-linklet: mismatch;\n reference to a variable that is not exported;\n possibly, bytecode file needs re-compile because dependencies changed\n name: Poly*178.1\n exporting instance: \"/home/runner/work/typed-racket/typed-racket/typed-racket-lib/typed-racket/rep/type-rep.rkt\"\n importing instance: (submod \"/usr/share/racket-7.7.0.6/pkgs/math-lib/math/private/array/array-parallel.rkt\" #%type-decl)" #<continuation-mark-set>)

Usually, I would run raco setup
and this type of errors would go away.

@mflatt Is there a more effective and efficient racket-ish way to fix this than something like git bisect
?

Ah, nvm, I see what I got wrong

In case someone else runs into similar trouble, what was it? (I didn’t have any good guesses.)

I’m working on a version of dict/c
with chaperones, but I’m running into a surprising problem that only comes up because of the failure-result
optional-argument to dict-ref
.
When the failure-result
is used, I don’t want the “value” contract to apply to that result. But when the failure-result
isn’t used, but the “value” result happens to be exactly equal to the failure-result
, I do want the “value” contract to apply to it. How do I distinguish those though?
I tried to take inspiration from Carl Eastlund’s dict/c
implemented in mischief/contract
, but it doesn’t use chaperones so it is free to both add an escape continuation, and change the failure-result input to always be a new synthesized procedure. That way the new synthesized failure-result procedure can call the escape continuation. If I’m constrained to chaperones, I don’t know how to do either of those things.
How can I detect whether the failure-result is used-or-not by the dict’s implementation of dict-ref
, while keeping the failure-result
a chaperone of the original failure-result?

it was out-of-date zo files caused by (the TR CI tests) running raco setup on only a limited set of collections

I have also asked on the Racket Users list: https://groups.google.com/d/msg/racket-users/kHQmJh63-mU/8SXYlmZzAAAJ

Maybe, send 64-byte chunks with a header byte that’s all–0 to signal “end of object”

use all–1 to signal “there’s more” after this and all–0 to signal “this is the end”

that shifts the problem into the 64-byte window though, doesn’t it?

Why not just take any incremental (non-empty) data you have, length-prefix that part, repeat, at the end emit a “length” of 0.

Or use something like http 1.1’s chunked encoding.

Which is exactly what @gfb’s suggestion amounts to… :slightly_smiling_face:

And @mbutterick, your hex idea is essentially available in racket via base64 encoding ( https://docs.racket-lang.org/net/base64.html ), which avoids many characters (for a different reason, but that doesn’t matter). That library also breaks the data into chunks (again, not for the reasons we would), but you can just set the separator to the empty byte string.

and profile to see if the base64 encoding/decoding is expensive or not, that’ll help you decide if base64 is good enough

if 64 byte chunks seem like the better approach, then could reserve the first byte of the chunks to indicate if it’s the last chunk or more still coming

You still need a length indicator on the last chunk, not just that it’s the final one.

if every chunk is of a known same size, won’t a length indicator not be necessary?

oh I see what you mean

the last bit of the binary file might not occupy the entire chunk

change of topic : what’s the noticeable difference between defining a function in a class, versus defining a private method, and is there a standard heuristic for choosing which to do.

One will produce a closure over this, one will indirect through the vtable

so the closure is a bit of allocation per object, but a standard closure for higher-order uses

Right. For space and time performance, you should practically always define a private method, except when doing would lead to a syntax error (because the method name is used as an expression). A private method avoids closure allocation and is potentially inlined.

@mbutterick Here’s an example of what I was talking about: https://gist.github.com/97jaz/20a53bb49d2f6684b91011f2aa1911ff
It transmits data as a series of variable-length chunks, where the end of the stream is indicated by a chunk of length 0. This is a bit different from how it’s done in HTTP, since I use a fixed two-byte chunk size.

thanks!

Is this documented anywhere? I was confused by this for a very long time. If not, would it be a good idea to put it in tutorial/doc?

Is it wrong in a procedure chaperone, to call the function I’m supposed to be chaperoning during the chaperone’s wrapper-proc? It feels kinda evil to me, but I’m not sure why

that definitely seems wrong

it would call the procedure twice

Okay.

So I guess it would be worth avoiding chaperones then, for a contract that would need to be an impersonator contract, that only calls the procedure once, rather than a chaperone contract that calls the procedure twice

Hi Racket folks. I am attempting to perform some basic comparative benchmarking of a handful of implementations of parallel Concurrent ML, with Racket being one of them (since its channels and events correspond pretty closely to Concurrent ML). To that end, I have been working on implementing some small test programs in Racket - thank you very much to the people who have helped me out with that so far :slightly_smiling_face:
I have now ‘completed’ these programs using places, channels and events. You can see the current results here: https://github.com/jcoo092/CML_benchmarks/tree/master/Racket
I strongly suspect, however, that since I’m pretty much still a total Racket newbie, I have done one or more things in a sub-optimal (or at least non-idiomatic) way. Plus, there could well be a bug or two in there that I haven’t spotted. Thus, I would very much appreciate it if anyone who is interested would take a look at the programs, and let me know if they spot any glaring errors or inefficiencies. Or anything else that jumps out at you as a problem.
I’m interested in any and all critiques you can come up with that might make the programs better, but, please note that I might not take them into account. This is mostly likely to happen if the suggested change would be a significant rewrite of a whole program beyond what I have now. The reason for that is I’m also (implicitly) somewhat testing the languages I am working with to see which ones enable new-to-the-language programmers to get good performance without too much effort.
Thanks again everyone for your help! :slightly_smiling_face:
EDIT: You don’t need to suggest Typed Racket, since I already plan to try that out in the near future :wink:

@hedgehogshiatus has joined the channel

@joe has joined the channel

Hi. Is Racket suitable to make a chat server with a web client?