freenode/#lisp - IRC Chatlog
Search
18:45:20
aeth
I seem to rely on booleans (rather than generalized booleans) in two cases: (1) I'm storing something so the general boolean value would just be unwanted noise, e.g. something with :type boolean in e.g. a struct; or (2) I need to make a distinction past just having true/false, so e.g. keywords and t and nil all have some meaning in the API.
18:46:06
aeth
(for the second one, consider an API where t is default, nil disables it, and the keywords are niche alternate behaviors)
18:47:08
aeth
Neither are the return values, though. They're input values. And that's in the standard, too, e.g. with FORMAT. Generalized booleans are too useful in return values because you never know if the caller wants to use the extra information or not and that saves an extra return value.
18:49:19
aeth
Similarly, I also always return nil (or, more rarely, t) even if the function is only used for its side effects. Some do (values) but that might break code that uses certain multiple-value functions/macros (and everywhere else it just inserts a NIL return value)
18:51:45
aeth
Bike: Well, I mean, you could be using multiple-value-call to call a function that has the mistaken assumption that every function returns at least one value, which isn't true for those extremely rare functions that end in (values)
18:52:57
aeth
It sounds like it would never happen, but that's exactly the sort of thing that if it did happen someone will lose a day or two on it because no one thinks it would happen
18:53:11
pjb
aeth: also, it's good to use T/NIL instead of generalized boolean to give the garbage collector an opportunity to do some work.
18:54:52
aeth
pjb: Which means that it's "perfectly safe" (in a reasonable implementation) to return a fixnum or single-float or other, similar things that (probably) aren't boxed.
18:56:26
aeth
pjb: If you're talking about storing, then, yes, definitely, t/nil helps with the GC always. You don't want to accidentally refer to some hash-table of 40,000 elements that could have been collected hours ago if you didn't store a reference to it instead of t
19:44:50
Bike
ecl has some code to make things like (error '(or type-error simple-condition) ...) work. does anybody use such a thing? https://gitlab.com/embeddable-common-lisp/ecl/commit/c6e419101400ee5d4372d748f646011b1480d0a2
19:47:24
Bike
well, clhs says make-condition's first argument is a subtype of condition, so i guess it could be understood as standard
19:47:26
pjb
Bike: it looks like it's conforming! type---a type specifier (for a subtype of condition).
19:48:55
Bike
no, i mean the function ERROR takes a condition designator, and a condition designator is either a symbol or a format control or a condition.
19:49:02
pjb
Bike: error takes a condition n. 1. an object which represents a situation---usually, but not necessarily, during signaling. 2. an object of type condition.
19:49:39
Bike
yes and the designators are clearly defined in 9.1.2.1 and specify a symbol, not any subtype. okay? okay. so does anyone actually use this thing.
19:49:58
pjb
This is a great find! I've been definining conditions just to mix simple-condition with my errors!!!
19:50:43
Bike
well if you did (make-condition '(and my-error simple-condition) ...) that could still just be an empty type.
19:51:22
Bike
it's also in clasp, which is why i'm asking. dunno about others but i sorta doubt it. i'll check sbcl.
19:52:05
pjb
Bike: you're right about 9.1.2.1, but ERROR is specified to accept and OR type specifier, and MAKE-CONDITION is explicitely designed to accept it.
19:53:08
aeth
Tangentially related, but I'd say the weakest part of the standard is conditions. Didn't someone here write their own destructuring-bind just to get a consistent cross-implementation condition there?
19:53:46
pjb
Bike: error is specified to take a designator to a condition (glossary) with a very large definition.
21:58:17
t58
Hey I'm using slime with emacs is there a shortcut to close all the open parens? I'm sure there was one like C-c C-q or something like that but I can't find any reference to it online.
22:17:43
White_Flame
and paredit is highly recommended, nearly always keeping things balanced (except for cut'n'paste)
4:08:35
p0a
I'm familiar with emacs but it's been so long I've done some CL that I don't know what' sup
4:09:26
beach
I don't know about Debian in particular, but that combination is probably the most frequently used by #lisp participants.
5:05:22
p0a
but I don't want to have them run concurrently. I realize I can have 3 loop macros but I'm just wondering
5:09:32
beach
(loop with result = '() for i in list do (loop for j in list do (loop for k in list do (push (list i j k) result))) finally (return result))
5:21:29
beach
p0a: (loop for (i . ii) on list nconc (loop for (j . jj) on ii nconc (loop for k in jj collect (list i j k))))
5:25:49
p0a
also, is there a way to check if a list of bools is all true without REDUCEing over AND?
5:29:16
beach
p0a: All I did was to use the remaining list in the nested loops, rather than the entire list.