freenode/#lisp - IRC Chatlog
Search
21:48:55
phoe
beach: I got a YouTube comment on Creating a Common Lisp implementation (Part 2) saying "Thanks for this series! The not covered topics are really interesting. Consider touching them in the future.
21:50:46
aeth
For those not following #sbcl apparently a lot of code uses NIL for an invalid default value, which SBCL has (afaik) started complaining about. The type-correct alternative is ERROR, but this is often not done because ERROR will quickly pollute your swank/slime API with useless information if you e.g. have 8 mandatory &key arguments with a declared type that doesn't permit NIL.
21:51:39
aeth
I think it's in everything except struct definitions at the moment? But SBCL intends to check everything for that now.
21:52:15
aeth
I think the resolution should be to modify swank to hide the contents of (error ...) defaults by default, to prevent a ton of useless noise in the function API. sort of like *arglist-show-packages* except more like *arglist-show-full-errors* or something. https://github.com/slime/slime/blob/fac8069fc13eb62742c31967b314bddb6da6b6c7/contrib/swank-arglists.lisp
21:53:07
aeth
so instead of seeing &key (foo (error 'your-full-package-name/conditions:whatever :details "foo bar baz" :variable 'your-full-package-name/foobar::quux)) ...
21:54:47
phoe
I mean, (error) signals an error, but it's a PROGRAM-ERROR because the required arg is not provided
21:54:51
aeth
Is anyone familiar enough with swank to be able to modify this? Or would I have to dig into it to try? This is going to affect quite a few packages that will now have to change invalid NILs to ERRORs
21:55:10
phoe
but I'd rather have (error ...) to signal that there's actual args in there that have been elided for readability
21:55:20
aeth
And I don't think my example of the problem, which currently is just &key (foo nil), is an exaggeration
21:58:25
Gnuxie[m]
what do you mean by uses nil for an invalid default value? default value for what? why's it wrong?
22:02:19
aeth
Gnuxie[m]: the shortest thing I can think of is (defun foo (&key foobar) (declare (type integer foobar)) (1+ foobar)) which should (but is not guaranteed to!) error if called as (foo) instead of (foo :foobar 1)
22:02:45
aeth
Gnuxie[m]: But it's one of those things that, when seen in a short example, you'd wonder why anyone would do that, but it could easily happen if someone designed a function API with, say, 10 arguments, some mandatory.
22:03:32
Gnuxie[m]
oh ok, so this is specific to people declaring things as not null without realising?
22:03:35
aeth
Gnuxie[m]: the right thing to do is something more like this: (defun foo (&key (foobar (error "FOOBAR is a required argument"))) (declare (type integer foobar)) (1+ foobar))
22:03:55
aeth
Gnuxie[m]: But a lot of people will explicitly rely on things being NIL as an invalid type because they don't want to take, like, 4 lines or something in SLIME
22:04:21
aeth
Emacs will expand the minibuffer, but it still is pretty annoying, and the only time that ever really happens is with a lot of ERRORs in keys
22:04:35
aeth
When you as the user probably only care that it will error by default, i.e. required argument
22:05:36
aeth
Gnuxie[m]: But SBCL is starting to detect this sort of UB... Idk if it has gotten to this one in particular, but it might have.
22:07:40
aeth
So this is a case of SBCL finally doing the right thing (warning on UB), but the tools encouraging the wrong thing (it really doesn't take many keys for those ERRORs to be really, really annoying in SLIME).
22:09:47
aeth
And on top of that, I think that SLIME translates DEFCLASS :initarg/:initform pairs into keys like this. At least in SBCL, it looks like it does, which is pretty smart of it, because it's working off of (make-instance 'foo ) instead of just a function API.
22:10:04
aeth
Gnuxie[m]: e.g. (defclass foo () ((foobar :initarg :foobar :initform (error "This is a mandatory slot."))))
22:10:26
aeth
But, again, the error could be incredibly verbose, but the user probably only cares that it is an error.
22:14:46
aeth
And with respect to what I have just written in the last 30 minutes of lines here, I waive all copyright and related rights to the extent permitted by law, and otherwise place the text under the CC0 license described here https://creativecommons.org/publicdomain/zero/1.0/ and with the full text here https://creativecommons.org/publicdomain/zero/1.0/legalcode
22:15:59
aeth
phoe: If anyone wants to justify hiding (error ...) like that in SLIME/swank, feel free to copy and paste and plagiarise.
22:23:26
Gnuxie[m]
yeah that, i didn't know it was possible to uhh copyright your irc talkings though and stop people opening issues just because you said it
22:24:01
aeth
Gnuxie[m]: probably allowed under fair use, but there was quite a bit of text here so I was just being safe.
22:25:20
aeth
I'm not a lawyer, but afaik everything you write is automatically copyrighted by you without you having to claim it with e.g. © or (C).
22:26:19
aeth
That's why code without a license is treated as all rights reserved instead of public domain.
22:29:48
White_Flame
huh, I remember getting errors/warnings of this sort of thing a while ago already
22:30:46
White_Flame
as in a few years ago. It must have only been supported in a few places and is spreading now. IIRC, it was struct slots that bit me
22:33:32
aeth
< Xach> hmm, failures with latest (ish) sbcl from git - another increase in type derivation strictness i think? http://report.quicklisp.org/2020-08-29/failure-report/claw.html#claw is one example, many seem to be due to slots with a declared type but a NIL initform.
22:39:16
aeth
So then a patch to swank to hide ERROR verbosity and an update of all library code with invalid default NILs will happen before anyone really notices it.
22:40:31
aeth
I guess I'm going to have to compile the latest SBCL and see which parts of my code break (probably more than I expect)
23:04:37
rumbler31
reason why I'm procrastinating my python homework, I'm busy trying to import functools and read the docs on the reduce because I miss lisp and want to run a higher order function on an array
23:31:34
aeth
Wow, I was getting really excited by the changes in the latest SBCL, but, no, unfortunately it still does not check :type in default optimization levels in DEFCLASS, e.g. (defclass foo () ((%foobar :initarg :foobar :initform nil :accessor foobar :type fixnum)))
23:31:58
aeth
It will now warn that NIL isn't a fixnum, but it won't actually stop you from doing (make-instance 'foo :foobar "hello") thus keeping :type absolutely useless on the implementation that 90% of people use
23:32:53
no-defun-allowed
I think that the latest SBCL broke decentralise2 dispatch maybe (but it's fair because I mixed compilation/evaluation environments). That was fun.
23:33:34
aeth
well, it broke cl-autowrap, which was fun, because I had to override it with the git version so I could even test to see if anything new showed up in my game engine when I loaded with :verbose t (nothing did)
23:33:55
no-defun-allowed
No, I don't think SBCL changed anything for that to happen, but it did happen, and I can't complain really.
3:29:27
beach
phoe: By the way, I can prepare a presentation for a week from tomorrow (or later) in case you have no other candidates.
8:43:16
pve
but it's not clear to me why (shadow 'array) leads to that weird behaviour, because reading the hyperspec entry for shadow, I get the impression that it should work
8:47:03
pve
are all the references to the symbol "ARRAY" stored "in one place" in the fasl, so that when the fasl is loaded, LOAD sees 'array (i.e. CL:ARRAY, before shadowing) and then assumes all ARRAY symbols in the fasl are the same?
8:49:42
beach
The symbol ARRAY already exists in the cl-user package, so it is going to use the pre-existing symbol.
8:52:13
beach
The name is a designator for a string, so only the name of the symbol matters if you give it a symbol.