igemnace has quit [Remote host closed the connection]
* edgar-rft
goes looking for his Gjallarhorrn
<_death>
afaik Fenrir still struggles with Gleipnir ;) .. back to Lisp
<jackdaniel>
NL - Nordic Lisp
MajorBiscuit has quit [Ping timeout: 246 seconds]
tyson2 has quit [Remote host closed the connection]
scymtym has joined #commonlisp
<NotThatRPG>
@jackdaniel: Norwegian Death Lisp
aartaka has quit [Ping timeout: 246 seconds]
aartaka has joined #commonlisp
<Josh_2>
Death metal band with a lisp
morganw has joined #commonlisp
MajorBiscuit has joined #commonlisp
chrcav has quit [Quit: leaving]
chrcav has joined #commonlisp
tyson2 has joined #commonlisp
jmdaemon has joined #commonlisp
ttree has joined #commonlisp
seletz has quit [Ping timeout: 272 seconds]
speskk has quit [Ping timeout: 248 seconds]
khrbt_ has joined #commonlisp
khrbt has quit [Ping timeout: 252 seconds]
peterhil_ has quit [Remote host closed the connection]
peterhil has joined #commonlisp
pdietz has joined #commonlisp
peterhil has quit [Read error: Connection reset by peer]
Cymew has joined #commonlisp
_cymew_ has quit [Ping timeout: 256 seconds]
seletz has joined #commonlisp
seletz has quit [Ping timeout: 260 seconds]
eron has joined #commonlisp
cosimone has joined #commonlisp
<Demosthenex>
lordi?
<pjb>
Lord I or l'ordinateur?
<Demosthenex>
oh wait Lordi is from Finland, not norway
cosimone has quit [Remote host closed the connection]
cosimone has joined #commonlisp
sedzcat has quit [Ping timeout: 264 seconds]
sedzcat has joined #commonlisp
cosimone` has joined #commonlisp
cosimone has quit [Ping timeout: 272 seconds]
eron has quit [Quit: Client closed]
rgherdt has quit [Remote host closed the connection]
rgherdt has joined #commonlisp
varjag has joined #commonlisp
YaN3k has joined #commonlisp
<YaN3k>
is there some value error that I can throw if the value of function argument is incorrect?
aartaka has quit [Ping timeout: 246 seconds]
aartaka has joined #commonlisp
peterhil has joined #commonlisp
<yitzi>
YaN3k: Are you using check-type?
nij- has joined #commonlisp
<Josh_2>
you can declare the type of arguments and if the safety settings are high enough you will get a type error. (defun test (a) (declare (type string a)) (print a)) -> (test 1) -> type error
cage has quit [Quit: rcirc on GNU Emacs 28.2]
nij- has left #commonlisp [Using Circe, the loveliest of all IRC clients]
Odeqlmd has quit [Remote host closed the connection]
<YaN3k>
This seems interesting but what I'm looking for is to signal error if integer value is not in (0-255) range.
<YaN3k>
is there some idiom to do this?
<_death>
(check-type x (unsigned-byte 8))
<YaN3k>
thanks!
seletz has joined #commonlisp
Noisytoot has quit [Ping timeout: 246 seconds]
seletz has quit [Ping timeout: 265 seconds]
<pjb>
YaN3k: also, in general, (check-type x (integer 0 255))
<_death>
I assumed you meant [0-255] ... otherwise it's (integer 1 254) or (and (unsigned-byte 8) (not (member 0 255))) or something
<pjb>
Oops, yes, it was NOT.
<pjb>
_death: but my point is that 10000000000000000 is an integer not in [0,255] range!
<pjb>
_death: but the error is to be signaled when it is not in the range [0, 255]. So checking for the type (integer 0 255) is correct.
puchacz has quit [Quit: Client closed]
<pjb>
(mapcar (lambda (x) (typep x '(integer 0 255))) '(-1 0 1 2 254 255 256 10000)) #| --> (nil t t t t t nil nil) |#
<_death>
yes, but YaN3k used (0-255) so may have meant (0, 255)
<pjb>
YaN3k: you may signal type-error yourself. (unless (valid-value-p argument) (error 'type-error :datum argument :expected-type 'valid-value-type))
<pjb>
YaN3k: you may define a condition class subclass of type-error, adding a format-control and format-arguments slots, (aka simple-type-error) if you want to add a specific error message.
<pjb>
Oh, silly me, there's already a cl:simple-type-error
<pjb>
(unless (valid-value-p argument) (error 'simple-type-error :datum argument :expected-type 'valid-value-type :format-control "Expects a valid value, not ~S" :format-arguments (list argument)))
<pjb>
(let ((argument 400)) (error 'simple-type-error :datum argument :expected-type '(integer 0 255) :format-control "Expects an integer between 0 and 255, not ~S" :format-arguments (list argument))) #| ERROR: Expects an integer between 0 and 255, not 400 |#
<pjb>
(error 'type-error :datum 400 :expected-type '(integer 0 255)) #| ERROR: The value 400 is not of the expected type (integer 0 255). |#
varjag has joined #commonlisp
<pjb>
For example, I like to add the name of the function to the error message: (let ((argument 400)) (error 'simple-type-error :datum argument :expected-type '(integer 0 255) :format-control "Function ~S expects an integer between 0 and 255, not ~S" :format-arguments (list 'foo argument))) #| ERROR: Function foo expects an integer between 0 and 255, not 400 |# Using ~S and the symbol like this will print a qualified symbol when needed.
<_death>
there's also assert..
Noisytoot has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
<pjb>
indeed, and you can add a message to (let ((argument 4.2)) (check-type argument (integer 0 255) "an integer between 0 and 255 inclusive")) #| ERROR: value 4.2 is not an integer between 0 and 255 inclusive ((integer 0 255)). |#
<pjb>
a string describing the expected type more precisely.
alejandrozf has quit [Ping timeout: 252 seconds]
<Josh_2>
There is an advantage to using (declare (type ..)) over check-type
<Josh_2>
You can maintain two builds, a development and a testing version, with different speed/safety settings
Cymew has quit [Ping timeout: 265 seconds]
<NotThatRPG>
Also I often don't want a continuable error, which is what I get from check-type
<_death>
why not?
<NotThatRPG>
If I have a defgeneric with &allow-other-keys, shouldn't I be able to use &key and &allow-other-keys in method definitions?
<_death>
it's a correctable error
<NotThatRPG>
_death: Usually there's no way to fix the problem -- I have passed the wrong argument, and it's fatal
<_death>
NotThatRPG: it gives you a restart to store a new value into the place, that satisfies the type
<_death>
for your defgeneric question.. &allow-other-keys means you can pass any keys to the methods, so there's no need to specify that in defmethod
pdietz has quit [Quit: Client closed]
rgherdt_ has joined #commonlisp
rgherdt has quit [Read error: Connection reset by peer]
rgherdt__ has joined #commonlisp
rgherdt_ has quit [Read error: Connection reset by peer]
tyson2 has quit [Remote host closed the connection]
<NotThatRPG>
Odd. Allegro likes it, but SBCL still thinks it's wrong. Which makes me suspect I'm wrong, because SBCL is usually more stringent.
<_death>
if you're doing everything in the same image with the same gf, make sure you fmakunbound first
<NotThatRPG>
OMG, I think I see the problem.
<NotThatRPG>
Yes, my bad. I needed to fix my defgeneric, but that broke *a different* defmethod form, and I was confused about which was broken. FACEPALM
tyson2 has joined #commonlisp
<ldb>
^that happend before right
jeosol has quit [Quit: Client closed]
semz has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
semz has joined #commonlisp
aartaka has quit [Ping timeout: 264 seconds]
aartaka has joined #commonlisp
attila_lendvai has joined #commonlisp
<pjb>
Josh_2: I see no advantage of using declare for the types. Only big pitfalls.
<pjb>
Josh_2: Now, what you could do, is combine both: (defun foo (x) (check-type x the-type-x-must-have) (%foo x)) (defun %foo (x) (declare (type tye-type-x-must-have x)) …)
<pjb>
Josh_2: here, foo will check the type at run-time, and offers you security, while %foo will assume the type of x, and be compiled the most efficient way possible (ie. without type checking).
<pjb>
Josh_2: of course, you would never call %foo without having first checked the type of x.
<pjb>
(defun bar () (let ((x (compute-some-x))) (check-type x the-type-x-must-have) (%foo x)))
<pjb>
Josh_2: it's difficult to manage those two sets of functions, so in general, just write foo and use check-type; forget about declare.
<pjb>
The only useful declare is declare special, when you want local dynamic variables.
aartaka has quit [Ping timeout: 264 seconds]
shka has quit [Ping timeout: 265 seconds]
<ldb>
or if the compiler can unbox the data type, which sometimes can give huge performance gain
<ldb>
if the type would be a pointer anyway, there is not much reason to declare it.
Posterdati has quit [Ping timeout: 272 seconds]
seletz has joined #commonlisp
jeosol has joined #commonlisp
cosimone` has quit [Remote host closed the connection]
seletz has quit [Ping timeout: 272 seconds]
Posterdati has joined #commonlisp
<jcowan>
pjb: Declare special is the only *necessary* declare, in the sense that it changes semantics. It isn't the only useful one.
thuna` has quit [Remote host closed the connection]
azimut has joined #commonlisp
YaN3k` has joined #commonlisp
dra has joined #commonlisp
dra has quit [Changing host]
dra has joined #commonlisp
YaN3k has quit [Ping timeout: 268 seconds]
YaN3k` has quit [Ping timeout: 260 seconds]
<prxq>
anyone using cl-json on latest sbcl? When I try to use 'with-decoder-simple-clos-semantics' I get "SB-MOP:CLASS-SLOTS called on #<FLUID-CLASS JSON:FLUID-OBJECT>, which is not yet finalized."
<prxq>
btw what hapened to zach an xoph. No longer on IRC?
<phoe>
prxq: does (sb-mop:finalize-inheritance (find-class 'json:fluid-object)) work around the issue?
<prxq>
we shall see :-)
<prxq>
yes!
<prxq>
phoe: thx
varjag has quit [Ping timeout: 260 seconds]
<NotThatRPG>
_death: ping?
ldb has quit [Quit: ERC 5.4 (IRC client for GNU Emacs 28.1)]
tyson2 has quit [Ping timeout: 260 seconds]
peterhil has quit [Remote host closed the connection]
peterhil has joined #commonlisp
seletz has joined #commonlisp
seletz has quit [Ping timeout: 260 seconds]
<_death>
sup
khrbt has joined #commonlisp
khrbt_ has quit [Ping timeout: 252 seconds]
MajorBiscuit has quit [Ping timeout: 260 seconds]
<NotThatRPG>
_death: I recalled one of the reasons I don't like `check-type`
<phoe>
what is it?
<NotThatRPG>
It messes up SBCL's type-checking. SBCL doesn't recognize that after I (check-type foo bar) foo can be trusted to be of type bar.
<phoe>
got an example? SBCL actually should be doing that
<NotThatRPG>
type checking seems to do good reasoning over branches, but not over check-type.
<NotThatRPG>
phoe: I think i could probably recover one -- I have a system where I shadowed CHECK-TYPE with my own definition that is not continuable for that reason.
<phoe>
what is your (sb-ext:describe-compiler-policy)?
<NotThatRPG>
phoe: What I was seeing was SBCL saying it could not optimize something because of type uncertainty that I believed check-type could have resolved. And indeed, the type uncertainty went away with the shadowed check-type.
* NotThatRPG
is having some trouble with his mechanical keyboard...
<NotThatRPG>
phoe: It's getting late here and I have to go walk dogs, but I will try to find an MWE
<phoe>
NotThatRPG: I'd like to see the code and warning in question; AFAIK it's possible that this type uncertainty thing disappeared because SBCL's ability to typecheck got *worse* rather than better because of your check-type modification, at least to the best of my understanding of SBCL
<phoe>
sure, there's no rush; ping me when you find it
rgherdt has quit [Remote host closed the connection]
<phoe>
it's almost 1 AM here anyway so
julio has joined #commonlisp
<_death>
I guess the compiler could recognize that sometimes.. at least until there's some assignment later on.. but when I want to declare something to the compiler I don't really rely on check-type
julio is now known as ClickHacker
<NotThatRPG>
_death: At least potentially it could cut down on the need for a lot of `locally` declarations. You check something's type and from then on the compiler should be able to trust its type and potentially optimize.
<NotThatRPG>
Maybe my compiler policy is leaving the compiler being lazy
<_death>
NotThatRPG: if it's a lexical variable, yeah.. unless there's some later assignment to it
<NotThatRPG>
Right.
<phoe>
yes, that's the idea in SBCL, as far as I know, and any deviations from this behavior might be bugs
<phoe>
_death: I don't think that assigning to a variable is allowed to erase its type declaration
<_death>
phoe: check-type is not a type declaration
<NotThatRPG>
OK, I will go out now. If I don't report back tomorrow, it's because I froze to death!
NotThatRPG is now known as NotThatRPG_away
<phoe>
_death: I see what you mean
<phoe>
check-type works on a value, and reassigning the variable that value is bound to causes the value's typecheck to not be useful anymore