freenode/#lisp - IRC Chatlog
Search
18:10:03
didi
How do I specify the type of a class' slot? Shouldn't (progn (defclass foo () ((foo-slot :initarg :foo-slot :type symbol))) (make-instance 'foo :foo-slot 42)) error?
18:21:04
_ark_
didi: There's no way to strictly enfore a class' slot type. Best you can do is type check in initialize-insance and with accessor/reader methods. Still, you can always set a slot to whatever you want by calling (setf (slot-value ...)). That might be good enough, but if you need strict enforcement you can use a struct instead of a class. Struct slot types are strictly enforced.
18:23:08
pjb
#+ccl (defclass point () ((x :type fixnum :initarg :x :accessor point-x))) (make-instance 'point :x 3.2) --> The value 3.2, derived from the initarg :x, can not be used to set the value of the slot x in #<point #x3020034C998D>, because it is not of type fixnum.
18:24:06
pjb
But it's correct, if you want to be sure it's checked, you have to do it explicitely in initialize-instance and in the setters.
18:25:05
scymtym
sbcl checks standard-object slot types with a sufficient safety optimization setting
18:25:59
pjb
didi: you would use check-type on the parameters of the setters and of initialize-instance.
18:27:05
pjb
(defmethod initialize-instance :before ((o your-class) &key to-be-checked &allow-other-keys) (check-type to-be-checked type-of-the-thing))
18:27:42
pjb
It's very simple, just write the mininum that has to be written: :before, your argument and the check-type. Nothing more!
20:06:38
sebboh
This doesn't do what I expect: sbcl --noinform --eval '(progn (ql:quickload :grid :silent t) (grid:render "foo"))' --non-interactive
20:07:33
sebboh
If I just start sbcl and evalute (ql:quickload :grid :silent t) followed by (grid:render "foo"), it works as expected.
20:08:14
Bike
so it reads the form, then (if it worked) would quickload grid, making the grid package available.
20:10:57
phoe_
because I'd need to first render this as a PNG file, then read that file, then read the pixel valus
20:12:18
phoe_
XachX: basically, I need to create a gradient purely in memory, in order to read the individual color values in between
20:13:17
phoe_
...actually, I want to get all the color values for values from 0 to 255, given that the gradient is 256 pixxels long.
20:13:39
phoe_
Yep, I can see it, and it's doable - just, it's that part that I need to save a temporary file and then load it that itches me
20:17:14
phoe_
https://github.com/xach/vecto/blob/8659770bfdc460a1c6b07271a188ec6c19aad3ea/gradient.lisp#L48 hm.
20:24:47
phoe_
So it's like 0% one color, 4.76% another color, 5% yet another color, ..., 94% one more color, 100% last color.
20:31:11
phoe_
if you're worried about it, you can defstruct and still get good performance, and then define a print-object method on it that does not print everything like crazy.
20:33:35
phoe_
Go with defclass, and if you feel that your performance suffers way too much AND that you are not using too much CLOS magic, then go for defstruct instead.
20:38:11
phoe_
I could use VECTO, if there was a way to get the in-memory vector of data *before* it's saved into a PNG.
20:43:48
phoe_
It seems that I can use an unexported IMAGE accessor, https://github.com/xach/vecto/blob/8659770bfdc460a1c6b07271a188ec6c19aad3ea/user-drawing.lisp#L332
20:58:20
phoe_
XachX: If I understand VECTO correctly, I can call SET-GRADIENT-FILL to describe what kind of gradient I want, and then call RECTANGLE to bound that gradient to a particular space on the canvas, so it doesn't draw the gradient all over the previous gradients I have created on that canvas. Is this correct?
0:03:13
sebboh
hm, didn't work for some reason. The UI prompted me to confirm the name of the thing I wanted to fmakunbound, but it still has a value... Oh well, it's quittin' time. :)
1:33:07
shrdlu68
What happens when you start sbcl in a terminal and paste this: http://paste.lisp.org/display/356394 ?
5:27:34
beach
Yesterday, I think I figured out how to do partial inlining of local functions using local graph rewriting.
5:31:59
beach
It is a graph of HIR (High-level Intermediate Representation) instructions in Cleavir.
5:32:22
minion
iqubic: Cleavir: A project to create an implementation-independent compilation framework for Common Lisp. Currently Cleavir is part of SICL, but that might change in the future
5:32:28
minion
iqubic: SICL: SICL is a (perhaps futile) attempt to re-implement Common Lisp from scratch, hopefully using improved programming and bootstrapping techniques. See https://github.com/robert-strandh/SICL