
Any suggestion to make it more scheme-way or racket-way?

One thing that would make it more Racket-like would be that you can define a bf language. Since the syntax is very simple, that would be a pretty easy task.

Then, you can use #lang bf
to write programs.

Another possibility would be to change the (run)
procedure to use a functional style. Strictly speaking, that might reduce efficiently, but not necessarily by much. And, it would be a good exercise in using immutable data.

I guess the main point is “avoid eval
” :wink:

@kellysmith12.21 > Then, you can use #lang bf
to write programs. Thanks for the suggestion. Actually, that’s my starting point. https://gist.github.com/sleepnova/835b1df4029c0d03764f8bcdc33b96d6 But I need something that can read a bf program file and then execute it on the fly. So I don’t have to copy and paste every bf program into a file starting with #lang bf
.

That can be a different story indeed, although you could also use dynamic-require and friends.

@laurent.orseau Many thanks, you helped me get ride off this line. (eval '(require 'bf-module) ns)
Can you help me get ride off this line too? (eval bf-module ns)
What do you mean by “friends”?
Can I avoid eval
while still read-translate-load-execute my code dynamically through Racket’s JIT compiler engine?

I was thinking of dynamic-rerequire
:https://docs.racket-lang.org/reference/interactive.html?q=rerequi#%28def._%28%28lib._racket%2Frerequire..rkt%29._dynamic-rerequire%29%29

(if needed)

If the program to execute is written in #lang bf
, you can simply dynamic-require
the program file without using eval (you’ll need to parameterize the namespace with a new one though)

if you need to execute the same program a second time in the same namespace, you will need dynamic-rerequire
. If you create a new namespace each time, dynamic-require
should be enough

Or maybe I have to write a macro which expand a bf program file path to a Racket syntax object?

oh you mean you want to read user input like with a REPL?

for REPLs, using eval is legitimate

(but if you only ever read from file, then you generally don’t need it)

If the user is writing programs at a REPL, perhaps defining a #lang
and providing #%top-interaction
would be appropriate?

(Also, minor thing: Regarding style, the <https://docs.racket-lang.org/global/index.html|docs for global> say that by convention global ids are surrounded by . So I guess it should be *file*
. Note that the won’t appear in the command line arguments)

I only want to execute a bf program from file. Don’t have to be interactive in REPL.

Ok, good, that simplifies things a little.

Then I’m not sure why you ask about this: > Or maybe I have to write a macro which expand a bf program file path to a Racket syntax object?

@laurent.orseau I was thinking about how to achieve the same goal without using eval
. Is there any better or right way to dynamically generate a module and make it compile and load from Rackets VM?

FYI - after receiving a non-objection from @greg :), I created a #frog channel for Frog users to share tips, ask questions, etc.

@wanpeebaw Have you seen http://calmerthanyouare.org/2015/01/07/optimizing-brainfuck.html

You’re not happy with the user having to write modules like: #lang bf
+++++[->>>++<<<]>>>.
?

(because this really is just a module that you can require, as long as you require the bf language in the namespace first)

Are #:defaults
and #:fast-defaults
predicates tested in order of definition in define-generics
?

Want to install Racket CS on Raspian Arm64 - Reading https://github.com/racket/racket/blob/master/build.md#11-git-repository-versus-source-distribution and it suggests I should install from a snapshot. So I downloaded racket-7.9.0.6-arm-linux-cs.sh
which is 265mb and I have no idea what I am supposed to do with it

It’s a shell script (it ends in sh) - so you are meant to run it.

okay so i need to chmod -x
?

yes - I think sh racket-7.9.0.6-arm-linux-cs.sh
also works.

that worked great thanks!

Great.

Next Q: I installed the minimal version, but raco is missing make
, exe
and distribute
- which packages do I need to install to get them? I don’t see anything obvious in the package directory


Yes, I think it is compiler
you need.

oof SSL fail

