Question that may be controversial, but which I genuinely don’t know the answer to: What is so great about REPLs? I have seen people comment that they refuse to touch a given language because it doesn’t have a (well-developed-enough) REPL. They seem to be the centre of the LISP-family universe these days (or, the Scheme universe, at least).
Every time I try to use one, though, I find it to be a pain in the neck - the moment I want to use basically anything in my program that isn’t defined in the language’s standard library/default environment, I seem to have to jump through a bunch of irritating hoops just to get started. Which I have to repeat every time I make some modifications. And, of course, what you do in them is ephemeral, so you don’t have some old file to refer back to when you hit a similar problem later on.
Basically, for tiny toy fiddling they appear to work fine, but as soon as I start writing something that is to be part of a larger program/library, it becomes painful. REPLs seem to me to be more trouble than they’re worth on the whole, which leaves me thinking that I must be missing something, since a lot of people seem to adore REPLs. Does anybody have any references to something along the lines of “How to use your REPL effectively”? (for Racket or any other language)
Also here is another use case: You have a server that’s running and decides to change something (while the server continues running).
https://www.youtube.com/watch?v=0RQYa2XJBKU
The video could be more to the point - but couldn’t finde a better one.
(in case anyone is potentially dissuaded from answering the above question, I really am interested in finding out what it is I don’t understand about REPLs and their use. This isn’t just one of those rants disguised as a question where I’m only seeking reinforcement of my pre-conceived ideas)
Assuming I already did raco link * and going forward I will do raco pkg migrate, is there something I should do to undo raco link * ? Also, sometimes I like to have two Rackets, one the current “official” one (7.8) and another the latest nightly build, and/or maybe something I built from source. Is package management with raco pkg possible in that scenario? And while mentioning links, on a Mac I have /Applications/Racket/Racketx.y for various x.y, then I have /usr/local/racket/{versions,…,latest}, where each of those versions points to an x.y version in /Applications/Racket/, and latest points to whatever the latest one is. Is this horribly bad, or ok and manageable for packages?
@jcoo092 Sounds like you’re looking for something akin to a .bashrc, but for your REPLs?
or maybe some way to “save” the code/machinery that’s been developed in the REPL? is there a racket equivalent to ipython’s %logstart
?
Yes, that can work fine. I use https://github.com/takikawa/racket-dev-goodies to manage that situation
Is there a raco
command to recursively remove the contents of compiled
directories starting from the current directory?
e.g. raco make clean
@badkins find . -name compiled -type d -exec rm -r \{\} \;
not raco
, but it does the trick
Yes, I’m familiar with *nix commands, but I think this is worth having in raco
It could be that my workflow is incorrect, but when I change a struct
I sometimes get errors relating to it being changed, so apparently a recompile isn’t being triggered.
I’ve yet to package-ize my code - maybe if it was a package, this would no longer be a problem.
You could use raco make *.rkt
to just do a recompile.
Recursively?
ohhhhh.
More unix commands then.
find . -name \*.rkt \| xargs -n raco make
I resorted to writing a script for running tests so I could use -j 8
, but it’s brittle. I could do the same thing for make
, but isn’t that what make is for?
would a -r
option be appreciated for raco test
and raco make
? Maybe I could add that.
If these issues go away if I convert my code to a package, then I’m fine just doing that. I’ve been putting it off due to laziness.
Normally, raco make
on your main module should work. Does your program use dynamic-require
to access other modules, or just plain old require
?
Hmmm, wasn’t really something I was thinking about, but you might well have a point.
I’m really still largely at the “huh, what?” stage with REPLs, though ¯_(ツ)_/¯
plain require
To rebuild, I do usually just raco make app.rkt
, and that’s been fine, even for building web template views, etc., it’s just occasionally I’ll get the error about the wrong struct version.
Hmm… now that I mention it, I wonder if the macro that builds the html views is using dynamic-require
behind the scenes.
I’m using include-template
for that.
i guess that’s one thing i like about ipython, i can load the repl, mess around until i find something that works, then save the whole mess to a file and edit it to make a useful standalone script
i haven’t searched very hard, but it wasn’t obvious to me how to do that in racket’s repl
It seems unlikely that include-template
involves dynamic-require
. I’m out of guesses, but I’d be interested to look at a smallish example that doesn’t behave correctly, if you have one.
I know that macros can execute arbitrary Racket code, but, in practice, do macros generally only use a small subset of the language?
They tend to usually avoid IO and threads
but there are valid use cases for those in macros (such as generating code based on data in a file)
Reading command-line at compile-time is another thing I thought it’s cool that it’s able to do, until I found that if you raco make
, then the compiled code is cached, so your new invocation won’t work.
If your code is in a collection (even if not a package) then raco setup collection-name
will rebuild it all and raco setup -c collection-name
will remove compiled files
@soegaard2 Thanks the video was helpful! I was unconsciously thinking of syntax-objects
as having no associated scope, so my mental model was wrong (I’ve not really touched a hygenic macro system before; both elisp and scala had unhygenic ones).
Hi, I have both Racket BC & CS version installed. When I start DrRacket BC I got following error message, is there any way to get around that? Error loading tool #<path:/Users/sleepnova/Library/Racket/7.8/pkgs/todo-list>
read-compiled-linklet: virtual-machine mismatch expected: "racket" found: "chez-scheme" in: /Users/sleepnova/Library/Racket/7.8/pkgs/todo-list/compiled/info_rkt.zo
context...:
read-linklet-or-directory
read-dispatch
read-syntax
default-load-handler
standard-module-name-resolver
module-path-index-resolve
do-dynamic-require
/Applications/RacketBC/collects/setup/getinfo.rkt:33:0: get-info/full
/Applications/RacketBC/collects/racket/contract/private/arrow-val-first.rkt:555:3
/Applications/RacketBC/share/pkgs/drracket/drracket/private/tools.rkt:106:0: installed-tools-for-directory/keys
/Applications/RacketBC/share/pkgs/drracket/drracket/private/tools.rkt:96:0: installed-tools-for-directory
loop
[repeats 16 more times]
/Applications/RacketBC/share/pkgs/drracket/drracket/private/tools.rkt:84:0: all-installed-tools
/Applications/RacketBC/share/pkgs/drracket/drracket/private/tools.rkt:80:0: rescan-installed-tools!
/Applications/RacketBC/share/pkgs/drracket/drracket/private/tools.rkt:72:0: load/invoke-all-tools
...
just kill compiled
?
I mean, this is pretty much the conversation we have above…