jackdaniel changed the topic of #commonlisp to: Common Lisp, the #1=(programmable . #1#) programming language | Wiki: <https://www.cliki.net> | IRC Logs: <https://irclog.tymoon.eu/libera/%23commonlisp> | Cookbook: <https://lispcookbook.github.io/cl-cookbook> | Pastebin: <https://plaster.tymoon.eu/>
waleee has quit [Ping timeout: 244 seconds]
waleee has joined #commonlisp
<mathrick> I have to also wonder how much the fact it's Launchpad contributes to its general disuse. Launchpad has an amazingly confusing UI, and I never could stomach it, even back when I was a big fan of Bazaar and used the built-in Launchpad integration
morganw has quit [Remote host closed the connection]
jmdaemon has joined #commonlisp
<mathrick> given a list of of applicable methods, how do I compare them for specificity?
<mathrick> CLHS specifies how class precedence list is determined in pseudocode, but doesn't mention any built-in tools that actually implement it
thuna` has quit [Remote host closed the connection]
Catie has quit [Quit: sQuit]
waleee has quit [Ping timeout: 244 seconds]
azimut has quit [Ping timeout: 258 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 244 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 244 seconds]
<Bike> mathrick: i believe the only mop interface to this is compute-applicable-methods, etc. but if you're still working on a method combination, define-method-combination should give you teh methods in sorted order
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 244 seconds]
orestarod has quit [Ping timeout: 268 seconds]
comatory_ has joined #commonlisp
Nilby has quit [Ping timeout: 255 seconds]
comatory_ has quit [Ping timeout: 268 seconds]
jmdaemon has quit [Ping timeout: 248 seconds]
hineios has quit [Ping timeout: 252 seconds]
comatory_ has joined #commonlisp
hineios has joined #commonlisp
Oladon has joined #commonlisp
comatory_ has quit [Ping timeout: 252 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 252 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 244 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
jmdaemon has joined #commonlisp
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 268 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 260 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 268 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 252 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 268 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
comatory_ has joined #commonlisp
justJingo has quit [Quit: ZNC 1.8.2 - https://znc.in]
justache has joined #commonlisp
comatory_ has quit [Ping timeout: 268 seconds]
comatory_ has joined #commonlisp
jmdaemon has quit [Quit: ZNC 1.8.2 - https://znc.in]
comatory_ has quit [Ping timeout: 248 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 244 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 252 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 268 seconds]
comatory_ has joined #commonlisp
eddof13 has joined #commonlisp
comatory_ has quit [Ping timeout: 244 seconds]
rgherdt has quit [Ping timeout: 260 seconds]
eddof13 has quit [Client Quit]
comatory_ has joined #commonlisp
mathrick has quit [Ping timeout: 260 seconds]
comatory_ has quit [Ping timeout: 244 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
mathrick has joined #commonlisp
comatory_ has joined #commonlisp
SR-71 has joined #commonlisp
razetime has joined #commonlisp
comatory_ has quit [Ping timeout: 260 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 252 seconds]
comatory_ has joined #commonlisp
Oladon has quit [Quit: Leaving.]
comatory_ has quit [Ping timeout: 248 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 252 seconds]
jmdaemon has joined #commonlisp
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 268 seconds]
pve has joined #commonlisp
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 252 seconds]
comatory_ has joined #commonlisp
eddof13 has joined #commonlisp
eddof13 has quit [Client Quit]
comatory_ has quit [Ping timeout: 252 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
comatory_ has joined #commonlisp
comatory_ has quit [Ping timeout: 248 seconds]
razetime has quit [Ping timeout: 244 seconds]
attila_lendvai has joined #commonlisp
shka has joined #commonlisp
ttree has quit [Ping timeout: 248 seconds]
rgherdt has joined #commonlisp
lottaquestions has joined #commonlisp
lottaquestions has quit [Client Quit]
makomo has quit [Quit: WeeChat 3.5]
lottaquestions has joined #commonlisp
cage has joined #commonlisp
Noisytoot has quit [Quit: ZNC 1.8.2 - https://znc.in]
Noisytoot has joined #commonlisp
frgo has joined #commonlisp
Helmholtz1 has joined #commonlisp
razetime has joined #commonlisp
<Helmholtz1> Is there a way to use C-style format specifiers for printf? (%s, \n, etc)
<Helmholtz1> *for format
<beach> Why would you want that?
<Helmholtz1> beach, familiarity
<Helmholtz1> I have not delved into CL...I'm just wondering
<beach> And at the same time make your code unreadable to others?
waleee has joined #commonlisp
<jcowan> Helmholtz1: You could write some code that converts a C-style format string into a CL-style one, since C-style is a subset.
<_death> if you really need it there's https://github.com/splittist/printfcl
hineios1 has joined #commonlisp
cosimone has joined #commonlisp
Helmholtz1 has quit [Ping timeout: 244 seconds]
hineios has quit [Ping timeout: 244 seconds]
hineios1 is now known as hineios
<_death> note that \n has nothing to do with printf, but with C syntax
random-nick has joined #commonlisp
Dynom_ has joined #commonlisp
Dynom_ is now known as Guest1009
pranavats has left #commonlisp [Disconnected: Replaced by new connection]
Brucio-61 has joined #commonlisp
waleee has quit [Ping timeout: 268 seconds]
Noisytoot has quit [Quit: ZNC 1.8.2 - https://znc.in]
Noisytoot has joined #commonlisp
jeosol has quit [Quit: Client closed]
pranavats has joined #commonlisp
<beach> The Common Lisp HyperSpec entry for NTHCDR says that "For n being an integer greater than 1, the error checking done by (nthcdr n list) is the same as for (nthcdr (- n 1) (cdr list))". Can anyone see a reason why this would not be true also for n equal to 1?
<beach> Never mind. I think I see it.
<beach> (nthcdr 1 '(a . b)) is allowed, but (nthcdr 0 'b) is an error.
<beach> It would be more consistent if (nthcdr 0 <anything>) would be <anything>, but that's not the case.
<_death> what about (nthcdr 2 '(a . b)), if you had a naive recursive implementation
Noisytoot has quit [Quit: ZNC 1.8.2 - https://znc.in]
Noisytoot has joined #commonlisp
* edgar-rft eagerly awaits NICL (Naively Implemented Common Lisp)
samebchase- has quit [Quit: Ping timeout (120 seconds)]
samebchase- has joined #commonlisp
<_death> the naivety is to make a point about consistency
azimut has joined #commonlisp
<SR-71> For someone using CL for the web please checkout
Noisytoot has quit [Quit: ZNC 1.8.2 - https://znc.in]
Noisytoot has joined #commonlisp
Noisytoot has quit [Excess Flood]
Noisytoot has joined #commonlisp
SR-71 has quit [Ping timeout: 244 seconds]
Noisytoot has quit [Remote host closed the connection]
Noisytoot has joined #commonlisp
perrierjouet has quit [Quit: WeeChat 3.6]
perrierjouet has joined #commonlisp
orestarod has joined #commonlisp
jmdaemon has quit [Ping timeout: 252 seconds]
epony has quit [Remote host closed the connection]
tyson2 has joined #commonlisp
thuna` has joined #commonlisp
<gendl> Hi Shinmera: have you used Deploy to deploy a CCL or SBCL application with cl+ssl built into it, where it's built on a linux distro with e.g. openssl 1.1.1 then the image is deployed to a host with e.g. openssl 3.0?
<Shinmera> Not specifically tried, but you should definitely add a (DEPLOY:DEFINE-LIBRARY CL+SSL/CONFIG::LIBSSL :DONT-DEPLOY T) (DEPLOY:DEFINE-LIBRARY CL+SSL/CONFIG::LIBCRYPTO :DONT-DEPLOY T) to your stuff
<Shinmera> you do *not* want to ship your local ssl libraries, they have way too many dependencies that will break on a target system.
Andrew has quit [Quit: Disappearing for a while, email me if you need to talk: andrew AT andrewyu DOT org.]
zachel_ has quit [Quit: DIsconnected: v7+nano]
zachel has joined #commonlisp
zachel has quit [Quit: DIsconnected: v7+nano]
zachel has joined #commonlisp
zachel has quit [Client Quit]
zachel has joined #commonlisp
aartaka has joined #commonlisp
azimut has quit [Ping timeout: 258 seconds]
azimut has joined #commonlisp
<jcowan> I was trying to build a C program on Mac that depended on SSL 1.1.0, which apparently is no longer available on that platform, so I would have had to conditionalize a whole raft of function calls, ugh. I gave up.
comatory_ has joined #commonlisp
cage has quit [Remote host closed the connection]
cage has joined #commonlisp
pranavats has left #commonlisp [Error from remote client]
puhi has quit [Quit: (;´Д`)]
puhi has joined #commonlisp
<beach> _death: A naive implementation with 0 as the base case would not be conforming.
Noisytoot has quit [Quit: ZNC 1.8.2 - https://znc.in]
Noisytoot has joined #commonlisp
pranavats has joined #commonlisp
dmgk has joined #commonlisp
euandreh has quit [Ping timeout: 260 seconds]
<_death> beach: my earlier comment was a bit harebrained, but wouldn't a naive implementation like (defun my-nthcdr (n x) (check-type n (integer 0)) (if (zerop n) x (my-nthcdr (1- n) (cdr x)))) work?
<beach> That's right, because it would be the identity function for n=0 and that's not allowed.
<beach> Though now that I have said that, perhaps that's undefined behavior.
<_death> but it's a constraint on the argument type..
<_death> that's why the example has a local declaration for safety
<beach> I am not sure I follow.
<beach> It looks to me like (my-nthcdr 0 234) returns 234.
<beach> And the specification says that x has to be a list. It can be a dotted list or a circular list, but it has to be a list.
<_death> if you pass 234 then you (the user) are violating the argument type constraint
<beach> But I didn't check the "exceptional situations" part, so it is possible that it is undefined behavior then.
<beach> If so, then yes, your implementation will be conforming.
<beach> It wouldn't be a "polite" implementation, but indeed conforming.
<_death> clhs 1.4.4.3
<specbot> The ``Arguments and Values'' Section of a Dictionary Entry: http://www.lispworks.com/reference/HyperSpec/Body/01_ddc.htm
<beach> Yes, I know that one.
<_death> there's no exception situation description for the case where n=0, so it seems undefined behavior to me
<beach> But again, I didn't check the "Exceptional situations" for this particular operator. That's where the "Except as explicitly specified otherwise" would be indicated.
<_death> *exceptional
<beach> Yes, you are right.
<beach> A case for WSCL.
<_death> if there's value in defining it?
<beach> There is. Otherwise a conforming implementation can do some nasty things to your image.
<_death> but isn't it a matter of the quality of implementation then?
aartaka has quit [Ping timeout: 268 seconds]
<beach> Sure. Whatever.
euandreh has joined #commonlisp
<_death> if you want to define it, you probably want to decide between signaling an error or returning the value as-is.. signaling an error means another check and that the naive implementation is out.. returning the value as-is may result in forming a user's expectation
<_death> (which would be unjustified if the argument type constraint is preserved)
<beach> I want to define it, but it sounds like your opinion is that most of WSCL is misguided.
<_death> no.. I've no strong opinion about any of this.. just exploring
<beach> And, yes, WSCL would keep the indicated argument constraint.
<beach> _death: I suggest you give it some thought then. I mean, CAR and CDR are specified to signal an error if the argument is not a list. So there is some obvious asymmetry there. Perhaps that requirement should instead be removed, since it could be argued that it's a matter of quality of the implementation.
<beach> The purpose of WSCL is to have a specification that is as safe as possible when the SAFETY quality is maximal. So what I have been doing is to specify situations like the one for NTHCDR to signal an error in safe code, provided that all major implementations already do it, and provided there is no significant cost associated with it.
<_death> I talked about quality of implementation in the context of "nasty things".. to signal an error or return value is not one of them, generally speaking.. I think a non-nasty implementation may do one of those..
rendar has quit [Quit: Leaving]
rendar has joined #commonlisp
rendar has joined #commonlisp
<_death> so the alternative in my mind is between specifying which one to do and keeping it undefined (but hopefully non-nasty, especially when safety is not 0..)
<jcowan> Are WSCL and BOCL meant to be related in some way?
cosimone` has joined #commonlisp
cosimone has quit [Ping timeout: 248 seconds]
<beach> jcowan: No.
tane has joined #commonlisp
tane has quit [Changing host]
tane has joined #commonlisp
<beach> jcowan: BOCL is mainly a fun thought experiment, but it could become useful one day. The main issue is that some operating systems allow only packages that can be built with only a C compiler.
<beach> jcowan: But some Common Lisp implementations require Common Lisp in order to build.
eddof13 has joined #commonlisp
<beach> jcowan: So the idea for BOCL is a Common Lisp implementation that can be built using only a C compiler, plus, it is more maintainable than existing such implementations, because it does not contain results of decisions to make it fast for general-purpose programming.
<beach> Then, a Common Lisp implementation that requires Common Lisp to build, can be built using BOCL.
Oladon has joined #commonlisp
<beach> As it turns out, BOCL is amusing to contemplate, because of this specificity that maintainability and simplicity is more important than performance.
<jcowan> Right. It seems to me that because of its greater simplicity, BOCL should be written to conform to WSCL.
<jcowan> s/its/WSCL'
<beach> Definitely.
<jcowan> So there is a link between them, at least it makes sense to have one
<beach> Sort of. I think every implementation should conform to WSCL.
<beach> So there is a link between WSCL and every implementation, and BOCL is no exception. But there is no other particular connection.
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kuao has joined #commonlisp
cosimone` has quit [Ping timeout: 260 seconds]
<jackdaniel> if the function checks its argument (and signals an error), then this could be probably use by the type inferencer
<jackdaniel> (and an edge case of the type inferencer is the programmer who sees the code :)
jmdaemon has joined #commonlisp
perrierjouet has quit [Ping timeout: 244 seconds]
Josh_2 has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
<Josh_2> Good Morning :sunglasses:
notzmv has quit [Ping timeout: 268 seconds]
orestarod has quit [Quit: Leaving]
razetime has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
ttree has joined #commonlisp
<mathrick> Bike: right, they will be sorted, but I want to sort them in "most specific first, then by priority" order, and I expect to have multiple methods of equal specificity, so without that information, I can't preserve the order properly
<mathrick> unless there's some combination of STABLE-SORT invocations I haven't thought of
cosimone` has joined #commonlisp
<gendl> Shinmera: Noted 🙏🏻
pranavats has left #commonlisp [Error from remote client]
perrierjouet has joined #commonlisp
pranavats has joined #commonlisp
jolby has joined #commonlisp
tyson2 has joined #commonlisp
pjb has joined #commonlisp
pjb has quit [Ping timeout: 268 seconds]
tyson2` has joined #commonlisp
tyson2` has quit [Remote host closed the connection]
tyson2` has joined #commonlisp
tyson2` has quit [Remote host closed the connection]
tyson2 has quit [Ping timeout: 268 seconds]
tyson2 has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
pjb has joined #commonlisp
simendsjo has joined #commonlisp
pjb has quit [Changing host]
pjb has joined #commonlisp
Lord_of_Life has quit [Ping timeout: 244 seconds]
pjb is now known as Guest2276
pjb has joined #commonlisp
Lord_of_Life has joined #commonlisp
pjb has quit [Remote host closed the connection]
Guest2276 has quit [Remote host closed the connection]
pjb has joined #commonlisp
anticomputer_ has joined #commonlisp
anticomputer has quit [Ping timeout: 258 seconds]
tyson2 has joined #commonlisp
<Josh_2> Is Chanl broken?
tyson2 has quit [Remote host closed the connection]
<Josh_2> Test SEND-BUFFERED keeps failing
<Josh_2> Rip
akoana has joined #commonlisp
tyson2 has joined #commonlisp
<Josh_2> I will just use lparallel
Noisytoot has quit [Remote host closed the connection]
Noisytoot has joined #commonlisp
mariari has quit [Ping timeout: 244 seconds]
Noisytoot has quit [Remote host closed the connection]
kuao has quit [Quit: Connection closed for inactivity]
Noisytoot has joined #commonlisp
tyson2` has joined #commonlisp
tyson2 has quit [Read error: Connection reset by peer]
Noisytoot has quit [Remote host closed the connection]
dmgk has quit [Quit: ZNC - https://znc.in]
Josh_2 has quit [Ping timeout: 244 seconds]
dmgk has joined #commonlisp
mariari has joined #commonlisp
notzmv has joined #commonlisp
Noisytoot has joined #commonlisp
tyson2` has quit [Remote host closed the connection]
simendsjo has quit [Ping timeout: 244 seconds]
chipxxx has joined #commonlisp
nij- has joined #commonlisp
<nij-> Hello! Is (let ((result '()')) (push 1 result)) good practice? My compiler does not complain, but I think it's not as it is mutating literal stuff.
<mfiano> Minus the superfluous quote, it is fine.
<aeth> nij-: it's mutating RESULT, not '()
tane has quit [Quit: Leaving]
<aeth> linked lists aren't real, only conses are real
<aeth> linked lists are just syntactic sugar
<nij-> s/'()'/'()/
<aeth> nij-: if it really bothers you, you could use (list) though
<nij-> or just (let (result) (push 1 result))
<aeth> I think (list) would communicate the intent better
<nij-> I am just curious.. why isn't the literal nil getting mutated @@?
<mfiano> I strongly advice against that syntax
<nij-> mfiano against which syntax?
<mfiano> (let (result) ...)
<nij-> mfiano What would you do instead?
<mfiano> Your sed substitution
<aeth> that's probably the worst of the four ways to get it. If you're going to use NIL, be explicit about it and do (result nil)
<nij-> result, (result nil), (result '()), (result (list))
<aeth> (Okay, there are more than four ways, but all of the other ways are even worse, e.g. (gethash :empty (make-hash-table)) gives you a NIL)
<nij-> (list) is not good as it involves another computation?
<nij-> Which one is better? a - (result nil), b- (result '())
<aeth> no, any compiler worth using is going to turn (list) into NIL
<aeth> (maybe CLISP doesn't)
<mfiano> (aref #0a())
<nij-> aeth But then the compiler needs to do that extra step, which isn't much difference but still.
<nij-> I think I'd prefer (result nil) more than (result '())..
<aeth> nij-: '() suggests that you might be building up an immutable list, while (list) makes it clear to the reader that it's being used mutably... but you can't mutate NIL itself, so it won't hurt to use NIL or '()
<mfiano> I do too. Don't be discouraged by the purists that will point you to some archaic style guide
<mfiano> I always do (let ((result nil)) ...)
<nij-> mfiano thanks for sharing that! yeah, I think that's more beautiful than (let (result)) ..
<aeth> I personally would prefer either (list) or nil and am probably 50/50 either way since '() suggests too strongly that it's going to be immutable even though it doesn't have to be
<nij-> mfiano why don't you like (let ((result '())))?
<nij-> aeth ah good point; yeah '() sort of hints that and that's what made me uncomfortable
<mfiano> Mostly because nil stands out to me more in a soup of parentheses, and I know from the context what the intent is
<mfiano> It also syntax highlights differently for me
<nij-> good ok! I will use (let ((result nil))) from now on
<aeth> Consider, though, that '() or NIL or (list) is just the / part of the boxed cons cell list representation like [ |/] and not itself a cons cell. It terminates the linked list.
<aeth> The first push turns it into [pushed-thing|/]
<aeth> the '() itself will never be mutated even if you mutate the contents of the list
<aeth> that's also why push is modifying RESULT, not the list itself... it can't modify the list itself.
<aeth> It's just adding things to the front
cosimone` has quit [Ping timeout: 252 seconds]
<aeth> so it is perfectly safe to build mutable lists where everything is mutated (not just while building it) off of a '()
<aeth> by contrast, it wouldn't be safe to built it off of '(1) if you expect to mutate the elements of the list later on (but if you're just appending to the front, it's still going to be safe because the tail would never be modified)
chipxxx has quit [Read error: Connection reset by peer]
<nij-> What's an example to mutate a literal list?
<nij-> (push 3 '())?
<aeth> you'd need to (setf car) or (setf cdr) to mutate a literal list, which could be dangerous for '(1) but won't work on '() because it's not a cons. That's because (deftype list () '(or cons null))
<aeth> Adding to the front (like push) is always safe. Adding to the tail like (setf cdr) isn't.
<aeth> This is somewhat counterintuitive because linked lists in Lisp are very direct and low-level. You don't get some sort of encapsulating data structure around it like with vectors (and e.g. vector-push-extend).
<aeth> Every sublist is itself a list, so if you keep adding to the start, you're just updating what you consider to be the current start of the list locally.
<nij-> I need to give it more thoughts..
<aeth> '(2 1) and '(3 1) could share a structure
<aeth> (the tail)
<aeth> and modifying '(1) to, say, '(4) could, depending on the implementation turn '(2 1) and '(3 1) into '(2 4) and '(3 4)
<nij-> Could you provide an example of a bad practice?
<nij-> Modifying with what form?
<aeth> something like this is the bad practice: (let ((l '(1))) (setf (car l) 4) l) => '(4)
thuna` has quit [Remote host closed the connection]
<aeth> as well as setting its cdr
<aeth> but pushing is fine, because pushing just adds another cons in front
<aeth> (let ((l '(1))) (push 4 l) l) => (4 1)
<aeth> this is safe
<nij-> How about (let ((l '())) (setf (car l) 4))?
<aeth> that will error because '() is a list but not a cons
<aeth> but just avoiding quoted literals for anything mutable (even '() even though it's safe, unlike '(1)) means you don't really have to think low-level at all so it's just simpler to work with
<aeth> so I personally wouldn't push to a '(1) instead of a (list 1)
cage has quit [Quit: rcirc on GNU Emacs 27.1]
akoana has quit [Quit: leaving]
<aeth> Because that requires knowing that push is mutatable in the right way, not the wrong way. Plus, you'd need to know that all users of that list don't modify the final element or else everything generated with that function might be modified.
<aeth> (Because the last element would be shared among every generated linked list)
<aeth> (Or could be, anyway)
<aeth> You can't modify NIL or '() or (list) so it is just a stylistic choice, but it's just nicer to be consistent and avoid '() in this context since you'd want to avoid '(1) in this context.
<aeth> Note that '() or NIL isn't the final element (the final CAR), though. It's the final CDR. The first thing you push is actually going to become the final element (the CAR of the last CONS).
<mathrick> question: given a list of methods, with the restriction that they're all *applicable* to some argument list, can I compare any two of them for specificity based on their specialisers alone, without reference to that argument list?
<mathrick> I know this is a very specific set of weird requirements, but this happens to be what the method combination expander is given, and I'd like to be able to sort the methods by specificity myself without needing to see the argument list, if possible
<nij-> Ah, I see :D
<Bike> mathrick: assuming you can't just use the existing sorted order for the reason you said, and assuming this is a normal generic function that doesn't have a weird compute-applicable-methods, you could probably do it yourself using the mop tools
<Bike> mathrick: that is, using method-specializers, generic-function-argument-precedence-order, subtypep, etc
Guest1009 has quit [Quit: WeeChat 3.6]
<mathrick> yeah, that's what I was hoping for
<mathrick> even with a weird compute-applicable-methods, by the time I'm in the method combination body, it has been called and I know the list of applicable methods, no?
<Bike> but given your goal, maybe you could cheap out more and just only resort-by-priority methods that have the same specializers, which ought to be next to each other in the list the method combination gets
<mathrick> Bike: ooooh, that's a good point! I can just scan the list and derive their specificity that way and map it to a number
<Bike> compute-applicable-methods also does the sorting, so one could define a method on it to impose some different sorting order
<Bike> (but, again, nobody actually does this, as far as i know)
<Bike> so actually i guess all you need to do is stable-sort the list with a predicate of (and (equal (method-specializers m1) (method-specializers m2)) (< (method-priority m1) (method-priority m2))) or so?
<pjb> nij-: if you want to initialize a list, use '() ; if you want to initialize a boolean, use nil ; if you want to initialize a symbol, use 'nil ; use () only in code.
<pjb> nij-: so the correct form to transmit your intent the best to the human programmer is (let ((result '())) (push 1 result) result)
<pjb> nij-: what's mutable, it's the consed list bound to result. Obviously, neither 1 or NIL which are referenced by this chain of conses are mutable!
<aeth> pjb: well, no, because '() is equivalent to (list) and the latter is superior in communicating your intent (that the list you're building is likely safe-to-mutate all the way through)
<pjb> (1) = (1 . nil) ; the cons is mutable, 1 is not ; nil is not for it's name slot, (nor it's package or function slot, since it's in CL). But it's symbol plist is still mutable!
<pjb> aeth: it communicates nothing! You wouldn't use (/ 1 1) to get 1 !
<aeth> pjb: you can also extend (list) if you for whatever reason want to hard code a tail now. (list 1 2 3) vs '(1 2 3) suddenly breaking
<pjb> or (- 3 2)
<aeth> pjb: I don't know. You might in fact want to use (*) to get 1 in some rare contexts, which is closer to what's going on.
<pjb> aeth: in this case the right way to use list is: (list 1).
<mathrick> Bike: tempting, but I'm afraid that's not enough. SORT will get weird if the comparison function's answers are inconsistent, and it needs to be able to compare any two elements. But maybe it will not be a problem with STABLE-SORT
<pjb> Well, if you have a context where you'd prefer to use (*) rather than 1, then indeed, you'd rather use (list) than '(). But since we agree to use 1 in the exposed context, '() should be.
<aeth> pjb: arguably if you're building a sum you might want to start off of (+) instead of 0 and if you're building a product you might want to start off of (*) intead of 1, and if that wasn't the case, then it wouldn't even work at all.
<aeth> (list) of course is just a far, far, far more common thing
<aeth> (in Lisp, anyway)
<Bike> oh, i guess you are right
<pjb> aeth: you have quicklisp, count the (list) vs '() !!!
<pjb> people prefer concrete values, rather than indirect references.
<pjb> You could of course use an operation parameter in a HOF and use (funcall operation new (funcall operation)) to work for both (* new 1) (+ new 0) (list new (list)) oops that doesn't work, and neither does: (list* 1 (list*)).
waleee has joined #commonlisp
<pjb> (we could argue that list* is defective here).
<aeth> Every time I think I found a use for list*, I never actually do.
<aeth> If I grep my code I might find it once or twice, though
<pjb> I had a few uses for it.
<pjb> Yes.
<pjb> It's like append.
<aeth> Yes. Just as a rule of thumb, every time I think I might need LIST*, I wind up using APPEND or CONS.
<mathrick> Bike: also, I think to get the order of "by specificity, then by priority", the order of sorts would be "by priority", then stable sort by specificity, and that's basically why I'm trying to get a thing that can compare by specificity. If my goal were the other way around, it would be trivial with STABLE-SORT
<aeth> looks like LIST* is basically just a repeated application of CONS to a tail list, e.g. (list* 1 2 (list 3 4))
<aeth> or alternatively an append treating all but the final element as implicitly part of a (list ...)
<aeth> I had to play with it in the REPL just to refresh myself because I never use it.
<pjb> (defun append (fun &rest arguments) (apply1 fun (apply1 (function list*) arguments)))
<Bike> mathrick: sure. i think you can hack it the other way around, tho.
jeosol has joined #commonlisp
<pjb> which shows that apply does 2 things.
<mathrick> Bike: yeah, your point that I can reverse-engineer the information from the fact I know the list is sorted already, and I can compare its elements for equality is really helpful, thanks :)
<mathrick> that is enough to recover substitute sorting keys from that
<mathrick> also, this section is just completely unreadable in HTML: http://www.lispworks.com/documentation/lw50/CLHS/Body/04_ce.htm
<mathrick> I had to find the TeX source and get it rendered to figure out what it was trying to say
euandreh has quit [Ping timeout: 244 seconds]
euandreh has joined #commonlisp
<Bike> mathrick: yeah, the subscripts get wonky. but you at least shouldn't need to determine the class precedence list yourself, you can get it with mop
kuao has joined #commonlisp
orestarod has joined #commonlisp
pve has quit [Quit: leaving]
jmdaemon has quit [Quit: ZNC 1.8.2 - https://znc.in]
jmdaemon has joined #commonlisp
<jcowan> I've been thinking about the idea of an UNORDERED-PROGN special form, the effect of which is that the compiler is free to reorder its forms
<jcowan> (if (consp x) (unordered-progn (setf (car x) 'this) (setf (cdr x) 'that)))
<jcowan> it does not matter which setf is performed first
<aeth> if it already existed, it would probably use a name like PPROGN (like PSETF)
<jcowan> makes sense
<pjb> And what would the result be?
<jcowan> I had forgotten about psetf
<jcowan> Unspecified result
<pjb> (pprogn (princ 'a) (princ 'b) (princ 'c)) could print ABC ACB BAC BCA CAB or CBA.
<jcowan> Yes
<aeth> best to have it return NIL and rely on either side effects or a RETURN-FROM (limit one because otherwise it's non-deterministic)
<aeth> similar to iirc TAGBODY
<jcowan> but (pprogn (print "foo" ostream1) (print "foo" ostream2)) is a more sensible case.
tyson2 has joined #commonlisp
<jcowan> I agree that nil is the right thing
<jcowan> like psetf
<aeth> (block nil (pprogn (return "success") (print "Hello") (print "World")))
<aeth> (return-from if a named block; only one return/return-from allowed)
<jcowan> or perhaps the last arm is the result
<jcowan> so only arms 1 to n-1 are executed unordered
pjb has quit [Ping timeout: 244 seconds]
<jcowan> then again (progn (pprogn (arm1) (arm2)) result) does that
<aeth> oh, yeah, that would make sense
<aeth> the last one as the result
attila_lendvai has quit [Ping timeout: 244 seconds]
<aeth> maybe have the two variations
epony has joined #commonlisp
son0p has quit [Remote host closed the connection]
<Bike> i have thought about an operator like this before, and there's a pretty similar one used in theoretical concurrency stuff sometimes, but it's a little... low level, as an optimization thing
son0p has joined #commonlisp
shka has quit [Ping timeout: 248 seconds]
rendar has quit [Quit: Leaving]
cowboy8625 has joined #commonlisp
<aeth> that's what I kind of like about Lisp though
<aeth> not afraid to go all the way up and down the abstraction level. Helps that it doesn't use (and invent meaning for) infix symbols
<aeth> (imagine the cognitive overhead of unsearchable symbols for everything)
dmgk has left #commonlisp [#commonlisp]
orestarod has quit [Ping timeout: 268 seconds]
Oladon has quit [Quit: Leaving.]
causal has joined #commonlisp
snits has quit [Ping timeout: 252 seconds]
snits has joined #commonlisp
waleee has quit [Ping timeout: 248 seconds]
snits has quit [Ping timeout: 268 seconds]
snits has joined #commonlisp
karlosz has quit [Quit: karlosz]
<jcowan> Bike: Scheme's denotational seantics uses a hack like this to represent the fact that in Scheme, arguments are evaluated in any order desired. It's not quite the right hack, because it scrambles the arguments statically instead of dynamically.