Resolving "compiler" via <https://www.cs.utah.edu/plt/snapshots/20201120-b9e1294/catalog/>
ssl-make-client-context: requested protocol not supported;
SSL not available; check `ssl-load-fail-reason'
requested: 'auto

$ openssl version
OpenSSL 1.1.1d 10 Sep 2019

I see a very lengthy manual build in my future

If I want to prevent control from escaping an expression, is it correct to install a continuation barrier around the expression?

If you run (require openssl)
and then ssl-load-fail-reason
in the Racket repl, what do you get?

Continuation barriers prevent jumps back in. For example, in (+ (f) (g))
, f
could capture a continuation and store it somewhere and then g
could invoke it. If you put a barrier around the call to f
, then g
can’t use that continuation because it would cross the barrier.

You might want dynamic-wind
.

I could use dynamic-wind
and have the post-thunk raise an exception.

Related, how do I guarantee that call/cc
doesn’t capture beyond an expression, is that a case for prompts?

> ssl-load-fail-reason
"ffi-lib: could not load foreign library\n path: libcrypto.so\n system error: libcrypto.so: cannot open shared object file: No such file or directory"

I do have OpenSSL installed

Yes, kind of. But prompts have tags, and you can jump past a prompt if there is a prompt with another tag outside it, and if you have a reference to the outer tag.

might try (get-lib-search-dirs) and make sure libcrypto.so is on one of those paths

Thanks. What are the specific suffixes in /usr/lib for libcrypto.so and libssl.so? (For example, libssl.so.1.1
?)

hmmm i don’t see it in /usr/lib

@mwblakley do i need to require a pkg for that?

One thing that may fix your problem is installing the libssl-dev
package. That package includes a link from libssl.so
and libcrypto.so
to the specific versions of those libraries that are installed. Racket doesn’t always know about the most recent .so versions.

Try find /lib /usr/lib -name 'libcrypto.so*'

The actual library files are often in an architecture-specific subdirectory, and I don’t know that that is for your system.

/usr/lib/aarch64-linux-gnu/libcrypto.so
/usr/lib/aarch64-linux-gnu/libcrypto.so.1.1

Thanks. That means it’s not the problem I was thinking of, though, and now I’m stumped.

Ah. Is there no way to totally prevent capture beyond a given expression?

tbh i’m also confused by the new build instructions. Have been unable to build from source off tag v7.9
using make
from the top level.

fails building Chez
compiling <http://cpnanopass.ss\|cpnanopass.ss> with output to cpnanopass.patch
Killed
make[12]: *** [Mf-base:307: cpnanopass.patch] Error 137
make[11]: *** [Mf-boot:25: tarm64le.boot] Error 2
make[10]: *** [Makefile:59: tarm64le.bootquick] Error 2
make[9]: *** [Makefile:58: tarm64le.bootquick] Error 2
make[9]: Leaving directory '/home/pi/github/racket/racket/src/build/cs/c/ChezScheme'
make[8]: *** [Makefile:140: pb-bootquick] Error 2
make[8]: Leaving directory '/home/pi/github/racket/racket/src/build/cs/c'
make[7]: *** [Makefile:134: scheme-via-pb] Error 2
make[7]: Leaving directory '/home/pi/github/racket/racket/src/build/cs/c'
make[6]: *** [Makefile:118: scheme] Error 2
make[6]: Leaving directory '/home/pi/github/racket/racket/src/build/cs/c'
make[5]: *** [Makefile:76: cs] Error 2
make[5]: Leaving directory '/home/pi/github/racket/racket/src/build/cs/c'
make[4]: *** [Makefile:287: cs-base] Error 2
make[4]: Leaving directory '/home/pi/github/racket'
make[3]: *** [Makefile:271: cs-minimal-in-place] Error 2
make[3]: Leaving directory '/home/pi/github/racket'
make[2]: *** [Makefile:145: plain-in-place] Error 2
make[2]: Leaving directory '/home/pi/github/racket'
make[1]: *** [Makefile:142: in-place] Error 2
make[1]: Leaving directory '/home/pi/github/racket'
make: *** [Makefile:138: main] Error 2

Also
> (get-lib-search-dirs)
'(#<path:/home/pi/.local/share/racket/snapshot/lib>
#<path:/home/pi/racket-7.9.0.6/lib>)

Maybe the snapshot is looking in the wrong place?

If I want to build a minimal racket from source on Arm64 (Raspian) what do I need to run, I can’t really figure out what to do from https://github.com/racket/racket/blob/master/build.md

Previously I needed to do some kind of configure
incantations but it seems like the guide has been updated quite a bit, an tbh I just want to know what I need to do to get this to build.

You could run it in a new thread. Or if you know there are no prompts with other tags in the context, you can use a prompt.

Currently the build is failing with
Load <http://back.ss\|back.ss>
compiling <http://library.ss\|library.ss> with output to /home/pi/github/racket/racket/src/build/cs/c/ChezScheme/boot/tarm64le/library.so
fx-: contract violation
expected: fixnum?
given: 1152921504606846975
context...:
{cp0 unique164968}
{finish-compile unique363235}
{do-compile-file unique363531}
/home/pi/github/racket/racket/src/ChezScheme/rktboot/make-boot.rkt:171:0
body of "/home/pi/github/racket/racket/src/ChezScheme/rktboot/make-boot.rkt"
body of "/home/pi/racket-7.9.0.6/collects/setup/main.rkt"

I made another version which is closer to Racket’s parameter
, but it uses box
instead of thread-cell
, and uses hasheq
instead of Chez Scheme’s intmap
, and doesn’t support fancy features like derived parameters. In Matthew’s benchmark, my get
is as efficient as native get
, but set
is about twice faster.

I think @mflatt made some 32 bit related changes that might be relevant — are you on the latest HEAD

I’m on tag v7.9

can switch to head

Worth a try at least

yah same error

:(

Maybe report a bug

To Org Mode & Racket users out there: For keeping an archive of web-based notes during university, would it better to use Frog / Scribble/ Pollen (or maybe something else with Racket), or would it be conducive to use Org Mode (which is plain text and very easy to organize when used with Emacs) and use the simple html-export, which can create websites like <http://doc.norang.ca/org-mode.html#HowToUseThisDocument|this one> or <http://olivierberger.org/|this one> ?

Never really used Frog/Scribble/Pollen so not sure

Personally I’d just use Org Mode. Pollen could potentially work if you invest a lot of time with it, but Org Mode will work for you from the start.

To me, the main perk of Org Mode is not the language itself, but it’s the ability to integrate with the editor (Emacs) so that you can take note quickly. Pollen, when set up properly, will provide a better language than that of Org Mode, but you will still lose the editor integration.