freenode/#lisp - IRC Chatlog
Search
7:54:30
beach
But we can't consider this situation illegal, so it makes no sense to mark U1 as abandoned and signal an error in the initial transfer.
7:57:11
beach
Or else, we have different concept of "abandoned" for UNWIND-PROTECT, meaning "don't execute the cleanup forms again".
7:57:17
scymtym
i was thinking about modeling the exit point/uwp stack more explicitly and turning 5.2 into an algorithm (or more than one, if there are multiple possible interpretations) to get a more formal grip
7:58:25
beach
Good idea. And that is basically what I am trying to do, because I am planning to implement this stuff for SICL. But you are right, an more formal algorithm is probably a good start.
8:00:38
beach
The other slight quirk is that, as a result of RETURN-FROM, the exit point is abandoned and cannot be used again. But as a result of GO, the exit point is still valid.
8:04:21
beach
More quirks: 5.2 says "Not that for go, the exit point is the form within the tagbody that is being executed at the time the go is performed;...."
8:05:50
beach
So if I have (tagbody (f) (g) out) and (f) happens to do a (go out), then the exit point is (f)?
8:07:47
scymtym
one could also argue the statement containing the GO form, but the GO form itself is strange
8:10:18
beach
So 5.2 says that exit points are forms, but the glossary says that they are points in a control form.
8:13:38
beach
It seems to me that a "point" is either before a particular form is about to be evaluated, or immediately after a particular form has been evaluated. Or something like that.
8:15:15
scymtym
the static aspect sounds like program points. but the ability to abandon exit points requires some kind of attached dynamic state
8:21:05
beach
It should be defined somewhere that the program point corresponding to the end of the evaluation of the last form in the body is one where special variable bindings established by the lambda list are undone before control returns to the caller.
8:23:08
scymtym
time to look into formal semantics for common lisp? i would be surprised if that hadn't been attempted before, though
8:24:23
beach
We had to make some of it formal in Cleavir (especially in version 2), where we have the concept of a "compilation context" that says how values are to be used, and what the successor forms are.
8:27:41
beach
Hmm, maybe if I just document what Cleavir2 does, while avoiding direct references to its data structures, it would be a good start.
8:28:11
scymtym
yeah, i said the above half-jokingly. some kind of middle ground in terms of formality may be best since formal semantics for all of common lisp seems daunting
8:31:05
beach
*sigh*, I think I just signed up for yet another huge task. But I can't put what I am doing on hold, so it shall have to wait, or I can do it in parallel with my current tasks.
9:08:53
beach
So at least I convinced myself that the previous example with B1 B2 U1 U2 is not a problem.
9:09:39
beach
The "unwinder", i.e. the procedure that executes the steps of section 5.2 is basically executed as a result of a function call.
9:11:13
beach
If U2 executes the unwinder again, that second invocation will end with a non-local jump to B1, and the first invocation of the unwinder will be automatically eliminated.
10:29:56
isBEKaml
How can I define optional arguments with default values in defuns? as an example: (defun factorial (n (acc 1)) ...) ?
10:32:22
White_Flame
acc = defaults NIL. (acc 1) = defaults 1. (acc 1 acc-p) = the acc-p boolean tells you if the caller actually included that parameter or not
10:32:40
White_Flame
the latter, because (factorial 3 1) is ambiguous as to whether the 1 was passed or defaulted
10:32:59
isBEKaml
White_Flame: yeah, I vaguely remembered seeing something like that in PG's ANSI CL book
10:33:34
White_Flame
also, there's #clschool for basic questions, a lot of responses will get advanced here
10:34:28
isBEKaml
thanks, I have worked around my failing memory with labels in that factorial function now
12:03:40
beach
To me, it is looking more and more like the authors of the standard had some very concrete implementation of the dynamic environment in mind, and that they tried to avoid such a concrete description in the standard, in favor of some more abstract language. The net result is a loss of precision, and also some contradicting terminology.
12:05:00
beach
I am currently trying to recover that concrete description. And then I will try to find a better way of turning it abstract so that no precision is lost. I am not sure that I will be able to do that though.
12:15:29
beach
It is interesting how one can think that one knows a language pretty well, but then when one tries to create an implementation of it, one discovers several holes in one's knowledge about it. And some holes in the specification of it as well.
12:37:15
ralt
a simple single-threaded event loop using only lisp and some small cffi wrappers is not too hard to do
13:46:41
Xach
i used it to do async dns and async http to have bounded response times for a web app.
13:52:17
ralt
Xach: yes, that's my point, a custom single threaded one is fairly straightforward once you have epoll
13:53:45
Xach
i cheated and didn't use the system resolver, just parsed resolv.conf and did direct networking myself. which does not work in all situations but did for me.
14:05:56
dlowe
I have no idea how this got called grovelling - maybe it's basically a form of giving up and begging other languages to do things
16:20:45
beach
Here is another question: Suppose we have a dynamic environment with entries C1 B C2 U, where C1 and C2 are CATCH entries with the same tag (say C), B is a BLOCK entry and U is an UNWIND-PROTECT entry. C1 is the oldest and U is the most recent. Now we do a RETURN-FROM B. So C2 is "abandoned". Then we run the cleanup forms in U. Suppose that U does a (THROW C). Is this operation invalid because C2 has been "abandoned", or is C1
16:25:34
beach
(catch 'c (block b (catch 'c (unwind-protect (return-from b) (throw 'c (values)))))) or something like that.
16:27:26
Bike
the clhs page for throw says it goes to "the most recent outstanding catch". I think interpreting "outstanding" to mean "not abandoned" is reasonable, and there's nothing to force the abandonment of C1, which is not an intervening exit point
16:28:12
Bike
also "the cleanup clauses of an unwind-protect see the same dynamic bindings of variables and catch tags as were visible when the unwind-protect was entered" in 5.2.
16:28:34
Bike
...well, i guess that kind of contradicts the intervening points invalidated thing, doesn't it
16:29:10
beach
I am wondering whether this is the exact example shown in the THROW dictionary entry.
16:30:51
Bike
No in that case the initial throw is to the same catch that the second throw ends up in - invalidation isn't relevant. i think.
16:34:08
Bike
i still don't really get the point of the "intervening exit points are invalidated" thing. the committee issue makes it seem like the point was to make it easier for implementations but that doesn't seem to actually be true
16:48:39
beach
Bike: I think that it will be harder for some implementations with their chosen strategy. But then, they let the implementation choose by making it undefined behavior.
17:11:25
proto
I can't figure out what makes functional programming better or even worth to use, rather than imperative programming. Functional programming restricts and establishes some guarantees, but this could easily be established with imperative programming languages as well.
17:13:05
dlowe
it's functional in that functions are first class objects, but it has iteration and global variables and stuff
17:16:22
edgar-rft
because in Common Lisp you can *combine* imperative, functional, OOP. whatever style in *one* program
17:17:20
dlowe
You can, but the fact that you might screw it up means that your cognitive load is not reduced so much
17:17:29
shka_
but oh my god, writing large systems this way is impractical and i don't think i know anyone that does that
17:19:37
shka_
proto: try passing void* as explicit closure every time and you will quickly loose your mind
17:20:23
shka_
also, you can't just (lambda (x) (+ x y)), you will have to define function elsewhere, and then the state, and then initialize the state…
17:22:51
proto
shka_: give me the simplest example of a closure, and why they are far superior to a simple struct with methods.
17:26:27
proto
No. I don't that at all. I am just applying doubt to obtain certainty and understanding.