<sveit>
hello. is there a "standard" solution to the following usecase: I have some objects, a,b of class A. I want to build some structure, say a graph, whose vertices are also of class A. each vertex is "mostly" like a or b, with small modifications.
<sveit>
naively one would make shallow copies of a and b, and modify each slot (possibly copying the slot values as well if they themselves are class objects), but since common lisp (without closer-mop) seems to make this somewhat inconvenient (I was just overloading shared-initialize with a "default" keyword parameter), I was wondering what the "lispy" solution to such a usecase would be
bubblegum has quit [Ping timeout: 276 seconds]
<paulapatience>
sveit: Am I understanding this correctly: You want to make a new object that is almost exactly like a, but changing one or two slots?
bubblegum has joined #commonlisp
<paulapatience>
(Because calling make-instance with all the initargs is inconvenient.)
<ixelp>
Trucler/Code/quasi-clone.lisp at master · s-expressionists/Trucler · GitHub
<paulapatience>
Basically, cloning-information is an append generic function that you specialize to return the initargs and initvals that you want to copy over to the new object in quasi-clone.
NotThatRPG has joined #commonlisp
NotThatRPG has quit [Ping timeout: 276 seconds]
random-nick has quit [Ping timeout: 244 seconds]
johnjaye has quit [Ping timeout: 276 seconds]
johnjaye has joined #commonlisp
koditals has quit [Quit: Leaving]
xlymian has joined #commonlisp
tisanae has joined #commonlisp
tisanae has quit [Client Quit]
hineios235 has joined #commonlisp
hineios23 has quit [Ping timeout: 245 seconds]
hineios235 is now known as hineios23
NotThatRPG has joined #commonlisp
lucasta has joined #commonlisp
NotThatRPG has quit [Ping timeout: 252 seconds]
waleee has quit [Ping timeout: 244 seconds]
troojg has joined #commonlisp
istewart has joined #commonlisp
<kanuba>
Is #'= on different floating point types under-specified? I'm not quite sure what it means by "mathematical value" in the dictionary entry, considering:
<kanuba>
The dictionary only gives a "good" mathematical value set as an example in the notes (0.0, -0.0)
brokkoli_origin has quit [Ping timeout: 244 seconds]
brokkoli_origin has joined #commonlisp
mzan has joined #commonlisp
shawnw has quit [Ping timeout: 272 seconds]
<Alfr>
kanuba, possibly from 12.1.4.2: "Common Lisp functions assume that the accuracy of arguments to them does not exceed their precision."
amb007 has joined #commonlisp
greaser|q has quit [Changing host]
greaser|q has joined #commonlisp
greaser|q is now known as GreaseMonkey
amb007 has quit [Ping timeout: 260 seconds]
<beach>
sveit: Every Common Lisp object is a "class object".
<kanuba>
Alfr: I'm thinking, but I don't see how that is the case. There is no baseline for accuracy here that I am aware of.
<kanuba>
sveit: You can define a new class that is also of type A, and initialize it in a variety of ways, perhaps with the :default-initargs class option.
<kanuba>
Something like: ,(progn (defclass a () ((%foo :reader foo :initarg :foo :initform 0))) (defclass b (a) ((%bar :reader bar :initarg :bar :initform 0)) (:default-initargs :foo 42)) (foo (make-instance 'b)))
<ixelp>
(progn (defclass a () ((%foo :reader foo :initarg :foo :initform 0))) (defclass b (a) ((%bar :reader bar :initarg :bar :initform 0)) (:default-initargs :foo 42)) (foo (make-instance 'b))) => 42
<Alfr>
kanuba, you have a double-float which you =-compare to that converted to a single-float.
<kanuba>
That doesn't exactly spell out accuracy to me, but I realize contagion only applies to results. I might need to think more. Maybe a case for WSCL in any case
<Alfr>
kanuba, it says accuracy <= precision.
pranavats has joined #commonlisp
<Alfr>
kanuba, so, and now this begs the question whether mathematically = means up to full precision or up to accuracy.
<kanuba>
It seems accuracy, as stated in the notes, since precision refers to the representational value, which is where it says #'eql differs in that it tests for that.
<Alfr>
kanuba, I know that the same section also says that CL never converts from larger to smaller floats, but we're not getting a float back, but whatever mathematically = values means.
<aeth>
I would assume that either (= 1f0 1d0) would convert 1d0 to 1f0 or 1f0 to 1d0 and call the (implementation-specific, or perhaps a recursive call) non-generic = on it, and based on what Alfr says, it seems likely that it should (must?) be the latter.
<kanuba>
Not the former, since it says it never converts from larger to smaller in the section.
<aeth>
intuitively (though perhaps it's underspecified) it should behave like (= (coerce 1f0 'double-float) 1d0)
<Alfr>
kanuba, for most double float values, you would get the false answer, if it did that.
Lord_of_Life_ has joined #commonlisp
Lord_of_Life has quit [Ping timeout: 244 seconds]
<kanuba>
The examples for #'= specifically give the case of a numerically equal value of different types being true, but this is not the case for the above float, which is ,(/ (1- (sqrt 3)) 2d0)
<aeth>
that's also T in SBCL, and so if it went double->single the first should be T, which it isn't in CCL/SBCL, and based on this discussion, it shouldn't, because that would be moving to less precision
<Alfr>
aeth, doesn't make sense to compare values beyond accuracy, and here the single-float would be decisive.
cdegroot has quit [Remote host closed the connection]
istewart has quit [Quit: Konversation terminated!]
<kanuba>
It makes sense now given that passage. Thanks Alfr. I just spent an hour trying to figure out why #'alexandria:define-constant with a :test of #'= wasn't cerror-ing when I changed from single to double.
<kanuba>
or rather, not #'
Guest8832 has joined #commonlisp
Guest8832 is now known as wobbol
<Alfr>
kanuba, caveat: That's just my reading of those passages, and as it seems at least sbcl disagrees with me.
<kanuba>
I am on SBCL, and get the same results as the above CCL (for that example, anyway)
<Alfr>
kanuba, on an other note, comparing floats with equality is fragile at best.
<kanuba>
Right. Even using an absolute epsilon is pretty wrong in the general sense.
<kanuba>
A good read, especially for other gamedevs (ok fine -- perpetual game engine devs) like aeth. This is a very good book, and this is an article of the author's blog on the product's domain: https://realtimecollisiondetection.net/blog/?p=89
<ixelp>
Floating-point tolerances revisited – realtimecollisiondetection.net – the blog
<Alfr>
For example: ,(= #1=(sqrt 2d0) (float #1# 1f0))
<ixelp>
(= #1=(sqrt 2d0) (float #1# 1f0)) => NIL
<Alfr>
kanuba, things seem to behave as aeth said, only that your double-float starting value is rather special.
<kanuba>
Yes, I even tried other incantations of (/ (1- (sqrt x) 2d0) and couldn't reproduce, which led me to believe representable values were at play with the distribution of floating point values.
* kanuba
goes back to writing financial software
<kanuba>
Just joking, good night
<Alfr>
Did you start with (sqrt 3)?
<kanuba>
Yeah, = and eql are nil for single/double
<Alfr>
That result is a single float, from which you'd then subtact 1 and finally divide that by two.
<kanuba>
I divide by 2d0, which will give a slightly different result than 3d0 and 2, ofc
<Alfr>
Yeah, and it stays a single-float right until / .
Alfr has quit [Remote host closed the connection]
Alfr has joined #commonlisp
<Alfr>
What did I miss?
<kanuba>
Check the logs, according to the history, nothing.
<Alfr>
Was saying, that up until / the we're dealing with single floats.
<kanuba>
But lag may change that
<Alfr>
Yeah, just got disconnected.
<kanuba>
The last thing I said was
<kanuba>
I divide by 2d0, which will give a slightly different result than 3d0 and 2, ofc
<Alfr>
kanuba, my point being, that you obtained the starting value basically by converting a single- to a double-float.
<kanuba>
Yep I do see
<Alfr>
kanuba, and that'd explain why the single-float, double-float round trip doesn't affect its value and the T result.
<kanuba>
Thanks for digging. I lost my brain about an hour ago when I was headed to bed before I started reading the spec endlessly.
<kanuba>
On that note, night again :)
danse-nr3 has joined #commonlisp
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
prokhor has quit [Remote host closed the connection]
decweb has quit [Ping timeout: 276 seconds]
wacki has joined #commonlisp
danse-nr3 has quit [Read error: Connection reset by peer]
brokkoli_origin has quit [Ping timeout: 252 seconds]
epragalakis has joined #commonlisp
epragalakis is now known as evasync
NotThatRPG has joined #commonlisp
Ruby has quit [Ping timeout: 252 seconds]
brokkoli_origin has joined #commonlisp
edgar-rft_ has joined #commonlisp
evasync has quit [Changing host]
evasync has joined #commonlisp
rnfn has joined #commonlisp
rnfn has quit [Changing host]
rnfn has joined #commonlisp
edgar-rft has quit [Ping timeout: 252 seconds]
JuanDaugherty has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
varjagg has joined #commonlisp
amb007 has joined #commonlisp
brokkoli_origin has quit [Ping timeout: 252 seconds]
brokkoli_origin has joined #commonlisp
Guest3 has joined #commonlisp
brokkoli_origin has quit [Ping timeout: 248 seconds]
brokkoli_origin has joined #commonlisp
koditals has quit [Ping timeout: 265 seconds]
alcor has quit [Remote host closed the connection]
_whitelogger has quit [Ping timeout: 246 seconds]
_whitelogger has joined #commonlisp
Cymew has quit [Quit: Konversation terminated!]
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pranavats has joined #commonlisp
Inline has joined #commonlisp
danse-nr3 has quit [Quit: going for a walk]
awlygj has quit [Quit: leaving]
flip214 has quit [Ping timeout: 252 seconds]
rnfn has quit [Ping timeout: 260 seconds]
brokkoli_origin has quit [Ping timeout: 276 seconds]
brokkoli_origin has joined #commonlisp
jjnkn has joined #commonlisp
flip214 has joined #commonlisp
koditals has joined #commonlisp
Inline has quit [Quit: Leaving]
brokkoli_origin has quit [Ping timeout: 260 seconds]
Inline has joined #commonlisp
brokkoli_origin has joined #commonlisp
waleee has quit [Ping timeout: 252 seconds]
jonatack has quit [Ping timeout: 255 seconds]
danse-nr3 has joined #commonlisp
evasync has quit [Ping timeout: 244 seconds]
markb1 has quit [Ping timeout: 252 seconds]
koditals has quit [Ping timeout: 252 seconds]
mgl has joined #commonlisp
NotThatRPG has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
aciep has quit [Ping timeout: 248 seconds]
Guest3 has quit [Quit: Client closed]
edgar-rft_ is now known as edgar-rft
mgl has quit [Ping timeout: 272 seconds]
Inline has quit [Ping timeout: 265 seconds]
prokhor_ has joined #commonlisp
prokhor has quit [Ping timeout: 265 seconds]
danse-nr3 has quit [Read error: Connection reset by peer]
koditals has joined #commonlisp
prokhor_ has quit [Remote host closed the connection]
danse-nr3 has joined #commonlisp
waleee has joined #commonlisp
oneeyedalien has joined #commonlisp
amb007 has quit [Ping timeout: 252 seconds]
amb007 has joined #commonlisp
bubblegum has quit [Quit: disappeared]
JuanDaugherty has quit [Quit: JuanDaugherty]
oneeyedalien has quit [Ping timeout: 260 seconds]
kamafam has quit [Quit: kamafam]
jonatack has joined #commonlisp
yitzi has quit [Ping timeout: 272 seconds]
yitzi_ has joined #commonlisp
Pixel_Outlaw has joined #commonlisp
yitzi_ has quit [Remote host closed the connection]
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
NotThatRPG has joined #commonlisp
oneeyedalien has joined #commonlisp
yitzi has joined #commonlisp
shawnw has joined #commonlisp
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #commonlisp
ym has quit [Ping timeout: 276 seconds]
danse-nr3 has quit [Quit: good night]
attila_lendvai has joined #commonlisp
Ruby has joined #commonlisp
X-Scale has joined #commonlisp
X-Scale28 has joined #commonlisp
X-Scale has quit [Ping timeout: 256 seconds]
X-Scale28 has quit [Ping timeout: 256 seconds]
<jjnkn>
/quit
jjnkn has quit [Remote host closed the connection]
X-Scale has joined #commonlisp
mwnaylor has joined #commonlisp
X-Scale has quit [Ping timeout: 256 seconds]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
Alfr has quit [Read error: Connection reset by peer]
Alfr has joined #commonlisp
steew has quit [Remote host closed the connection]
yitzi has quit [Remote host closed the connection]
amb007 has quit [Ping timeout: 245 seconds]
amb007 has joined #commonlisp
JuanDaugherty has joined #commonlisp
varjagg is now known as varjag
amb007 has quit [Ping timeout: 260 seconds]
oneeyedalien has quit [Quit: Leaving]
amb007 has joined #commonlisp
pve has quit [Quit: leaving]
JuanDaugherty has quit [Quit: JuanDaugherty]
koditals has quit [Ping timeout: 260 seconds]
molson_ has joined #commonlisp
molson has quit [Ping timeout: 252 seconds]
zetef has joined #commonlisp
zetef has quit [Client Quit]
<mwnaylor>
Had to install sbcl as a requirement for installing stumpwm. Enjoying the experience. Quick start times when firing up a repl in emacs w/ slime.
cage has quit [Quit: rcirc on GNU Emacs 29.4]
attila_lendvai has quit [Ping timeout: 252 seconds]
<paulapatience>
mwnaylor: Haven't you been using stumpwm all this time?
triffid has quit [Remote host closed the connection]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 255 seconds]
wbooze has joined #commonlisp
<paulapatience>
I mean I thought you were writing extensions for stumpwm. Unless I am thinking of someone else.
rendar has quit [Ping timeout: 248 seconds]
Inline has joined #commonlisp
wbooze has quit [Ping timeout: 252 seconds]
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dino_tutter has quit [Ping timeout: 272 seconds]
zetef has joined #commonlisp
zetef has quit [Client Quit]
pranavats has left #commonlisp [Disconnected: Hibernating too long]
X-Scale has joined #commonlisp
ym has quit [Ping timeout: 272 seconds]
shka has quit [Ping timeout: 260 seconds]
thuna` has quit [Remote host closed the connection]
char has joined #commonlisp
<mwnaylor>
Yes, small extensions. But I also just started with stumpwm and am expanding on my limited experience w/ common lisp.
<mwnaylor>
I've been hacking on my emacs for years. stumpwm has the same spirit of openess and the ability to extend. It helps that bout CL and elisp are lisp-2, and that there are common lisp packages in elisp.
<mwnaylor>
Mostly I wrote grenumber, which is the group equivalet to the windows renumber command. I've also used sparse key maps and define key for my own key commands.
Ruby has joined #commonlisp
X-Scale has quit [Ping timeout: 256 seconds]
varjag has quit [Ping timeout: 252 seconds]
xlymian has quit [Ping timeout: 276 seconds]
<mwnaylor>
Some simple code in my .stumpwmrc to automatically set up the groups I want on hand at startup.
ym has joined #commonlisp
istewart has joined #commonlisp
istewart has quit [Client Quit]
theBlackDragon has quit [Remote host closed the connection]
theBlackDragon has joined #commonlisp
<mwnaylor>
@Xt
donleo has quit [Ping timeout: 255 seconds]
Alfr has quit [Killed (lead.libera.chat (Nickname regained by services))]