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/>
Noisytoot has quit [Ping timeout: 244 seconds]
cercopith has joined #commonlisp
cercopith_ has joined #commonlisp
cercopith_ has quit [Client Quit]
Noisytoot has joined #commonlisp
waleee has quit [Ping timeout: 244 seconds]
epony has joined #commonlisp
cercopith has quit [Remote host closed the connection]
cercopith has joined #commonlisp
razetime has joined #commonlisp
VincentVega has quit [Ping timeout: 244 seconds]
jeosol has joined #commonlisp
Noisytoot has quit [Quit: ZNC 1.8.2 - https://znc.in]
Noisytoot has joined #commonlisp
razetime has quit [Ping timeout: 244 seconds]
razetime has joined #commonlisp
orestarod has quit [Ping timeout: 264 seconds]
razetime has quit [Read error: Connection reset by peer]
razetime has joined #commonlisp
enzuru has quit [Quit: ZNC 1.8.2 - https://znc.in]
notzmv has quit [Ping timeout: 268 seconds]
enzuru has joined #commonlisp
azimut has joined #commonlisp
Brucio-61 has quit [Remote host closed the connection]
Brucio-61 has joined #commonlisp
ttree has quit [Ping timeout: 248 seconds]
Brucio-61 has quit [Remote host closed the connection]
Brucio-61 has joined #commonlisp
razetime has quit [Ping timeout: 244 seconds]
razetime has joined #commonlisp
mzan has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
mzan has joined #commonlisp
razetime has quit [Ping timeout: 244 seconds]
razetime has joined #commonlisp
qhong_ is now known as qhong
tyson2 has quit [Remote host closed the connection]
bilegeek has joined #commonlisp
notzmv has joined #commonlisp
rgherdt has quit [Ping timeout: 244 seconds]
rgherdt has joined #commonlisp
irc_user has joined #commonlisp
ttree has joined #commonlisp
comatory has quit [Ping timeout: 268 seconds]
comatory has joined #commonlisp
shka has joined #commonlisp
azimut has quit [Remote host closed the connection]
azimut has joined #commonlisp
azimut has quit [Remote host closed the connection]
azimut has joined #commonlisp
cercopith has quit [Remote host closed the connection]
cercopith has joined #commonlisp
razetime has quit [Ping timeout: 244 seconds]
razetime has joined #commonlisp
razetime has quit [Ping timeout: 252 seconds]
razetime has joined #commonlisp
razetime has quit [Ping timeout: 268 seconds]
razetime has joined #commonlisp
son0p has quit [Ping timeout: 244 seconds]
shka has quit [Ping timeout: 244 seconds]
pve has joined #commonlisp
bilegeek has quit [Quit: Leaving]
razetime has quit [Ping timeout: 244 seconds]
razetime has joined #commonlisp
ttree has quit [Ping timeout: 244 seconds]
razetime has quit [Ping timeout: 248 seconds]
razetime has joined #commonlisp
irc_user has quit [Quit: Connection closed for inactivity]
jgkamat- is now known as jgkamat
comatory has quit [Ping timeout: 252 seconds]
comatory has joined #commonlisp
lisp123 has joined #commonlisp
hrberg has joined #commonlisp
causal has quit [Quit: WeeChat 3.6]
Noisytoot has quit [Read error: Connection reset by peer]
Noisytoot_ has joined #commonlisp
tibfulv has quit [Remote host closed the connection]
tibfulv has joined #commonlisp
masinter has quit [Ping timeout: 252 seconds]
lisp123 has quit [Remote host closed the connection]
son0p has joined #commonlisp
pranavats has quit [Quit: Gateway shutdown]
contrapunctus has quit [Quit: Gateway shutdown]
thuna` has joined #commonlisp
jmdaemon has quit [Ping timeout: 260 seconds]
contrapunctus has joined #commonlisp
attila_lendvai has joined #commonlisp
rgherdt has quit [Ping timeout: 244 seconds]
random-nick has joined #commonlisp
rgherdt has joined #commonlisp
waleee has joined #commonlisp
waleee has quit [Ping timeout: 248 seconds]
azimut has quit [Remote host closed the connection]
azimut has joined #commonlisp
Conatus has joined #commonlisp
Noisytoot_ is now known as Noisytoot
Dynom_ has joined #commonlisp
Dynom_ is now known as Guest4686
epony has quit [Remote host closed the connection]
tyson2 has joined #commonlisp
semz has quit [Quit: ZNC 1.7.5+deb4 - https://znc.in]
semz has joined #commonlisp
euandreh has quit [Ping timeout: 255 seconds]
orestarod has joined #commonlisp
cage has joined #commonlisp
karlosz has joined #commonlisp
karlosz has quit [Remote host closed the connection]
masinter has joined #commonlisp
karlosz has joined #commonlisp
euandreh has joined #commonlisp
anticomputer has quit [Quit: quit]
anticomputer has joined #commonlisp
attila_lendvai_ has joined #commonlisp
attila_lendvai has quit [Ping timeout: 244 seconds]
cercopith has quit [Ping timeout: 244 seconds]
epony has joined #commonlisp
razetime_ has joined #commonlisp
razetime has quit [Ping timeout: 268 seconds]
cercopith has joined #commonlisp
attila_lendvai_ has quit [Ping timeout: 252 seconds]
masinter has quit [Ping timeout: 244 seconds]
karlosz has quit [Remote host closed the connection]
karlosz has joined #commonlisp
szkl has quit [Quit: Connection closed for inactivity]
comatory has quit [Ping timeout: 252 seconds]
comatory has joined #commonlisp
nij- has joined #commonlisp
masinter has joined #commonlisp
jmdaemon has joined #commonlisp
causal has joined #commonlisp
nij- has quit [Ping timeout: 244 seconds]
tyson2 has quit [Remote host closed the connection]
razetime_ has quit [Ping timeout: 240 seconds]
razetime has joined #commonlisp
hirez has quit [Quit: Later]
hirez has joined #commonlisp
makomo has quit [Ping timeout: 248 seconds]
aartaka has joined #commonlisp
karlosz has quit [Ping timeout: 244 seconds]
Equill has quit [Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/]
razetime_ has joined #commonlisp
razetime has quit [Ping timeout: 264 seconds]
makomo has joined #commonlisp
karlosz has joined #commonlisp
razetime has joined #commonlisp
razetime_ has quit [Ping timeout: 252 seconds]
karlosz has quit [Client Quit]
karlosz has joined #commonlisp
razetime has quit [Ping timeout: 252 seconds]
razetime has joined #commonlisp
razetime has quit [Ping timeout: 244 seconds]
razetime has joined #commonlisp
tyson2 has joined #commonlisp
akoana has joined #commonlisp
karlosz has quit [Ping timeout: 244 seconds]
<mathrick> what's the most elegant and/or compact way of only passing in an argument if the value is non-NIL, and otherwise leaving the default value untouched?
<mathrick> ie. not this: (defun my-intern (name &optional package) (intern name package)), because this will just pass in NIL as package, rather than letting INTERN use the non-NIL default
<yitzi> mathrick: specify a default value for package or use or.
<mathrick> yitzi: but I don't want to know what INTERN's default is. It's implementation-specific and can change. I just want to let it have it if I have nothing useful to add
<mathrick> the best I can think of is (apply #'intern name (when package `(,package))), but that's really ugly
<mathrick> and also doesn't scale very well to keyword arguments or multiple defaults
<yitzi> intern's default is `*package*`
<mathrick> yitzi: actually it's not, on SBCL it's SB-INT::SANE-PACKAGE
<mathrick> and I really don't want to have to know what it is
glaucon has joined #commonlisp
<yitzi> clhs 3.4
razetime has quit [Ping timeout: 268 seconds]
<yitzi> mathrick: Checkout the docs on lambda lists. They show you how to specify default values for arguments.
<mathrick> yitzi: I know how to do that :) I just don't want to repeat the same default the function I'm calling has already specified. It's really not an uncommon problem, and not specific to INTERN
<yitzi> You could use the supplied-p-parameter if you want to avoid knowing the default.
<mathrick> the same problem in python is solved by kwargs = {'arg': arg} if arg else {}; other_func(**kwargs)
<mathrick> yitzi: OK, tell me more please. How do I apply this knowledge to the actual call to INTERN?
glaucon has quit [Quit: WeeChat 3.5]
<mathrick> right, so that's just a plain IF. So we just don't have a more elegant way of doing it in other words?
<yitzi> Updated with three variants
<yitzi> shrug
<mathrick> that's why I was asking, cause those are all options I knew about, but none of them felt satisfactory
<Bike> mathrick: i understand you're not talking specifically about intern, but for the record, the default is definitely *package*. (sb-int:sane-package) is a wrapper function sbcl uses so that you can recover from mistakes you've made with *package*, but it will still eventually return *package*.
<mathrick> Bike: right. It was actually prompted by INTERN in this particular instance, but you're right, it's not at all specific to INTERN. In this case, I wanted to have the same protections (SB-INT:SANE-PACKAGE) affords me
<Bike> mathrick: the lisp equivalent to the python you wrote is pretty directly (let ((kwargs (if arg (list arg) nil))) (apply other-func kwargs)), or just (apply other-func (if arg (list arg) nil)).
<mathrick> but it is a much more painful issue when calling a function in a third-party library with many keyword arguments with defaults
<mathrick> Bike: aye, it's what I settled on. I just don't like how indirect and hard to read it is for what simple function it serves
<Bike> if the python solution is ok i don't understand why the lisp wouldn't be
<mathrick> mostly because python's solution still looks like a regular function call, but in CL, it changes to (APPLY #'FOO ...)
<mathrick> although TBH, I've never found python's solution to be all that great either, it's just functional enough that I can mostly live with it
<mathrick> and also I don't think I could do better
rgherdt_ has joined #commonlisp
<Bike> if you really want, you could define a reader macro to make {foo ...} read as (apply #'foo ...). but i don't think that's a good idea
rgherdt has quit [Ping timeout: 252 seconds]
aartaka has quit [Ping timeout: 240 seconds]
aartaka has joined #commonlisp
<mathrick> I don't either. I guess APPLY is just the best I can do, and will have to live with that
<yitzi> Python's ternary operator is an abomination, so there's that.
<mathrick> it is
<mathrick> it's not the worst part of its syntax though, that title almost certainly goes to undecorated tuple literals. Ie. return foo, # <-- this is now a single-element tuple of (foo,)
tyson2 has quit [Remote host closed the connection]
comatory has quit [Ping timeout: 244 seconds]
tyson2 has joined #commonlisp
comatory has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
sjl has joined #commonlisp
<aeth> {} is for hash tables, though :-p
<aeth> the best way to reset-to-default if the value is NIL is to provide the default twice, once in the lambda-list and once again in the body
<aeth> I guess that would be (unless foo (setf foo default)) or something if you want a messy hack without adding an extra level of parens
<aeth> Common Lisp has an amazing ternary
<aeth> Because you just pull the setf/setq out, as if factoring. Very intuitive. (setf x (if c a b)) vs (if c (setf x a) (setf x b))
karlosz has joined #commonlisp
McParen has joined #commonlisp
susam_ is now known as susam
<mathrick> aeth: I know it's for hash tables (or dicts, technically :). But you can do the same with *list, and also python allows you to refer to positional args with keywords, which I personally find immensely handy
<mathrick> it took them a while to get keyword-only arguments (which are just keyword arguments in CL), but having the ability to treat positional arguments as keywords can be very helpful
<pve> _death: Thanks for showing me that wikidata exists (with your Turing example yesterday), I had no idea. That thing is a gold mine. My code name generator will benefit greatly :)
Lord_of_Life_ has joined #commonlisp
Lord_of_Life has quit [Ping timeout: 244 seconds]
Lord_of_Life_ is now known as Lord_of_Life
morganw has joined #commonlisp
ttree has joined #commonlisp
karlosz has quit [Ping timeout: 244 seconds]
Oladon has joined #commonlisp
<aeth> mathrick: it would actually be a very useful feature in Common Lisp when combined with allow-other-keys
<aeth> everyone probably knows about &allow-other-keys but you can actually force it on at the caller, too
<aeth> (defun foo (&key bar baz) (values bar baz)) (foo :bar 42 :barfoo 24 :allow-other-keys t)
<mathrick> oh yeah, I just learn about it like two days ago
<aeth> this means the APIs don't need to exactly match, as long as they're keyword
<mathrick> *learnt
<aeth> not really useful with the example I gave, but extremely useful with higher order functions (which you then funcall, so the example would be the same just replace "foo" with "funcall foo")
<aeth> such a higher order function should work on anything that has the right keywords, but not every keyword is critically important to actually implement
azimut has quit [Ping timeout: 258 seconds]
cage has quit [Quit: rcirc on GNU Emacs 27.1]
tyson2 has joined #commonlisp
karlosz has joined #commonlisp
tyson2` has joined #commonlisp
tyson2` has quit [Remote host closed the connection]
tyson2 has quit [Ping timeout: 244 seconds]
tyson2 has joined #commonlisp
<_death> pve: cool.. likely want to create a list of names in a single query and then filter them off, instead of a query per word
tyson2 has quit [Remote host closed the connection]
karlosz has quit [Ping timeout: 268 seconds]
aartaka has quit [Ping timeout: 252 seconds]
bc4m has joined #commonlisp
McParen has left #commonlisp [#commonlisp]
kg7ski has quit [Quit: ZNC 1.8.2 - https://znc.in]
kg7ski has joined #commonlisp
<pve> _death: Oh absolutely, I'm trying constellations, chemical elements, scientists and other things. Got a bunch of clean looking lists already.
cercopith has quit [Remote host closed the connection]
cercopith has joined #commonlisp
waleee has joined #commonlisp
aartaka has joined #commonlisp
<_death> neat
cercopith has quit [Ping timeout: 252 seconds]
eddof13 has joined #commonlisp
karlosz has joined #commonlisp
aartaka has quit [Ping timeout: 252 seconds]
eddof13 has quit [Client Quit]
aartaka has joined #commonlisp
karlosz has quit [Quit: karlosz]
ttree has quit [Ping timeout: 264 seconds]
aartaka has quit [Ping timeout: 252 seconds]
thuna` has quit [Remote host closed the connection]
bc4m has quit [Quit: Client closed]
aartaka has joined #commonlisp
nij- has joined #commonlisp
Guest4686 has quit [Quit: WeeChat 3.6]
aartaka has quit [Ping timeout: 244 seconds]
Oladon has quit [Quit: Leaving.]
tyson2 has joined #commonlisp
ttree has joined #commonlisp
Oladon has joined #commonlisp
random-nick has quit [Ping timeout: 252 seconds]
pve has quit [Quit: leaving]
comatory has quit [Ping timeout: 244 seconds]
comatory has joined #commonlisp