freenode/#lisp - IRC Chatlog
Search
18:58:03
skidd0
oh i see. so a nick "skidd0" joins the channel, sends a query over to the bot to auth, then can give commands
18:59:49
skidd0
well i'd be keeping a list of authorized nicks, so if they change nick, they lose auth
20:13:33
aeth
This was mentioned in #lispcafe, but I think #lisp might appreciate this. I finally found a case where "RETRY" is the correct solution for handling a type error with the SLIME debugger.
20:13:37
aeth
(let ((x `(progn (format t "Hello, world!~%") (make-random-state) (zerop (random 2))))) (check-type x (satisfies eval)) x)
20:17:26
pjb
aeth: well, this is a very good example against types I would say. You should not use check-type here, but (assert (eval x) (x)).
20:17:56
jmercouris
only when debugging of course, I wouldn't have such a restart in production code..
20:17:59
Bike
good job managing to say something entirely reasonable in the face of "(satisfies eval)"
20:19:35
aeth
Bike: Couldn't there be an implementation where eval always starts with the same random state so that will be always t or always nil?
20:20:23
pjb
aeth: I don't think so. eval shall use the nil environment, which is the global environment. If it took a fresh environment, it couldn't use the user defined packages and functions, and it couldn't mutate the current environment.
20:20:53
aeth
pjb: okay, so if that gets caught one way or the other I guess it's non-conforming, then
20:21:34
pjb
ccl -x '(let ((x `(progn (format t "Hello, world!~%") (zerop (random 2 (make-random-state t)))))) (check-type x (satisfies eval)) x)'
20:22:25
pjb
Inside a running image, it can be non-deterministic, if you run random expressions before this one.
21:39:00
no-defun-allowed
pjb, aeth: (satisfies eval) was a meme i made late last night when i couldn't sleep
21:53:13
stylewarning
whartung: here's an instance of CERROR: https://github.com/rigetti/quilc/blob/master/src/transformable-mixin.lisp#L128 and here's a case of taking advantage of that restart: https://github.com/rigetti/qvm/blob/master/src/qvm.lisp#L159
22:00:28
whartung
I see the (invoke-restart 'continue), but I don’t find “continue” anywhere else in that code.
22:00:29
stylewarning
whartung: to goes back to the site of the CERROR, and continues just after that error
22:00:33
stylewarning
whartung: it keeps track of how many times it "retries" so that it doesn't go into an infinite loop of CERROR -> INVOKE-RESTART -> CERROR -> ...
22:01:59
whartung
sure, but, I mean, I haven’t studdied this in detai, but where does it do anything to try and mitigate the missing dependancy when it discovered the issue?
22:02:56
stylewarning
whartung: it calls (transform xform-to-do instance), which satisfies one of the required dependencies, decreases the no. of allowed attempts to recover, and loops back to check if all deps. are satisfied
22:05:18
stylewarning
whartung: here is another example of a custom-defined restart called TRY-NEXT-COMPILER. If a compilation function fails, it gives either the user (interactively) or the caller (non-interactively) an option to keep on trucking with compilation. https://github.com/rigetti/quilc/blob/master/src/compilation-methods.lisp#L71
22:05:36
whartung
coudn’t this have been readily done without a restart? just not sure how this case highlights the use of a restartable condition vs not.
22:11:21
p_l
whartung: the crucial difference is that the stack is not unwound, so you don't have to do crazy things to checkpoint and restore state
22:21:12
stylewarning
whartung: The latter one is certainly used interactively, I forget if there are non-interactive invocations
22:21:48
stylewarning
whartung: most of these can be avoided if you can sufficiently pass data about decision-making up and down the call stack
22:24:05
sjl
I use them in my option parsing library. If the library parses command line options and sees an unknown option, it signals a condition and lets you choose between a number of different restarts if you're working interactively: https://github.com/sjl/adopt/blob/master/src/main.lisp#L362
22:24:31
sjl
But if you're writing a program that uses my option parser and want to just ignore unrecognized options, you can choose to invoke the restart programtically https://github.com/sjl/adopt/blob/master/src/main.lisp#L302
22:24:58
sjl
or choose the "treat as normal argument" restart programtically instead https://github.com/sjl/adopt/blob/master/src/main.lisp#L314
2:09:09
PuercoPope
Xach: Don't know if you are aware but https://www.xach.com/clhs has been returning 502 for the last few days. Its my goto search method when outside of Emacs.
4:00:13
fiddlerwoaroof
whartung: before I learned CL, I implemented restarts myself in Python to facilitate a major data migration from a schemaless database to one with a strictly enforced schema
4:00:48
fiddlerwoaroof
It saved me numerous cases of "wait half an hour for a crash to happen, change the code and wait half an hour to see if the fix worked"
4:01:56
fiddlerwoaroof
Although this was a semi-interactive situation: when there was an exception, I'd inspect the data, add a rule to handle it to a collection of rules and then restart the migration process which could now handle the new category of malformed data automatically.