Search
Tuesday, 11th of June 2019, 21:14:05 UTC
21:21:43
nirved_
heh, more fun with RAM https://rambleed.com/
21:22:24
remexre
is it possible to dispatch a method based on a (satisfies _) type?
21:24:06
pjb
remexre: the question is not whether it's possible, but whether it's wise to do it.
21:24:34
Bike
the type system isn't restricted enough to allow the way normal method dispatch works.
21:24:37
pjb
Bike: well, the not really comes from the fact that testing for satisfies doesn't necessarily call the satisfying function.
21:24:57
pjb
remexre: but you can do something similar just giving the predicate.
21:25:10
pjb
remexre: it takes less time to implement it than this discussion so far, by the way.
21:26:03
remexre
how, then? I'm currently doing (defmethod foo (bar (baz (satisfies quux))) ...), but CCL throws an error at this
21:26:26
remexre
Illegal arg (SATISFIES QUUX)
21:26:31
Bike
that's because it's not allowed.
21:26:50
Bike
methods dispatch on EQL specializers (eqling a particular object) or classes, and satisfies types aren't classes.
21:26:51
aeth
some libraries dispatch on types
21:27:03
Bike
you could extend the system to dispatch more generally, but then you lose a lot of properties of clos.
21:29:48
Bike
and of course you could just have a body like (if (quux baz) thingone thingtwo).
21:30:36
remexre
I'm using (eql) in other places and need to be able to keep adding more (eql) variants
21:31:25
remexre
I guess the satisfies ones are finite so I could put them in a default one?
21:31:38
Bike
i don't know what you mean by "finite".
21:31:52
remexre
er, don't need to be extended
21:32:35
White_Flame
that sounds appropriate
21:32:46
remexre
I'll give this more thinking; thanks all!
21:34:27
semz
Bike: what properties would be lost by a more general dispatch?
21:35:11
Bike
a lot of clos's rules are about being able to translate a network of subtype relationships into a line, the class precedence list.
21:35:31
Bike
once you have that you can have a defined order for methods running.
21:36:22
Bike
satisfies types are completely arbitrary, which means they can overlap in disorganized ways. worse, figuring out the subtype relationship at all is impossible.
21:37:18
dagg
Hello. Can I pass a default arg to function? I. e.:
21:37:19
dagg
(defun test (&optional (a 0) (b 0)) (list a b))
21:38:10
Bike
you have to specify the default.
21:38:31
Bike
you can't leave one argument unprovided but provide the next.
21:38:38
Bike
if you want to do that, use &key instead.
21:38:59
dagg
The function #'test is given.
21:39:18
dagg
Why this feature is so commonly used, if it makes code so unflexible, I wonder.
21:39:40
dagg
Instead of the approach normal for Scheme (or Emacs Lisp): (setf a (or a 0)), I mean.
21:39:42
Bike
i think there is actually a bias against &optional in new code. maybe only a little, though.
21:40:01
Bike
functions sometimes do that too.
21:40:15
Bike
like a lot of the standard printing functions.
21:41:01
pjb
remexre: https://pastebin.com/grqu04NG
21:42:40
pjb
remexre: https://pastebin.com/QwTqpYzL
21:45:16
remexre
pjb: huh, okay, I'll give those a look in a bit; thanks!
21:46:15
pjb
remexre: now of course, if you have a lot of methods, you may want to be more efficient in find-predicate-dispatch-method. eg. you can use a tree instead of a list. or a tree of hash-tables, etc.
22:05:42
didi
Curious limitation: the size of a byte is unchangeable after the stream has been created.
22:06:09
didi
Not that I ever had to use a byte size different than 8.
2:53:24
beach
Good morning everyone!
5:01:14
hatchback17645
(find-all-symbols store-here)
5:13:19
beach
hatchback17645: Are you new here?
7:22:16
sindan
Is there a way for a function to access the call stack without calling up the debugger?
7:23:03
jackdaniel
sindan: try trivial-backtrace library
7:23:21
jackdaniel
there are also some bits for that in swank, but you'd need to look into it yourself
7:23:42
jackdaniel
I think that someone made yet another library for that but I can't recall the name nor the author
7:25:10
sindan
trivial-backtrace is all I need
Wednesday, 12th of June 2019, 9:14:05 UTC