libera/#commonlisp - IRC Chatlog
Search
9:45:19
aeth
It predates :keywords? Either that or because at one point you'd have to have specified your &key arguments with :keywords like that
12:31:06
nij-
Why do we say that handler-case unwind everything (worse), but handler-bind is able to preserve the stack?
12:31:23
nij-
This is the example i'm looking at. It seems that they are doing pretty similar things: https://bpa.st/3XAQ
12:32:48
nij-
Yeah my question is .. why is it so, given that they seem to do pretty similar things in the examples I gave.
12:33:39
jackdaniel
nij-: in handler-bind handlers you have access to the dynamic context of the error
12:34:05
jackdaniel
i.e special variable dynamic values may differ, the call stack may be different etc
12:34:32
jackdaniel
handler-case serves another purpose (and may be implemented in terms of handler-bind)
12:35:58
jackdaniel
what do you think about a function name fearless-handler ? a handler that always invokes the restart "continue" when present
12:38:12
Nilby
jackdaniel: having sufferd from having some accidentally fearless handlers, i can say you'll likely spend a lot of time back at top-level without much clue why
12:39:59
jackdaniel
Nilby: I wouldn't put it in the code; I'm tinkering with the bootstrap environment (there is no debugger available then, so it is either _ecl_unrecoverable_error(c); or cl_funcall(1, continuation);
12:43:51
jackdaniel
also if you are clever enough, you don't need to cons a function for the handler body
12:44:14
Nilby
handler-case saves you the step of having to do some restart/return if that's what you want
12:44:51
jackdaniel
I have a macro in my toy utilities handler-case* that executes the body in the dynamic context and only after that returns
12:44:56
Nilby
nij-: sometimes you might even want forms wrapped in both handler-bind and handler-case
13:02:06
nij-
pjb in your (/ 1 0) example, handler-case is better because it's a bit shorter than (handler-bind ((error (lambda (c) 'infinite))) (/ 1 0))?
13:05:25
nij-
Oh I see what you mean. (handler-case (/ 1 0) (error () 'infinite)) handles the error.
13:07:54
phoe
yes, if a handler function returns normally without transferring control then that's the definition of "declining to handle a condition"
13:07:55
jackdaniel
handler-bind may be used in many interesting ways - i.e change the dynamic state and leave the rest to the next handler
13:10:09
nij-
So why is the condition unhandled in (handler-bind ((error (lambda (c) 'infinite))) (/ 1 0))?
13:10:32
nij-
In phoe's example, it doesn't seem to be handled either, no? You just redirect the control flow.
13:10:47
specbot
Condition System Concepts: http://www.lispworks.com/reference/HyperSpec/Body/09_a.htm
13:11:04
phoe
"If a handler is invoked, it can address the situation in one of three ways: Decline (...), Handle (...), Defer (...)"
13:14:37
nij-
Oh, I see! "HANDLE: It can handle the condition by performing a non-local transfer of control."
13:16:53
phoe
it can be CL, it's just not the condition system - it's a continuation-passing style program
13:18:20
phoe
(lambda (resolve reject doubt) ...) is the modern approach, you gotta leave space for what happens in case of e.g. a network partition
13:19:22
jackdaniel
the "continuation" part is for when you invoke stuff like cerror, the rest is the same as with cl (more or less)
13:20:45
nij-
Thanks phoe! By the way, I have your book physically lying around me. Feel like it's the right time to read :D
13:21:09
hayley
Post-modernists are just modernists in denial - I say it as their Postgres library undoubtedly uses CPS :)
13:25:27
varjag
let's say i have a list of sorted numeric lists, and i want to collate it: '((3 4) (3 7) (5 7 9)) => ((3 3) (4) (5) (7 7) (9))
13:25:34
jackdaniel
and we have a proof that they are not forgotten ssh session on sdf - thanks to the great libera chat migration
13:33:15
pjb
jackdaniel: it is possible to plug-in languages for stored procedure, so theorically, you could hook ecl into postgres.
13:34:58
Nilby
varjag: (mapcar #'cdr (sort (group-by-alist #'identity (flatten '((3 4) (3 7) (5 7 9)))) #'< :key #'car))
13:35:09
jackdaniel
aren't you asking too many specific questions for an early stage of the project?
13:36:23
jackdaniel
'whole cl runtime' is a vague term, especially when we assume that some modules may be lazily loaded (or error if they requested but not present)
13:37:42
Bike
(reduce (lambda (l1 l2) (merge 'list l1 l2 #'<)) '((3 4) (3 7) (5 7 9))), just to actually use merge for once
13:37:43
jackdaniel
and what is common lisp if not a dozen of special operators plus a huge standard library, hm?
13:40:16
Nilby
to fit CL in small things you'd probably have to discard modern things such as unicode
13:40:47
jackdaniel
well, I'll update you on the progress if I have anything to show, probably on my blog ;p
13:42:29
jackdaniel
generally if we are picky, then storing all standard symbol names in memory is huge
13:47:13
jackdaniel
you have a name, two values (function and variable), type, home package, property list
13:51:07
phoe
even then, I assume you could stuff all standard CL symbols into ROM; the only "property" that can change about them is symbol-plist, right?
14:05:27
jackdaniel
either way even if I fail, some improvements are already made in a process, most notably delimited continuations are back (not pushed yet)
14:10:47
jackdaniel
I've defined it the same as it used to be in ecl before green threads were removed (see commit 0312839e1 for documentation)
14:16:21
Bike
i don't understand how you could do like shift/reduce with this. having external continuations is cool, though
14:22:38
jackdaniel
I'll see how these examples may be implemented with what ecl has now before making a pull request; that will surely make a good program for examples/
15:11:23
nij-
With CFFI, can I execute any C code on the fly? Something like (cffi:execute "int fn () { \n return 0;\n }")?
15:12:00
nij-
Or I must use that code to produce a shared library separately, and load it with CFFI?
15:31:05
nij-
Got it. But I can always write a wrapper in C that writes the C code, compiled to SO, and load.
15:33:33
nij-
I've heard though that C oughts to be compiled, and no interprettor can really do what the compile does semantically.
15:37:12
Bike
nah, there are c interpreters. and actually, in modern C++ (which isn't C, but eh) constexpr probably means a compiler has to have some kind of interpreter in it as well.
15:39:07
nij-
Oh, I even recall that emacs have both (compiler and interpreter), and it's hard to converge their semantics.
15:40:59
beach
There is a long-ish Lisp tradition that the interpreter uses dynamic variable bindings and the compiler uses lexical variable bindings, but that tradition was abandoned (luckily) in Common Lisp.
15:43:18
Bike
there are differences between compiling and evaluating, but they're pretty minor and mostly relate to redefinitions.
15:43:43
nij-
If C even has a JIT compiler, then we don't need to worry about possible divergence in semantics.
15:43:57
beach
I also recall that Franz Lisp (not Allegro) went to a lot of trouble to make the compiler respect dynamic variable bindings for many things.
17:01:36
White_Flame
nij-: I think it would actually be harder to write a JIT compiler for C than other languages. It would be harder to infer what runtime heuristic info you need to collect to get any benefit
18:40:02
luis
Someone at ELS did some work on method inlining, or some sort of class sealing and I can't recall who. Does anybody have any idea what I'm talking about?