<phoe>
you can see all the condition types present in figure 4-8
<phoe>
it would make no sense to have classes only for these and have everything else be just types that, somehow, aren't classes themselves
<phoe>
it would be more or less equivalent to bending over backwards to make use of multiple inheritance and defclass options in there without also defining new classes for each condition type
<phoe>
and let's not talk about DEFINE-CONDITION's :ALLOCATION :CLASS either
<phoe>
so the implications are already in the spec, I assume the committee just tried to satisfy a constraint of "what if we shipped a future variant of CL without CLOS but with conditions" and ended up with a little monster that is DEFINE-CONDITION that pretends real real hard that it ain't DEFCLASS
yottabyte has joined #commonlisp
<Josh_2>
can you imagine
<Josh_2>
someone who said such a thing should be banned
waleee has joined #commonlisp
seletz has joined #commonlisp
jello_pudding has quit [Ping timeout: 255 seconds]
seletz has quit [Ping timeout: 260 seconds]
Lord_of_Life has quit [Ping timeout: 248 seconds]
Lord_of_Life has joined #commonlisp
jello_pudding has joined #commonlisp
jolby has quit [Quit: Client closed]
jolby has joined #commonlisp
lucerne has quit [Ping timeout: 268 seconds]
danieli has quit [Quit: Ping timeout (120 seconds)]
jolby has quit [Quit: Client closed]
<jcowan>
there are just a bunch of irritations: why is VECTOR a class and SIMPLE-VECTOR is not?
<Bike>
i was going to say something, but then i noticed that string is a class, so you know what? i got nothing. (simple-string is not, though)
<ixelp>
GitHub - markcox80/specialization-store: A different type of generic function for common lisp.
<aeth>
but it lets you do things like write generic dispatch on simple-vectors of length 2, 3, and 4 of element-type single-float and double-float. Things like that
<aeth>
That you just don't get classes exposed for (and length wouldn't even be exposed even in that case) but you do get types
<jcowan>
interesting, thanks!
<aeth>
seems mostly useful for vectors and numbers
<aeth>
where the type system is richer than the class hierarchy
triffid has quit [Ping timeout: 255 seconds]
dipper_ has quit [Remote host closed the connection]
triffid has joined #commonlisp
tyson2 has quit [Read error: Connection reset by peer]
xaltsc has joined #commonlisp
yottabyte has quit [Quit: Connection closed for inactivity]
triffid has quit [Remote host closed the connection]
triffid has joined #commonlisp
waleee has quit [Ping timeout: 246 seconds]
akoana has quit [Quit: leaving]
seletz has joined #commonlisp
seletz has quit [Ping timeout: 248 seconds]
Lord_of_Life has quit [Ping timeout: 260 seconds]
Lord_of_Life has joined #commonlisp
jealousmonk has quit [Remote host closed the connection]
lucerne has joined #commonlisp
nij- has left #commonlisp [Using Circe, the loveliest of all IRC clients]
jello_pudding has quit [Ping timeout: 246 seconds]
rainthree has joined #commonlisp
rainthree3 has joined #commonlisp
rainthree has quit [Ping timeout: 260 seconds]
seletz has joined #commonlisp
seletz has quit [Ping timeout: 272 seconds]
Lord_of_Life has quit [Ping timeout: 260 seconds]
Lord_of_Life has joined #commonlisp
causal has quit [Read error: Connection reset by peer]
causal has joined #commonlisp
ttree has quit [Ping timeout: 255 seconds]
lucerne has quit [Read error: Connection reset by peer]
azimut_ has quit [Remote host closed the connection]
anticomputer has quit [Ping timeout: 255 seconds]
gxt has quit [Remote host closed the connection]
azimut has joined #commonlisp
anticomputer has joined #commonlisp
gxt has joined #commonlisp
ec_ has joined #commonlisp
triffid has joined #commonlisp
anticomputer has quit [Remote host closed the connection]
amb007 has joined #commonlisp
anticomputer has joined #commonlisp
aartaka has quit [Ping timeout: 260 seconds]
aartaka has joined #commonlisp
chipxxx has joined #commonlisp
_cymew_ has quit [Ping timeout: 246 seconds]
nij- has joined #commonlisp
<nij->
Can I add types in the signature of functions? Or should I always add assert forms in the body of the function?
<nij->
Something like (type-defun add ((x :int) (y :int)) (+ x y))
<beach>
You can do that for methods, provided your types are classes too.
<beach>
(defmethod add ((x integer) (y integer)) (+ x y))
<nij->
Or I can just define the macro type-defun by myself, which adds assert forms in the beginning of the body..?
<nij->
Yeah.. I'm really looking for types, not classes.
<beach>
What kind of types that are not classes are you considering?
amb007 has quit [Ping timeout: 255 seconds]
amb007 has joined #commonlisp
<nij->
Hmm.. good question. I'm still thinking what I really want.
<nij->
But in general, I think what type system offers are pretty different from what an class/object system offers.
<nij->
And what I'm looking for is really a system that checks the types.
<nij->
(to avoid errors)
_cymew_ has joined #commonlisp
<beach>
I think that you are underestimating the number of types that are also classes, which is why I asked what kind of types you are considering.
cdegroot has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
<beach>
I also think you might be to focused on types too early in the development process. Perhaps because you come from a statically typed language.
<nij->
There maybe a better way to elaborate, but here's my issue:
<beach>
s/to/too/
<nij->
Currently I wrap data (to be sent between functions) in hash tables, instead of structs or classes.
<nij->
For example, a hash table could have three slots :a :b :c
<nij->
but sometimes there may be a hash table that only has two slots :a :b
<nij->
instead of defining classes or subclasses for such kind of hash tables
<nij->
I only want my functions to check if the input is a hash table that has at least slot :a and slot :b.
<nij->
And I don't want to do this in an adhoc way (e.g. putting assert forms in the body of functions)
<nij->
I want to be able to say, "Ok, all hash tables with at least slots :a and :b are called 'Monkeys' from now on".
<beach>
But the only way to express that as a type is using SATISFIES. Plus, by using hash tables, you probably take a great performance hit. Accessing the slot of a standard object is usually a very fast operation.
_cymew_ has quit [Ping timeout: 255 seconds]
<nij->
And then I can define my functions as, something like, (type-defun play-with ((x :monkey)) (kill x))
<beach>
And, the reason you need to test that explicitly, is precisely because you are not using a standard class.
<nij->
beach: there's a difference between accessing the slot of a standard object v.s. a hash table?!
<beach>
Yes, a hash table needs hashing.
<Bike>
yeah this isn't javascript
<nij->
(I know no JS.)
<beach>
The operation is O(1) on the average but O(n) worst case.
<Bike>
and it sounds like you want structural typing, which is interesting, but not a native component of the type system, so you would be using satisfies indeed
<nij->
My hash tables have at most 15 slots.. is it still an issue?
<beach>
nij-: The issue is "why on earth would you not use standard classes instead?"
<Bike>
you could of course hide all this with a type-defun macro regardless
<nij->
beach Because I want to keep the slots names flexible.
<Bike>
I think there are a few "DEFUN*" sort of macros that do this kind of thing, but i don't know if they also include structural typing
<beach>
Well, then, you are pretty much out of luck unless you use SATISFIES.
<Bike>
You could use a CLOS extension and have objects with flexible slots. i know one of the jason libraries used to do that to mimic javascript's prototype system
<nij->
Also, in some languages the compiler even checks if the composition of functions passes type checks.
<nij->
Can we do that in CL?
<Bike>
Could you elaborate on what exactly that looks like. I can guess, but it might not be what you're thinking of
irc_user has quit [Quit: Connection closed for inactivity]
<Bike>
Generally speaking, the types of function arguments can't be checked. Some kind of gradual typing thing to do that would be pretty nice
<Bike>
(checked more specifically than "is a function", i mean)
<nij->
I see..
<nij->
Yeah, because the symbol can print to anything at runtime in CL..
<nij->
s/print/point/
<Bike>
Well, no, that's not what I mean, but that is also an issue, yes. We don't do much interprocedural anything.
<Bike>
if you block compile in sbcl i'm sure you can get some pretty specific type warnings, though.
<Bike>
since the block compile mechanism means you promise not to do any redefinitions of what you're block compiling
waleee has joined #commonlisp
<Bike>
what i meant was, in a static language like c or haskell or whatever, the compiler can just check function types like anything else, since the type system is carefully limited into computability, and is all available statically and doesn't so much need to be available at runtime
<Bike>
but that's very much not how lisp types work
<nij->
got it
<White_Flame>
however, there is still lots of room for JIT and runtime fast paths with escapes
<Bike>
sure, but nij was asking about type correctness, not optimization.
<White_Flame>
that would be runtime elision of type checks
<Bike>
there's a difference between eliding runtime type checks, and an actual guarantee that at compile time you get warnings if there would be a runtime problem.
<White_Flame>
"eliding runtime type checks" vs "runtime eliding of type checks" ;)
<White_Flame>
vs static eliding
<White_Flame>
anyway, yeah it is a little tangential to the original point
<White_Flame>
just something I'd like to explore at some point
Major_Biscuit has joined #commonlisp
<beach>
It seems nij- has chosen a language that is not adapted to the problem at hand.
<beach>
Maybe the thing to do is to create an embedded language that can express those things.
<nij->
coalton
<nij->
Nah, I will just use satisfies for now. Thanks :D
<Bike>
yeah, coalton is interesting for this.
McParen has joined #commonlisp
Major_Biscuit has quit [Ping timeout: 260 seconds]
<nij->
I think I can appreciate haskell more.. after these days.
<nij->
But wow, I can also appreciate different semantics. They do have their own advantages.
ldb has joined #commonlisp
triffid has quit [Ping timeout: 255 seconds]
triffid has joined #commonlisp
<pjb>
nij-: you can write (defun foo (a b c) …) (declaim (ftype (function (integer integer integer) integer) foo))
<pjb>
nij-: but this is dangerous, because it can make the compiler remove any type checking, since this is saying that you will ensure that the function will always receive integer arguments.
amb007 has joined #commonlisp
<pjb>
nij-: you can make programs crash like in C with type declarations.
White_Flame has quit [Remote host closed the connection]
<nij->
Why would taht make compiler remove type checking, instead of forcing it to check?!
<pjb>
nij-: this is how it's specified. Declarations are guarantees YOU are making to the compiler.
White_Flame has joined #commonlisp
<nij->
Oh, nice, there's also check-type. I thought I need to use assert.
<nij->
pjb i see
<pjb>
For methods, the classes specified in the parameter list are like run-time checks: they're used at run-time to dispatch on the class of arguments.
<Bike>
be aware that check-type will signal a _correctable_ error, which may not be what you want
<pjb>
nij-: the advantage of using check-type (in API functions), is that you get the conditions signaled closer to the API entry points, than if you defer it to internal type checking (like, wait for a (+ a b c) to signal a type-error).
<pjb>
For internal functions, you may want to avoid it.
amb007 has quit [Ping timeout: 268 seconds]
<pjb>
assert too can be interactive, if you use it with the list of places (assert (integerp result) (result) "Result should be an integer, not ~S" result)
<nij->
Bike correctable?
<pjb>
nij-: yes, you get restarts to change the value of the places.
<nij->
Oh, why is that an issue?
<pjb>
nij-: if you're coding the flight control of a rocket, you may want to avoid interactive debugging in the inner control loops.
rendar has quit [Quit: Leaving]
<nij->
phew~ i see. that's not what im doing.
<nij->
Still thanks :)
<ldb>
it is a feature for lisp to corrent a argument when the program is already running half way through instead of recompile and rerun the whole program
<Alfr>
pjb, why? Don't we reserve a special place on it for a programmer to fix such mishaps or die trying? :)
<Bike>
it means that a user (or program) can replace a value somewhere in the depths of your program, which may make other parts of the program behave unexpectedly
<Bike>
if you keep check-type at the api boundaries like pjb said it's probably not a big deal
<pjb>
Alfr: it depends if the loop is time critical or not. When you're not in a real-time loop, you can have interactive debugging. In time critical loops, you would want to handle all conditions automatically.
<ldb>
make correction while program is running vs. wait for compile & rerun & test loop
* Alfr
notes that he wasn't completely serious about the proposal.
<nij->
Thanks folks! Gotta head out :D
<ldb>
\/p
<ldb>
//o
amb007 has joined #commonlisp
aartaka has quit [Ping timeout: 248 seconds]
aartaka has joined #commonlisp
pfd has joined #commonlisp
tyson2`` has joined #commonlisp
amb007 has quit [Ping timeout: 255 seconds]
tyson2` has quit [Ping timeout: 260 seconds]
nij- has quit [Ping timeout: 272 seconds]
ldb has quit [Ping timeout: 272 seconds]
ldb has joined #commonlisp
ttree has joined #commonlisp
tyson2`` has quit [Remote host closed the connection]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
aartaka has quit [Ping timeout: 260 seconds]
aartaka has joined #commonlisp
rendar has joined #commonlisp
rendar has quit [Changing host]
rendar has joined #commonlisp
seletz has joined #commonlisp
seletz has quit [Ping timeout: 260 seconds]
ldb has quit [Ping timeout: 260 seconds]
tyson2 has joined #commonlisp
ldb has joined #commonlisp
tyson2 has quit [Ping timeout: 272 seconds]
<prokhor_>
Does anyone know a way how to change the superclasses of an exissting class without redefining it everytime? I try to build a class hierarchy incrementally...
tyson2 has joined #commonlisp
danieli has joined #commonlisp
cosimone has quit [Remote host closed the connection]
lisper29 has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
morganw has joined #commonlisp
ldb has quit [Ping timeout: 255 seconds]
aartaka has quit [Ping timeout: 260 seconds]
aartaka has joined #commonlisp
ldb has joined #commonlisp
ldb has quit [Ping timeout: 276 seconds]
akoana has joined #commonlisp
tyson2 has joined #commonlisp
triffid has quit [Remote host closed the connection]
triffid has joined #commonlisp
Inline has joined #commonlisp
eddof13 has joined #commonlisp
McParen has left #commonlisp [#commonlisp]
Inline_ has joined #commonlisp
Inline has quit [Ping timeout: 246 seconds]
eddof13 has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
<prokhor_>
phoe: thx alot! on #lisp, they said, it was unlikely to be possible
<phoe>
in CL, impossible is easy
<phoe>
miracles tend to involve a while more
<prokhor_>
:)
<jcowan>
prokhor_: It can't be done in portable CLOS, but it can be done (as shown above) in semi-portable MOP, which is not part of the standard, but is widely implemented. Note that you may need to use remove-direct-subclass as well.
<phoe>
yeah, {add,remove}-direct-subclass is the programmatic interface
ldb has joined #commonlisp
Inline__ has joined #commonlisp
rendar has joined #commonlisp
rendar has quit [Changing host]
rendar has joined #commonlisp
aartaka has quit [Ping timeout: 260 seconds]
cosimone has joined #commonlisp
Inline_ has quit [Ping timeout: 272 seconds]
ldb has quit [Remote host closed the connection]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
<_death>
I don't think it's meant to be called by a user
<_death>
if you want to add a superclass, ensure-class may be the trick.. like is done in e.g., stealth-mixin
seletz has joined #commonlisp
<phoe>
I've seen it in action when people create anonymous classes
<phoe>
but yes, ensure-class might be a better option
amb007 has quit [Ping timeout: 268 seconds]
seletz has quit [Ping timeout: 248 seconds]
cosimone has quit [Read error: Connection reset by peer]
cosimone has joined #commonlisp
_cymew_ has joined #commonlisp
vibs29 has joined #commonlisp
vibs29 is now known as Guest2907
lisper29 has quit [Ping timeout: 260 seconds]
danieli1 has joined #commonlisp
danieli has quit [Ping timeout: 260 seconds]
danieli1 is now known as danieli
morganw` has joined #commonlisp
morganw has quit [Ping timeout: 260 seconds]
amb007 has joined #commonlisp
Inline_ has joined #commonlisp
amb007 has quit [Ping timeout: 255 seconds]
Guest2907 is now known as lisper29
Inline__ has quit [Ping timeout: 260 seconds]
Inline_ has quit [Quit: Leaving]
tyson2` has joined #commonlisp
tyson2` has quit [Remote host closed the connection]
tyson2 has quit [Ping timeout: 260 seconds]
Guest3622 has quit [Quit: WeeChat 3.7.1]
nij- has joined #commonlisp
cage has quit [Quit: rcirc on GNU Emacs 27.1]
lisper29 has quit [Quit: Leaving]
_cymew_ has quit [Ping timeout: 255 seconds]
amb007 has joined #commonlisp
chipxxx has quit [Remote host closed the connection]
chipxxx has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
dipper_ has joined #commonlisp
dipper has quit [Ping timeout: 272 seconds]
chipxxx has quit [Ping timeout: 255 seconds]
chipxxx has joined #commonlisp
cosimone` has joined #commonlisp
chip_x has joined #commonlisp
cosimone has quit [Read error: Connection reset by peer]
chipxxx has quit [Ping timeout: 248 seconds]
nij- has quit [Ping timeout: 255 seconds]
amb007 has joined #commonlisp
tyson2 has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
pve has quit [Quit: leaving]
jmdaemon has joined #commonlisp
amb007 has joined #commonlisp
dipper_ has quit [Remote host closed the connection]
dipper_ has joined #commonlisp
dipper_ has quit [Remote host closed the connection]
dipper_ has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
gxt has quit [Remote host closed the connection]
gxt has joined #commonlisp
nij- has joined #commonlisp
gxt has quit [Remote host closed the connection]
gxt has joined #commonlisp
lisp123 has joined #commonlisp
bilegeek has joined #commonlisp
tyson2` has joined #commonlisp
tyson2 has quit [Ping timeout: 260 seconds]
tyson2` has quit [Remote host closed the connection]
thuna` has quit [Remote host closed the connection]
tyson2 has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
lisp123 has quit [Ping timeout: 246 seconds]
random-nick has quit [Ping timeout: 248 seconds]
dipper_ has quit [Remote host closed the connection]