freenode/#lisp - IRC Chatlog
Search
10:06:02
phoe
shka_: my status would be a very dumb object though, it's literally a member of (NIL :OK :ERROR).
10:07:16
shka_
anyway, you can simply abstract this in make-message where you are accepting operation and status symbol
10:09:31
shka_
because :error appears to be something that should contain some sort of description of what wen wrong
10:10:21
no-defun-allowed
i might need to do more reading but to make the slot you need the class definition and to make the class you need the slot definition
10:10:44
phoe
no-defun-allowed: you might want to read AMOP, where a CLOS-like object system is implemented in raw CLOS-less Common Lisp
10:11:14
phoe
basically, you can go from a CLOS-less Common Lisp to a CLOS-ful Common Lisp using nothing but the facilities embedded in the language
10:11:42
shka_
it has it's default implementation and it is really nice, but it is not the only possible
10:13:36
beach
no-defun-allowed: I am in the middle of implementing CLOS, so I have much of that relatively fresh in my head. So let me know if you need help.
10:14:10
beach
no-defun-allowed: If you had read up on that, you would have seen that they are just lists.
10:15:32
beach
"Each canonicalized slot specification is formed from the corresponding slot specification as follows: ..."
10:15:33
no-defun-allowed
the example on http://metamodular.com/CLOS-MOP/initialization-of-class-metaobjects.html is handy
10:21:00
Demosthenex
so anyone here using sly? worth trying as a n00b, or functional enough to get by?
10:21:58
jackdaniel
some people are using it (here included) and they seem to like it more than slime
10:21:59
Xach
Demosthenex: it has a lot of cool features and is probably easier to try for someone new than someone with a lot of slime muscle memory
10:22:28
Xach
I want to use sly more but I have a tension between wanting to be as productive as I am with slime and learning a different way
10:24:47
phoe
Is there any way to print only N first characters of an object's printed representation?
10:25:29
phoe
For (1234567890) if I want to print only five chars, I'd like to get "(1234.." or something similar
10:27:47
jackdaniel
four riders of the apocalypse: loop, format, clos and clim, none intelligible (half joking ;)
10:32:48
jackdaniel
phoe: if you make something of your own, take into account, that if it fits it sits. if you'd like to have at most 5 characters, then it would be "(12.."; but for (123) you should have full "(123)"
10:36:50
jackdaniel
McCLIM has quite elaborate transformations api which as everything one would need (given we take only transformations into account)
10:37:54
Xach
Shinmera: oh, that is so easy you could almost accidentally write it from scratch every time!
10:38:41
Shinmera
yea, which is why there's already so many matrix-y libs out there (plus innumerable ad-hoc ones, I'm sure)
10:50:05
jackdaniel
currently software renderer uses cl-vectors, but vecto api looks like a hit for it
10:50:51
cods
Xach: hi. Is someone maintaining cl-vectors these days? I doubt it was perfect as is :)
10:51:35
cods
I was supposed to convert the documentation to something more usual at some point, but never took the time to do it.
11:07:02
Xach
jackdaniel: http://report.quicklisp.org/2018-09-27/failure-report/mcclim.html#mcclim-raster-image fyi
11:12:20
Xach
jackdaniel: how about mcclim-clx-fb? http://report.quicklisp.org/2018-09-27/failure-report/mcclim.html#mcclim-clx-fb
11:20:24
Xach
cods: thank you, by the way, for making cl-vectors etc perfect so quickly, because i have been able to use it for so many happy things over the years
11:20:51
Xach
cods: my latest project involves making real roadside signs out of vinyl, paint, and wood, and it started from a program powered by cl-vectors
11:22:41
jackdaniel
Xach: will you be willing to accept such PR? or there is already a way to achieve that?
11:23:12
eminhi
Hi, I'm browsing sbcl source and came across, (declare (explicit-check)). What is this used for?
11:24:14
jackdaniel
eminhi: it looks like sbcl-specific interface. probably enforces checking declared variable types despite (i.e) succesful inference
11:25:27
no-defun-allowed
I guessed the opposite but that's less reasonable: type checks are explicitly required.
11:30:37
scymtym
jackdaniel: eminhi: it means arguments should not be checked against the declared ftype in the function prologue because the function body will perform an explicit check (hence the name) and error signaling itself
11:41:07
eminhi
sbcl has many instance of code like, (defun 1+ (number) (declare (explicit-check)) (1+ number). recursive without checks?
11:42:04
beach
eminhi: As I understand it, there are primitives that are directly known by the compiler, like CAR and CDR. I guess 1+ must be one of them.
11:44:20
beach
No, it's that (1+ number) does not mean "Call the function 1+ with the number" to the compiler. It means, generate code for what you already know about 1+.
11:45:59
eminhi
What happens when 1+ is used elsewhere in the same file? compiler generate code or defun application?
11:47:05
beach
I am not the right person to answer, because I don't know the details. But, as I understand it, wherever 1+ is used in a function-call position, like (1+ <any-form>), the compiler recognizes 1+ and just generates code for what it means.
11:47:14
no-defun-allowed
The same logic applies. If the function is declared inline, the compiler can optimise as much as it wants out of it.
11:48:16
scymtym
eminhi: 1+ is present as an ordinary function (in case it is called indirectly) and as compiler-level construct, a "source transform" (SLIME's M-. will show all of those). the function is implemented in term of the source transform, therefore the apparent recursion
11:49:13
scymtym
eminhi: asking SBCL-specific questions in #lisp is not the best approach. study the code and ask in #sbcl if you get stuck
11:53:40
no-defun-allowed
How does :initfunction work in the canonical direct slot specification work?
11:54:10
no-defun-allowed
By the looks of things initform is pretty useless and initfunction is a thunk which evaluates to the wanted default value.
11:55:35
Xach
jackdaniel: i would accept the pr, sure. you can snoop on the 8-bit sample image data by using :: right now but I understand the interest in a supported option.
17:00:54
phoe
mgsk: https://sites.google.com/site/sabraonthehill/postmodern-examples/postmodern-table-management has some data on it
17:45:53
Younder
Well, I'll work on that then. An MXNet interface to CL might be instructive. (I normally use Mathematica)
18:29:25
phoe
What would be the best pattern to only capture the kind of errors that happens as a part of DESTRUCTURING-BIND operation?
18:30:40
jasom
phoe: it's going to be implementation-specific unfortunately; this looks like someone needs to write a "trivial-bind-error" package :P
18:32:41
phoe
I'm wondering if I can somehow wrap the destructuring-bind body in some handlers that will only apply to whatever happens inside the d-b binding forms.
18:34:58
jasom
(let ((in-bind t)) (handler-bind ... (destructuring-bind X Y (setf in-bind nil) ...)))
18:36:02
jasom
djeis[m]: Y doesn't need to be wrapped, as it's identical in usage to destructuring-bind
18:36:47
phoe
I assume I could simply shadow CL:DESTRUCTURING-BIND with my own implementation that uses this trickery and is guaranteed to signal some DESTRUCTURING-BIND-ERROR when the binding fails.
18:36:50
djeis[m]
Depends if you want to catch errors raised by Y itself and not just the binding process.
18:38:20
djeis[m]
Right, so you’d either want to move that outside your handler bind using a gensym or you’d need to wrap that too.
18:38:23
jasom
(let (in-bind) (handler-bind ... (destructuring-bind X (prog1 Y (setf in-bind t)) (setf in-bind nil) ...)))
18:41:23
djeis[m]
And I don’t see a simple way around that one, actually, that doesn’t involve parsing a lambda list.
18:41:30
Younder
Look this is all ugly. You gotta restate the problem rather than rephrase the answer.
18:41:52
phoe
I am destructuring a list and I want to capture the kind of errors that happen when a list cannot be destructured.
18:42:17
phoe
I want to handle the DESTRUCTURING-BIND-ERROR condition that was not included in the CLHS.
18:45:05
Younder
The way I would do it is to paste destructing-bind-error, rename it and add it to your program in a portable way.
18:55:00
dbjergaard
Hi, I'm trying to load unit tests using fiasco and I cannot for the life of me get asdf to load it
18:57:50
dbjergaard
I made the test files/package according to https://github.com/stumpwm/stumpwm/blob/master/stumpwm-tests.asd
18:58:39
dbjergaard
I can (ql:quickload "packagename") just fine, but I can't do (ql:quickload "packagename-tests")
19:04:26
dbjergaard
now I've got another problem, but that's an actual "you wrote wrong code you dummy" problem
19:04:30
aeth
phoe: If you're only supporting a few implementations you could handle this with #+sbcl, #+ccl, #+ecl, etc. You would still need to think about which kinds of errors could happen, e.g. passing (list) to (a b c) gives an arg-count-error (and it looks like that's for defmacro lambda lists so internally they must have the same or a similar implementation) in SBCL, but that's probably not the only possible error
19:06:07
aeth
(If you're doing this as part of an application, then it's probable that your libraries already made the choice for you and your program can probably only run on SBCL and CCL and maybe ECL. If you're doing this as part of a library, you're going to have to support a longer list, but even that's only like 6-8 or so.)
19:10:03
scymtym
if you are willing to invest the effort, maybe try to make a protocol for generating destructuring forms (along the lines of CLtL's PARSE-MACRO, but more specific) instead. only standardizing the error condition seems like a lot of work for comparatively little gain
19:11:04
aeth
Well, just run invalid destructuring-binds and see what you get. #+sbcl sb-kernel::arg-count-error #+ccl ccl::simple-program-error #+ecl simple-error #+clisp system::simple-program-error #+abcl program-error
19:11:20
aeth
This only is problematic in #+abcl because SLIME isn't giving me the package, just the name, and program-error isn't in cl-user
19:13:21
aeth
There are some issues with just seeing what you get. SBCL might be too specific, i.e. you might get something else with a different invalid list passed in if that's possible (try cases with &key and &rest and &body).
20:08:46
phoe
it can properly handle things like (destructuring-bind* (a &optional (b (error "haha"))) '(2))
20:14:18
Shinmera
so it needs to be `(let ((,v ,expression)) (handler-bind ((error #',handle)) (destructuring-bind ,new ,v ,@body))))
20:21:07
Shinmera
`(let ((,v ,expression)) (handler-bind ((error #',handle)) (destructuring-bind ,new ,v (setf ,in-body T) ,@body))))
20:21:45
trittweiler
I'm a bit perplexed by what the point of this is, but assuming it's some kind of learning experience: please note LOCALLY won't be enough because locally only supports free declarations, not declarations of bindings. The bind-modify-lambda-list can also probably be written cleaner.
20:22:17
phoe
trittweiler: right, I'll need to extract the declarations from the body if there are any
20:23:09
phoe
trittweiler: also not really a learning experience, I realized that I have a use case where I want to capture errors that may happen during destructuring, and the standard doesn't let me do that easily.
20:23:46
trittweiler
can't you grab an implementation of destructuring-bind from sicl and use that instead? Seems cleaner imho :)
20:24:42
Shinmera
sicl's carries a lot of baggage, if I remember correctly, because lambda list parsing is extensible.
20:24:54
phoe
https://github.com/robert-strandh/SICL/blob/master/Code/Data-and-control-flow/destructuring-bind-support.lisp
20:36:41
Demosthenex
i think it was suddenly introducing mapcar that confused him, but he got over it