jcoo092
2020-8-10 07:25:47

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)


soegaard2
2020-8-10 09:02:33

soegaard2
2020-8-10 09:14:24

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.


jcoo092
2020-8-10 10:58:31

(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)


gknauth
2020-8-10 18:18:28

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?


gknauth
2020-8-10 18:20:36

@jcoo092 Sounds like you’re looking for something akin to a .bashrc, but for your REPLs?


george.privon
2020-8-10 18:24:44

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?


samth
2020-8-10 18:31:20

Yes, that can work fine. I use https://github.com/takikawa/racket-dev-goodies to manage that situation


badkins
2020-8-10 19:57:56

Is there a raco command to recursively remove the contents of compiled directories starting from the current directory?


badkins
2020-8-10 19:58:46

e.g. raco make clean


popa.bogdanp
2020-8-10 20:06:05

@badkins find . -name compiled -type d -exec rm -r \{\} \; not raco , but it does the trick


badkins
2020-8-10 20:06:40

Yes, I’m familiar with *nix commands, but I think this is worth having in raco


badkins
2020-8-10 20:08:37

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.


badkins
2020-8-10 20:09:20

I’ve yet to package-ize my code - maybe if it was a package, this would no longer be a problem.


samdphillips
2020-8-10 20:25:19

You could use raco make *.rkt to just do a recompile.


badkins
2020-8-10 20:25:42

Recursively?


samdphillips
2020-8-10 20:27:14

ohhhhh.


samdphillips
2020-8-10 20:27:30

More unix commands then.


samdphillips
2020-8-10 20:27:52

find . -name \*.rkt \| xargs -n raco make


badkins
2020-8-10 20:27:57

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?


badkins
2020-8-10 20:28:55

would a -r option be appreciated for raco test and raco make ? Maybe I could add that.


badkins
2020-8-10 20:30:14

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.


mflatt
2020-8-10 21:14:43

Normally, raco make on your main module should work. Does your program use dynamic-require to access other modules, or just plain old require?


jcoo092
2020-8-10 21:48:12

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 ¯_(ツ)_/¯


badkins
2020-8-10 21:59:11

plain require


badkins
2020-8-10 22:00:19

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.


badkins
2020-8-10 22:01:14

Hmm… now that I mention it, I wonder if the macro that builds the html views is using dynamic-require behind the scenes.


badkins
2020-8-10 22:03:03

I’m using include-template for that.


george.privon
2020-8-10 22:20:20

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


george.privon
2020-8-10 22:20:37

i haven’t searched very hard, but it wasn’t obvious to me how to do that in racket’s repl


mflatt
2020-8-10 22:42:43

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.


kellysmith12.21
2020-8-10 23:30:50

I know that macros can execute arbitrary Racket code, but, in practice, do macros generally only use a small subset of the language?


notjack
2020-8-11 00:01:17

They tend to usually avoid IO and threads


notjack
2020-8-11 00:02:10

but there are valid use cases for those in macros (such as generating code based on data in a file)


sorawee
2020-8-11 00:27:00

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.


samth
2020-8-11 01:01:49

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


yilin.wei10
2020-8-11 02:03:35

@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).


wanpeebaw
2020-8-11 03:00:01

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 ...


sorawee
2020-8-11 03:22:20

just kill compiled?


sorawee
2020-8-11 03:22:40

I mean, this is pretty much the conversation we have above…