
Good afternoon friends,
I’m trying to build a distributable version of my little Gemini browser:
https://git.sr.ht/~soapdog/fafi-browser
The source folder contains a main.rkt
which has (module+ main ...)
in it. I thought that selecting that file and using the menu to create a distribution should work. I also tried to come up with a build script based on Alex build script for ActivityLog2:
https://git.sr.ht/~soapdog/fafi-browser/tree/maybe-build/build.rkt
What is happening is that everything appears to build correctly on first glance but nothing happens when I try running the Fafi.exe
file. If I try running it like Fafi.exe -v
I get a Racket v7.7
banner which makes me think that my main module is not executing. This happens if I use my build script or if I use the menu in DrRacket.
Can someone share some pointers or feedback about where to look to fix this? I greatly appreciate any feedback.

Are macros in Racket first class macros? http://matt.might.net/articles/metacircular-evaluation-and-first-class-run-time-macros/

No. “First-class macros” are usually called https://en.wikipedia.org/wiki/Fexpr\|fexprs. They are not very common.

They’re also not a good idea

I’m looking forward to trying fafi. I have a gopher server I wrote in racket that I build a distributable version of. I use a Makefile to run a handful of ‘raco’ commands. The gist of it is this:

SRC_FILES = trie.rkt file-search.rkt corpus.rkt gopher.rkt main.rkt
EXE = main
DIST_DIR = gopher21
all: gopher21
main: $(SRC_FILES)
raco make -v main.rkt
raco exe -v main.rkt
gopher21: $(EXE)
raco distribute $(DIST_DIR) $(EXE)

‘raco make’ compiles the files. ‘raco exe’ builds an executable. And ‘raco distribute’ bundles everything in one directory that can be distributed.

(module+ main ...)
is a special sub module that only gets run by DrRacket https://docs.racket-lang.org/guide/Module_Syntax.html#%28part._submodules%29\|https://docs.racket-lang.org/guide/Module_Syntax.html#%28part._submodules%29

@andre how did you get on? Did it work?

@spdegabrielle I just managed to make a build that works but the command-line flags I have in my main.rkt
are not working as expected. Things like -h
and -v
are the Racket version and not my own.

solved by passing #:cmdline '("--")
to create-embedding-executable.

thanks a lot for all the help folks.

@i.n.buryan has joined the channel

:surfer:

If you’re interested though you can check out John Shutt’s work on Kernel

Hi everyone, I’m having trouble sending a post request from client to server containing many lines of data (a result of using a “select all” functionality). How does one go about compressing a post request in Racket? Any pointers are appreciated.

I’m not familiar with web stuff, but can you clarify what you mean by “having trouble”? What error did you get? Or what was not working?

Apologies, I should’ve included the error with my original message.
take: contract violation
expected: a list with at least 639 elements
given: '(1099 1101 1103 1109 1111 1113 1115 1117 1119 1121 1123 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1160 1161 1162 1163 1164 ...
The error occurs when the user submits the form containing the checkboxes. I’m not sure which function in the background is calling “take” so I’m struggling to pinpoint the source of the problem.

The problem here is that you’re trying to take more elements than there are.

Ah — sorry, I missed the fact that you’re not explicitly calling take
, right?

I’ll double check for a stray take
, but in case I don’t find it, is there any chance it’s being called by some function in the background?

I’m unclear on the context here. When you initially posted your question, I thought that you were using an http client function, like post-pure-port
, but now I’m wondering if the browser is what’s doing the http post, and your code is server-side.

can you run the code with errortrace enabled? that will give a stack trace that should make it easier for us to understand the problem

And if the code isn’t private, providing the relevant section, or a link to the repo would be helpful, too.


Is there a limit on the numbers with which bitwise-bit-set?
can work? It does not seem to work for me on Racket 7.8 CS with very large numbers:
(for/first ([bit (in-range 0 32)] #:when (bitwise-bit-set? 645656621111111187822534459392 bit)) #t)
The above code returns #f
(meaning that none of the first 32 bits are set in that number?), however for a smaller number it seems to work: (for/first ([bit (in-range 0 32)] #:when (bitwise-bit-set? 45656621111111187822534459392 bit)) #t)
The above is an order of magnitude smaller and returns #t

Are either of those fixnums?

also, are you trying to use a number as a bitstring? if so, I made an actual bitstring?
type you could use instead if you like

The example I gave has nothing to do with what I try to acomplish, but in my code I seem to be unable to check if a bit is set for very large numbers, such as 645656621111111187822534459392. I don’t think this is a fixnum, but the documentation for bitwise-bit-set?
does not seem to require a fixnum (and if it did, should it not fail?)

I agree that it should work on bignums, I’m just thinking about what the bug might be

@notjack, no I am not trying to use a number as a bit string. I am trying to convert a latitude - longitude pair onto a distance on the Hilbert curve. The code works for small recursion levels, but fails when the numbers get big.

that’s fascinating, why are you trying to do that?

The end result will be code which can (quickly) find a segment defined by a list of GPS points among several thousand tracks with a few million data points. But this is still far away.

Hi @samth, on a different note, can Typed Racket optimise away cond branches?

Basically, in the plot package, I check for invalid parameters using: (cond
[(and x-label (not (or (string? x-label) (pict? x-label))))
(printf "** boom = ~a~%" (and x-label (not (or (string? x-label) (pict? x-label))))))
but the branch does not seem to be taken even when x-label is a number (i.e. invalid). I printed out the condition before the cond and it is #t

Neither of those are fixnums, so I think it’s subtler than that.

my suspicion is that TR determines that the condition is always true based on the type of the arguments, than unsafe-provide
throws away the contract…

I don’t think any of the low 32 bits are set in 645656621111111187822534459392, but the next-to-high bit is set in 45656621111111187822534459392: > (format "~x" 645656621111111187822534459392)
"8263aa3ac6a75000000000000"
> (format "~x" 45656621111111187822534459392)
"93864595d9c8714040000000"
Have I misunderstood the problem?

> … if I use #lang typed/racket #:no-optimize
than the check works…

No, I don’t think you have. Doesn’t seem to be any problem here.

Then it’s definitely the optimizer

And yes, that’s what I would expect

The easiest way around that is probably to make the variable mutable (ie, the target of a set!
)

Looks like the problem was with my code, sorry for the trouble…

It seems in racketcs, invoking an escape continuation using call-in-continuation is generally faster than calling it directly. And non-composable continuation is even more faster for escaping(assuming not be disturbed by other prompts).

My thought is to just use the #:lang typed/racket/base #:no-optimize
— the module does not benefit from any speed improvements anyway, as all it does it checks parameters and forwards the calls into other TR modules, which are optimized. Longer term, it would be good to get rid of the unsafe-provide
the only bottleneck, as far as I understand is that the contracts attached to the snip instance are too costly

holy moly my stand alone executable with --embed-dlls
is 34MB. how can I cut this down? I’m pulling in 2htdp/image as a dependency so I assume that is the main reason. either way, how do i cut this down? I don’t want other people needing to install racket to use this small cli app

i dont need to draw images really, just crop them