freenode/#lisp - IRC Chatlog
Search
13:16:13
madrik
In these situations, if an end-of-file value besides nil is used, would that value be freshly made on each loop iteration? Or is it reused, once made?
13:19:29
madrik
beach: Ah, I see. Macroexpanding the code shows that eof is let-bound before the loop proper. Okay.
13:21:14
shka_
wheter the value returned from the read-line function is the same is the same instance as the one constructed in with clause
14:11:16
pjb
Some would say that (loop for line = (read-line stream nil nil) while line) is idiomatic. Personally, I don't have problem eliding the explicit test for NIL in lisp. However, in C I started to test explicitely for NULL when testing pointers, because 0 as a symbol representing the null pointer is true only in some context. Notably, and horribly, when as argument to a function, 0 is not interpreted as the null pointer, but as an in
14:13:27
pjb
For example, CL:AND and CL:OR are very explicitely defined to return the first or last values of the argument expressions. So using (or var :default) or (and (predicatep foo) foo) are perfectly readable, just as: (loop while line) is.
14:16:58
beach
pjb: That's one leap you just made. Essentially, you are saying that anything that is semantically well defined by the language is readable to the maintainer.
14:18:06
TMA
I even use '\0' in comparisons because of the intent is more apparent (and while '\0' is equivalent to 0 in C, it is not in C++); the same goes in lisp: make the intent apparent, preferably without needless reference to something external
15:43:37
beach
My guess is that the first C compiler was not terribly smart, so you had to write code like that to get the best performance. That changed with GCC.
15:49:12
madrik
Maybe it's just looking to the past, but I get a kick out of thinking that there used to be implementations of other languages besides Lisp on the Lisp machines.
15:50:41
dlowe
I've wondered if it'd be possible to do FFI in sbcl by providing a libc implementation that used underlying sbcl code, so that allocated memory would be gc'd as usual
15:51:45
dlowe
as far as I know, all the CL implementations keep non-CL code in its own little space
16:03:18
pjb
schweers: well, since char are upgraded to int when passed as parameter and in other places it's essentially the same.
16:04:37
pjb
The difference would be '\0'+'\1' = (char)1 instead of 0+'\1' = (int)1, but againm since (char)1 would be upgraded, I don't remember any circumstance where it would make a difference. (but there may still be one obscur case).
16:07:06
pjb
(let ((s #(1 2 3 4)) (d #(1 2 3 0)) (i 0) (j 0)) (loop :while (= (prog1 (aref s i) (incf i)) (prog1 (aref d j) (incf j)))) (list i j)) #| --> (4 4) |#
16:08:23
pjb
(let ((s #(1 2 3 0)) (d (vector 0 0 0 0)) (i 0)) (loop :while (prog1 (plusp (setf (aref d i) (aref s i))) (incf i))) d) #| --> #(1 2 3 0) |#
16:09:04
pjb
(let ((s #(1 2 3 0)) (d (vector 0 0 0 0)) (i 0) (j 0)) (loop :while (prog1 (plusp (setf (aref d i) (aref s j))) (incf i) (incf j))) d) #| --> #(1 2 3 0) |#
19:16:31
phoe
I have two trees of CLOS instances that form a cyclic graph. How can I compare them for equality? For slot values that are not standard instances, I'd like to use EQUAL; for slot values that are standard instances, I want to recurse while marking the instances I have already visited to avoid loops.
19:16:53
phoe
These instances are of different types; I also want to ensure that the respective instances are of the same type.
19:18:16
pjb
If you have associations that have a multiplicity more than 1, then there could be an abiguity, and you might need backtracking.
19:18:58
pjb
Otherwise, you will need a walk of the two graphs. You can keep the nodes that are already walked in a hash-table.
19:20:11
phoe
All instances have some sort of ID however, so I can sort them by that ID in each list and then assume that the order is the same.
19:20:48
phoe
Or, whenever I traverse one graph, I get the ID of the current instance, find the matching instance in the other graph, and use that instance for comparing the slot values.
19:20:51
pjb
Then you will have to backtrack. If you have a->nb and A->nB and a=A, then you will have to try n*(n-1) b=B.
19:21:27
phoe
Will I have to, if they are ordered? I can treat these collections as ordered, meaning that 1st element of one collection must be equal to 1st element of the other collection.
19:22:24
pjb
phoe: well, that depends if the two graph share the same nodes, or only nodes that are equal?
19:23:17
pjb
Ok. Then yes, you can have a subalgorithm to match the list of nodes in the same association.
19:24:55
pjb
There were a couple of math libraries developed in Japan. Perhaps they had something about graph, I'm not sure.
20:01:25
Xach
Josh_2: (asdf:load-asd "/path/to/file") I think. Although I note that I just tried that on a bogus pathname and it returned something, so I don't know what to expect any more.
20:31:32
pjb
phoe: actually if you have a graph that knows its list of nodes, we don't need to walk the graph, just process the list of nodes (and we have to). On the other hand, if the graph is connected, and we only have one "root" node, then we need to walk it.
21:39:18
fiddlerwoaroof
You should be able to do something like (let ((buf (make-string 10))) (read-sequence buf socket-stream) buf)
22:43:59
pillton
schweers: (loop for var = (allocate-lots-of-resources) do ...) is enough to trigger problems if you rely on finalizers.
0:28:18
fiddlerwoaroof
Speaking of which, nyef used to be really active here and in #sbcl, but I haven't seen them around in a year or so
1:06:10
Josh_2
am I missing something here because unwind-protect isn't shutting the socket when test crashes Q_Q https://plaster.tymoon.eu/view/1109#1109
1:11:49
Bike
i mean, you say test "crashes", but that means it signals an error and the debugger comes up, right?