jackdaniel changed the topic of #lisp to: Common Lisp, the #1=(programmable . #1#) programming language<http://cliki.net/> logs:<https://irclog.whitequark.org/lisp,http://ccl.clozure.com/irc-logs/lisp/> | SBCL 1.4.5, CMUCL 21b, ECL 16.1.3, CCL 1.11.5, ABCL 1.5.0
dto has quit [Remote host closed the connection]
arkaros has quit [Ping timeout: 272 seconds]
rumbler31 has quit [Remote host closed the connection]
blt has quit [Ping timeout: 246 seconds]
pjb has quit [Ping timeout: 252 seconds]
Pixel_Outlaw has joined #lisp
rozenglass has joined #lisp
emaczen has quit [Read error: Connection reset by peer]
v0|d has quit [Ping timeout: 252 seconds]
emaczen has joined #lisp
frodef has quit [Ping timeout: 252 seconds]
edgar-rft has joined #lisp
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 264 seconds]
graphene has quit [Remote host closed the connection]
graphene has joined #lisp
<oni-on-ion> is it trivial to swap out packages? ie. if i have two implementations of something, with the same interface, could i swap them at runtime? i amassuming so, like with find-symbol etc
graphene has quit [Remote host closed the connection]
graphene has joined #lisp
jcowan has joined #lisp
<jcowan> Can anyone suggest use cases for `copy-symbol`, either with or without copying properties (value cell, function cell, p-list)?
<oni-on-ion> clhs copy-symbol
Oladon has quit [Quit: Leaving.]
<oni-on-ion> see the examples there.. it would seem that testing for inequality might have some interesting cases
<oni-on-ion> string=
orivej has quit [Ping timeout: 240 seconds]
jcowan has quit [Quit: This computer has gone to sleep]
X-Scale has quit [Ping timeout: 252 seconds]
lemonpepper24 has quit [Ping timeout: 240 seconds]
blt has joined #lisp
<oni-on-ion> :pkg.pkg:extern-symbol ;; too many colons in symbol. ehhh
dale has joined #lisp
arkaros has joined #lisp
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
arkaros has quit [Ping timeout: 245 seconds]
X-Scale has joined #lisp
housel has quit [Ping timeout: 240 seconds]
jcowan has joined #lisp
<jcowan> The examples for copy-symbol show what the function does, it doesn't give any indication of why you'd use it in practice.
blt has quit [Read error: Connection reset by peer]
<aeth> hyperspec examples are usually interesting edge cases for implementors, perhaps something you'd want to put in a test case for standards compliance.
* jcowan nods
blt has joined #lisp
<jcowan> But I still wonder what the utility of the function is, especially without copying properties: it's just (make-symbol (symbol-name 'fred))
<aeth> I'd run a big usage search over ~/quicklisp/dists/quicklisp/software if you have a large amount installed and see if it shows up
<Bike> in sbcl at least, that's exactly how it's implemented
<aeth> I see it used in cells and closer-mop and mcclim and uiop
<aeth> Sorry, it's not actually used in mcclim, it's just part of a giant list called all-ansi-symbols
asarch has joined #lisp
<jcowan> aeth: Thanks. In uiop is used so that you can pass a symbol rather than a string to make-symbol variants.
<Bike> in closer mop it looks like it's doing kidn of a gensym thing
<Bike> i think i might have used it myself like that once
trafaret1 has quit [Ping timeout: 252 seconds]
<jcowan> in cells it's used in two places in the format (copy-symbol 'foo), which is just '#:foo
<jcowan> looks like the same story in closer-mop: applied to a constant symbol only
<jcowan> Can two instances of #:foo be coalesced by the compiler?
Roy_Fokker has quit [Read error: Connection reset by peer]
<Bike> nah
<Bike> they'll look the same, though, so it can get confusing
* jcowan nods.
<jcowan> So it is true then that (copy-symbol 'foo) does what '#:foo does
<Bike> wait wait, no
<Bike> maybe it can coalesce them
<Bike> "Two apparently uninterned symbols S and C are similar if their names are similar. " i guess.
jack_rabbit has joined #lisp
<aeth> Bike: is (eq '#:foo '#:foo) always NIL or is it undefined?
<Bike> undefined, apparently
<jcowan> 3.2.4.4 says "If [two literal objects] are either both symbols or both packages, they may only be coalesced if and only if they are identical."
<Bike> clhs 3.2.4.4
<specbot> Additional Constraints on Externalizable Objects: http://www.lispworks.com/reference/HyperSpec/Body/03_bdd.htm
<asarch> One stupid question: is it possible to get the very very very first Lisp there was?
<Bike> er...
<Bike> okay, that's a weird wrinkle in the definition of similarity
<Bike> nevermind then, can't coalesce theme
<asarch> How different were the first Lisp and Common Lisp?
<jcowan> asarch: Probably not: it was IBM 704 assembly language
<jcowan> There is a direct evolutionary continuity between them
<asarch> Does it still exist?
dented42 has joined #lisp
<asarch> Maybe on a museum
<jcowan> Unlikely
<jcowan> If it all, in a source code listing somewhere.
<loke> I did see someone managing to run lisp 1.5 on an emulated 704
<jcowan> Then they must have had access to the source somehow
<loke> If I remember correctly, they assembleds the binary from the source listings that are available on bitsavers
<loke> (I'm assuming it's available on bitsavers)
<jcowan> THe link above definitely does not contain full source, though it contains snippets of the Lisp-level source
<loke> jcowan: the full source is available somewhere else. I know I've sene it.
graphene has quit [Remote host closed the connection]
<asarch> Maybe in the creator's notes
graphene has joined #lisp
<asarch> I would be great an '--legacy-mode' option mode for SBCL, right?
<asarch> sbcl --legacy-mode and you could run the original Lisp code
<jcowan> http://recycledknowledge.blogspot.com/2011/11/john-mccarthy-inventor-of-lisp-died.html is a trivial translation of McCarthy's theorem prover from 1959 into Scheme
<jcowan> interestingly, it does not assume that false = (), which is also true of Scheme
<loke> jcowan: This page has a link to the full package you need to run it:
<asarch> Is (= in Common Lisp a variadic function?
<Bike> yeah
<jcowan> clhs =
<jcowan> Alas, the Lisp I wrote for early Tandem machines is lost forever
<asarch> Has anyone here worked with the original Lisp?
<loke> asarch: most of us are too young... Remember that was back in the 50's. Also, very few people did.
Oladon has joined #lisp
lemonpepper24 has joined #lisp
<loke> asarch: Also, you don' tneed a legacy mode for SBCL. You can implement it in very little Lisp code yourself. I beleve pjb did that and ran some Lisp 1.5 code in common lisp.
<jcowan> Yes, that's Wang's variant of McCarthy's prover
<jcowan> ~~ sigh ~~ So many deaths.
<asarch> Wow!
<asarch> We really will miss all that people
<asarch> So many questions
<loke> a lot of people are doign a lot of hard work preserving this stuff.
travv0 has joined #lisp
<loke> the living computer history useum for example.
<aeth> Nowhere near enough work preserving stuff. And I'm not sure things have gotten better in an era where things are continuously patched, either on the server or with daily updates
jcowan has quit [Quit: This computer has gone to sleep]
<aeth> I'm sure for some things you could see what version was used in 2011-02-12 and even have the binary stored, but even keeping the source repo(s) and rolling back to that day might not get you the same build.
gector has quit [Read error: Connection reset by peer]
gector has joined #lisp
dale has quit [Quit: dale]
<asarch> Now than I can understand Lisp, I see the code and I get disappointed. Then I get back to other languages and I get even more disappointed. Then, I get disappointed not about Lisp but about me and then I realize about its beauty. One very easy and natural way to solve problems
<asarch> Common Lisp is the language we should learn for our entire life
<asarch> When I have kids, I will teach them Lisp
<asarch> Have you teach to your kids Lisp?
rumbler31 has joined #lisp
<aeth> asarch: Imo, there's nothing in Lisp that can't be done in another language. What's rare is the combination in one language.
<asarch> Yeah
esrse has joined #lisp
rumbler31 has quit [Ping timeout: 240 seconds]
* loke has taught lisp to my kids
<loke> They understand it fine
xantoz has quit [Ping timeout: 252 seconds]
<aeth> loke: Do they write Lisp with GNU Emacs or something else?
Pixel_Outlaw has quit [Quit: Leaving]
<asarch> I think it would be great for girls, since they actually don't like to complicate things
<loke> aeth: They don't write any lisp. They learned some, and them promptly went back to doing something else.
<loke> However, I noticed that Roblox is a great game for creative people. Roblox Studio is pretty amazing.
<LdBeth> GG
<loke> Only problem is that it uses Lua as programming language.
<LdBeth> Lua is easy to get used
<LdBeth> So does JS
<LdBeth> They are just not good enough
rozenglass has quit [Remote host closed the connection]
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #lisp
marusich has joined #lisp
pierpal has quit [Client Quit]
pierpal has joined #lisp
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #lisp
arkaros has joined #lisp
doubledup has joined #lisp
doubledup has quit [Max SendQ exceeded]
doubledup has joined #lisp
travv0 has quit [Ping timeout: 240 seconds]
rnmhdn has joined #lisp
arkaros has quit [Ping timeout: 252 seconds]
doubledup has quit [Quit: Leaving]
Bike has quit [Quit: Lost terminal]
Kundry_Wag has joined #lisp
pfdietz has joined #lisp
Kundry_Wag has quit [Remote host closed the connection]
Oladon has quit [Quit: Leaving.]
ebzzry_ has joined #lisp
space_otter has joined #lisp
[X-Scale] has joined #lisp
X-Scale has quit [Ping timeout: 240 seconds]
[X-Scale] is now known as X-Scale
nowhereman_ has joined #lisp
nowhere_man has quit [Read error: Connection reset by peer]
housel has joined #lisp
housel has quit [Client Quit]
rumbler31 has joined #lisp
<gendl> "Lisp is for Girls" -- we need to steal that slogan from Python.
rumbler31 has quit [Ping timeout: 245 seconds]
<LdBeth> good evening
sauvin has joined #lisp
housel has joined #lisp
<beach> Good morning everyone!
<LdBeth> hello beach
astalla has joined #lisp
<LdBeth> okay, seem I get to know how #= works for circular list
<asarch> Lisp for everyone!
<asarch> じゃあまたね!
asarch has quit [Quit: Leaving]
frodef has joined #lisp
<LdBeth> クク
jackdaniel has joined #lisp
astalla has quit [Ping timeout: 260 seconds]
frgo has quit [Remote host closed the connection]
frgo has joined #lisp
arkaros has joined #lisp
frgo has quit [Ping timeout: 245 seconds]
arkaros has quit [Ping timeout: 250 seconds]
shka_ has joined #lisp
<shka_> good morning
Inline has quit [Quit: Leaving]
<oni-on-ion> hello
<no-defun-allowed> morning beach
igemnace has joined #lisp
<no-defun-allowed> i want to write some kind of metaobject protocol over cl-decentralise but i'm not sure how to start
<beach> Are you sure it is "meta"?
<no-defun-allowed> actually i'm not sure
<no-defun-allowed> i'd like to be able to use the system to define classes in itself which are also objects though
<beach> Ah, yes, that would be meta.
<shka_> hm
<shka_> to what end though?
<no-defun-allowed> my first thought is to write a "schema" or "class" class which is static and doesn't require any resolution or dependencies
eminhi has joined #lisp
arkaros has joined #lisp
space_otter has quit [Remote host closed the connection]
<no-defun-allowed> then i write the basic classes, "signed object", and give them instructions on how to be parsed and verified
vlatkoB has joined #lisp
<no-defun-allowed> effectively i want to teach cl-d's objects how to verify and interpret themselves
<shka_> ok, this sounds fine
SaganMan has joined #lisp
<shka_> you want to verify slots?
<shka_> methods?
<shka_> and objects as instances of classes or class objects?
<no-defun-allowed> i want to verify parts of cl-decentralise/netfarm objects
<shka_> well, i don't know this project :(
<shka_> sorry
<no-defun-allowed> these are distinct from CL objects and probably will be implemented as hashtables
<no-defun-allowed> no problem, i'm just trying to figure out how to create a MOP for netfarm
<no-defun-allowed> (although, hell, if i can write translators for nf objects into CL objects, that'd be very useful)
<shka_> this is certainly possible
<shka_> not sure if it would be a good idea, but it is possible
<eminhi> Hi, many functions which allow :test key also support :test-not. CLHS states :test-not is deprected, is there a specific reason for this?
<beach> eminhi: You can safely forget about the deprecation.
<no-defun-allowed> i think it's a good idea since i don't have a fixed plan or design for netfarm but it should be flexible
<no-defun-allowed> i figure :test (complement foo) is equivalent to :test-not if you want to live by that deprecation
<shka_> eminhi: when new standard comes out, it surely be removed! :D
<beach> eminhi: It was thought that one should use COMPLEMENT with :TEST insted.
<no-defun-allowed> REMOVE-IF-NOT was "deprecated" but no one listened
<beach> eminhi: You can safely ignore the deprecation because there will not be a new standard.
<no-defun-allowed> turns out many new languages today have R-I-N instead of REMOVE-IF which the spec writers preferred
<no-defun-allowed> they call it "filter"
arkaros has quit [Ping timeout: 244 seconds]
<eminhi> So using *-if-not functions and :test-not keyword is /in style/, rather than COMPLEMENT of :test
<beach> I use it and so do many others, so go right ahead.
<eminhi> ?
<shka_> eminhi: it doesn't matter
<eminhi> Thank You.
<no-defun-allowed> depends on the situation honestly
<shka_> :test-not is here to stay
<no-defun-allowed> if i want to find and eliminate some items from a set, R-IF looks nicest.
<shka_> it will outlive us all probabbly :P
<no-defun-allowed> if i want to keep items from a set, R-IF-NOT makes more sense
gravicappa has joined #lisp
<beach> Though, using :TEST-NOT with REMOVE-IF-NOT might not be such a good idea.
<beach> Too many negations.
<eminhi> So which ever makes code more readable .
<beach> Yeah.
<beach> Heh, (remove-if-not ... :test-not (complement ...))
<shka_> we need to go deeper
<eminhi> I have a hard time parsing, some, every, notany
<no-defun-allowed> beach: i can't disbelieve you wouldn't not consider not doing that in actual code
<jackdaniel> conceptually remove-if-not is simpler to me (but name is unfortunate - it should be FILTER) - so it picks elements matching the predicate
<no-defun-allowed> some = or, every = and, notany = nor, notevery = nand
<beach> jackdaniel: I mentally call it KEEP-IF.
<beach> FILTER is not such a great name.
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<no-defun-allowed> remove-if-not is less abstract
<beach> FILTER could mean remove or keep.
<no-defun-allowed> if you use flour or pan for gold, you might expect different things from a FILTER.
<eminhi> no-defun-allowed: That is very concise, thank you.
<no-defun-allowed> that also applies to coffee, fancy lenses, etc
<no-defun-allowed> no problem
<jackdaniel> my mind is settled on filter already, but I get your point and it is valid
dented42 has joined #lisp
<jackdaniel> (I have such abbreviation in my tools)
scymtym has quit [Ping timeout: 240 seconds]
arkaros has joined #lisp
dented42 has quit [Ping timeout: 252 seconds]
flamebeard has joined #lisp
SaganMan has quit [Ping timeout: 272 seconds]
ealfonso has joined #lisp
frgo has joined #lisp
<no-defun-allowed> i find cl has much more descriptive and verbose names for things than other languages
<no-defun-allowed> for example, destructuring-bind does what match might do in some other languages (and d-b sounds cooler too :)
<LdBeth> can I have a loop collect only if result is not nil?
frgo has quit [Ping timeout: 252 seconds]
<no-defun-allowed> (loop ... for value = ... when value collect value)
<LdBeth> Great, thank you #'no-defun-allowed
<no-defun-allowed> sci-hub doesn't have a copy of the Art of the Meta-Object Protocol which is a bit sad
<beach> That would be an illegal copy if it did.
<LdBeth> Does the book still in print?
<beach> LdBeth: You can buy it from Amazon, so I would think so.
graphene has quit [Remote host closed the connection]
<no-defun-allowed> well all of sci-hub is illegal last time i checked :^)
<beach> That doesn't make it acceptable.
graphene has joined #lisp
<no-defun-allowed> i disagree but that is probably cause we're on different sides of publishing
<no-defun-allowed> people who write books obviously should get paid but often the books are very expensive
<beach> Possibly. I am firmly convinced that laws exist so that we can live together despite different ideas. If people only respect the laws they like, that purpose will not be possible. The right way would be to change the laws, or, in this case, the way people publish books so that they are affordable.
<no-defun-allowed> i'd certainly pay if it was affordable though
<no-defun-allowed> as a student, i do appreciate that they're not "hahaha enjoy your student debt nerd" levels of expensive though, unlike some textbooks
<no-defun-allowed> $90 and you have to use their crappy online viewer which streams PNGs to your computer and is half broken? hell yeah great value for money
arkaros has quit [Ping timeout: 240 seconds]
<no-defun-allowed> i digress, but i believe the only people that expensive textbooks and resources benefit are the publishers
<shka_> scientific publishing needs to change, though
<shka_> open science luckly takes off
ggole has joined #lisp
rumbler31 has joined #lisp
<White_Flame> whatever happened to public funds implying public domain?
<White_Flame> but yeah, MOP is outside that
<White_Flame> (I think?)
xantoz has joined #lisp
rumbler31 has quit [Ping timeout: 244 seconds]
<nydel> howdy friendos
<aeth> White_Flame: what happened to that? well, SBCL resulted from that
<beach> Hello nydel.
<aeth> White_Flame: but I don't think it went away, I think there are just tons of loopholes to do things indirectly
<phoe> good morning
<beach> Hello phoe.
<phoe> Hey beach
arej has joined #lisp
<nydel> i write a function to evaluate the mathematical average of all numbers in a list added together. it's amazing how many different ways there are to do it.
<aeth> White_Flame: actually iirc (from Wikipedia/Wikimedia licensing) it's not public money => public domain, it's US federal government employee => public domain
<aeth> White_Flame: that's why there's so much NASA stuff on Wikipedia/Wikimedia
frgo has joined #lisp
SaganMan has joined #lisp
<beach> nydel: Yes, and that's the difference between "grammatical phrases" and "idiomatic phrases".
<beach> nydel: The concept exists in natural languages and in programming languages as well.
<nydel> beach: that's the exact thought i was having but i couldn't put it together! you always do that hehe.
<beach> Thanks. :)
igemnace has quit [Quit: WeeChat 2.2]
<aeth> White_Flame: I'm not quite sure how this rule got applied to SBCL (probably was pre-fork, with CMUCL) to put it into the public domain.
frgo has quit [Ping timeout: 252 seconds]
<White_Flame> was SBCL put into public domain because of something like that, or just because the forkers wanted it there?
<aeth> It looks like the original was Spice Lisp. https://en.wikipedia.org/wiki/Spice_Lisp
dented42 has joined #lisp
zfree has quit [Quit: zfree]
<aeth> So it looks like CMUCL/SBCL was initially funded by DARPA, and it looks like that history page was written in the 1993-1996 range when it was called ARPA for the 2nd time. https://en.wikipedia.org/wiki/DARPA
<nydel> beach: if you've a moment, is there anything terribly wrong with this way? https://bin.disroot.org/?176144b172fe6c0b#HQajk0WF/JIlPVJBtmkvE0P7/Gc0A7U2y7YakIi7fsk=
<nydel> i think maybe saying "let's make it recursive" was a mistake? hmmm
<no-defun-allowed> you can't guarantee you'll get away with tail recursion, even if done right
<no-defun-allowed> additionally, you can specify defaults in the lambda list
<nydel> no-defun-allowed: thank you for checking it. oh right of course, i'm doing the defaults in the cond for some reason
<nydel> i appreciate your help
<no-defun-allowed> (loop for item in list for length from 0 summing item into sum finally (return (/ sum length)))
<no-defun-allowed> the LOOP giveth, the LOOP taketh away
<beach> nydel: (/ (reduce #'+ list-of-numbers) (length list-of-numbers))
<beach> ... modulo checking for 0, converting to float, etc.
scymtym has joined #lisp
<no-defun-allowed> yes, i forgot another thing: even if you can do tail recursion, it's not worth it if you're reinventing MAP, REDUCE or the like
<nydel> wait does anything change if i set the defaults? don't i end up only instead of (null answer) in the cond instead (eq answer the-default-i-set)
<no-defun-allowed> nothing must be changed other than removing the cond clause that sets up "defaults"
<nydel> beach: thank you, that is much prettier and objectively better. i don't use #'reduce regularly so i was a bit confused trying to do it with mapping
<no-defun-allowed> if you still want to use a recursive iterative process, you could use LABELS to add an internal function which doesn't expose COUNTER too
<beach> nydel: It is never recommended to use recursion on linear lists.
<nydel> beach: would you count this definition among idioms that repulse? e.g. "ty" in english? ;)
<beach> nydel: One more thing, the typical style in Common Lisp is to use the plural form of the noun to mean a list of things, so you can use NUMBERS rather than LIST-OF-NUMBERS.
<beach> nydel: You mean your definition of AVERAGE? It is definitely a very strange way of defining it in Common Lisp.
frgo has joined #lisp
<nydel> i return to lisp hackerings after a year of family obligation so my readability/convention is a bit out of alignment. noted and will work on that.
<nydel> yes i am going for strange definitions. it seems to be helping me get back into the spirit.
<beach> nydel: As no-defun-allowed said, Common Lisp does not guarantee tail-call optimization, and the stack depth can be very limited. Recursion is fine when you have, say, a tree with a depth that is logarithmic in the number of elements.
<beach> Then the stack can't grow very much, and there is really no other choice than recursion for trees.
<jackdaniel> ftr: there is `mean` function in alexandria
<SaganMan> Morning beach
<SaganMan> I finally have all the free time to code again
eminhi has quit [Ping timeout: 250 seconds]
<no-defun-allowed> wonderful
<beach> SaganMan: Congratulations!
<beach> SaganMan: Are you looking for something to do? :)
frgo has quit [Ping timeout: 252 seconds]
<SaganMan> thanks beach, how is your research going?
<nydel> for fun this is the one i wrote right before the recursive: https://bin.disroot.org/?f8fd4643252795ce#jcpt0Rz6orIIGMNGlpcxKlqxSROwPI78TucjdmkESac=
<no-defun-allowed> beach: you can always pop and push your conses on a stack but that's very rarely needed
<beach> SaganMan: Very well thank you. I think I have enough material for 2, maybe 3 ELS submissions.
<nydel> (i know it's not named correctly but i didn't know it wasn't a function to be called by the actual one)
anewuser has joined #lisp
<no-defun-allowed> nydel: you should use DO if you're going to just mutate, it spares a few conses
<nydel> no-defun-allowed: as in do instead of collect?
<beach> nydel: (setq x (+ x y)) is better expressed as (incf x y).
<no-defun-allowed> yes, (loop ... do (mutating-thing))
<SaganMan> yes beach, I want to write program in lisp which will download comics
<beach> nydel: The entire thing can be expressed as (loop for i in list sum i)
v0|d has joined #lisp
<beach> SaganMan: I see.
<SaganMan> beach: ELS? what's that? is that like ieee?
<no-defun-allowed> european lisp symposium
<nydel> beach: oh that's great, was unaware of "sum" used like that. i still need to divide by the length if that way
<SaganMan> woah, that's cool
<beach> nydel: And you would never write it like that anyway. You would initialize ANSWER to 0 and loop over the entire list.
<SaganMan> beach: Will you be giving presentation at next lisp symposium?
<nydel> i hope this isn't a collosal waste of time for y'all, i'm learning a lot. so when i ask -- could AVERAGE be defined as a macro in an acceptable way? -- feel free to leave my curiosty unindulged
<no-defun-allowed> possibly
<jackdaniel> nydel: if its arguments are known at the compilation time - why not. otherwise just define a function and declare it inline
<no-defun-allowed> (defmacro average* (&rest foo) (#.(if (prefers-apply-p you) 'apply 'reduce) #'average foo))
<no-defun-allowed> inlining is also a good idea as jackdaniel said
<jackdaniel> also, you may define a function and call it at read time (if arguments are known by then), like #.(my-average 1 2 3)
<nydel> jackdaniel: these are part of a text adventure. an idler game where you expand a hideout to escape a forest. so the numbers are calculable for any given situation but does that count as "known" in the sense?
<nydel> that is, a function determines the numbers that will go to the average function. but it doesn't memoize at initialization or anything (yet)
<jackdaniel> nydel: if they are parameters (i.e variables passed to the function) then no
<nydel> jackdaniel: right, i see. thank you.
<beach> SaganMan: That will depend on the program committee after they examine the paper submissions. :)
<beach> nydel: The real thing to do is to define it as a function, because it doesn't require any strange evaluation rule. But then you can define a compiler macro on that function that checks whether the argument is a literal list and substitute the answer.
<beach> clhs define-compiler-macro
<nydel> that's great! & now i'm thinking more like a commonlisp user. i think freenode#lisp is the friendliest most productive/encouraging irc location.
frgo has joined #lisp
prometheus_falli has joined #lisp
frgo has quit [Ping timeout: 252 seconds]
marusich has quit [Quit: Leaving]
t0adst00l has quit [Ping timeout: 256 seconds]
nonlinear has quit [Remote host closed the connection]
nonlinear has joined #lisp
angavrilov has joined #lisp
frgo has joined #lisp
frgo has quit [Ping timeout: 244 seconds]
<LdBeth> hi nydel
jackdaniel has quit [Remote host closed the connection]
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jackdaniel has joined #lisp
ealfonso has left #lisp ["ERC (IRC client for Emacs 25.3.1)"]
orivej has joined #lisp
troydm has quit [Ping timeout: 272 seconds]
rumbler31 has joined #lisp
<russellw> I just discovered something weird. On theoretical grounds, vectors should be faster than lists, right? Well, tried a simple test just now in SBCL, find vs member, and lists are faster... by 3 orders of magnitude
<nydel> LdBeth: hello there :)
orivej has quit [Ping timeout: 240 seconds]
<nydel> LdBeth: nice to see you here. working on/playing with anything fun?
rumbler31 has quit [Ping timeout: 240 seconds]
<russellw> The above is also true of CCL. Presumably they just put much more effort into optimizing lists
kajo has quit [Quit: From my rotting body, flowers shall grow and I am in them and that is eternity. -- E. M.]
<beach> russellw: Three orders of magnitude? A factor 1000?
<russellw> beach, yes
<beach> That doesn't sound right.
kajo has joined #lisp
<beach> I think your test must be measuring something else.
troydm has joined #lisp
<nydel> russellw: would you share the test forms?
orivej has joined #lisp
<russellw> it absolutely does not sound right, to the point where I would've not believed it had I not seen the results myself, so I would definitely encourage you to try it
<russellw> (time(dotimes(i 100000000)(find 'z #(a b c d e f g h i j k l m n o p q r s t u v w x y z))))
<russellw> (time(dotimes(i 100000000)(member 'z '(a b c d e f g h i j k l m n o p q r s t u v w x y z))))
<russellw> adjust loop counts as necessary
<beach> russellw: Try using sequences of length 1000000 instead of that short.
<beach> russellw: Also, compilation time is included in your timing.
<beach> Stick those things in functions.
<beach> russellw: In SBCL with a million elements, using FIND on the list and on the vector gives indistinguishable times.
<beach> russellw: MEMBER is much faster, but not a factor 1000.
<beach> russellw: It is also likely that the compiler removes your code entirely in one case.
<russellw> beach, in practice you would use a hash table with 1000000 elements. The above is not an artificial test; it reflects a real pattern that I use somewhat frequently, which is why I was interested in the relative times. I think we both know compilation time is not going to be significant here, but I would by all means encourage you or anyone else interested, to try variants of the test and report
<russellw> the results
<russellw> the compiler does not remove the code entirely, as can be verified by trying different loop counts
<russellw> indistinguishable times with a million elements is an interesting data point; it is at least considerably closer to what one would expect
<beach> Anyway, you can not design a performance test that way. It will measure something else.
<russellw> there is no such thing as a perfect performance test, but I think the above is sufficient grounds to drop my tentative plan to start using find instead of member
<beach> With 10 million elements, find gives 0.080 seconds in one case and 0.079 in the other.
<beach> MEMBER gives 0.021 seconds, so it is 4 times as fast.
<beach> But this result only reflects the fact that MEMBER is better optimized than FIND. Not that any of the data types is "faster" than the other.
Folkol has joined #lisp
<russellw> So not as outlandish, but still interestingly different from what would expect on theoretical grounds. and if X is better optimized than Y, then X tends to end up faster than Y. That's the whole point of optimization. And was also my suggested explanation in the first place
lavaflow_ has quit [Ping timeout: 260 seconds]
<beach> russellw: No, you said that they put more effort into optimizing lists.
<beach> russellw: But in reality, they probably put more effort into optimizing MEMBER.
<ggole> Lists might show more variance in performance if you don't create them all at once
<ggole> The conses will likely be contiguous given the way you have constructed the list.
<russellw> which they clearly did, as your own results verified. the same function was the same speed on lists and vectors in the asymptotic case, which you only get if you put more optimization into lists, that by default would be slower
<beach> Whatever.
<russellw> ggole, true
longshi has joined #lisp
<no-defun-allowed> maybe there's cache coherency but that's about it for lists
dented42 has joined #lisp
<nydel> russellw: if you compose a hypothesis to mark the beginning of these tests, what is it, and is it proven? if so, have you tried to disprove it?
<russellw> nydel, my hypothesis was that vectors would be faster than lists for testing membership. That hypothesis has been comprehensively disproven
<ggole> If this operation is consuming a lot of time, you could (probably) do a lot better than switching between member and find
<ggole> eg, using binary search
<russellw> ggole, with many elements yes, or a hash table as I mentioned, but I am looking at scenarios where there would only be a handful of elements. Constant factors matter when N is small
<ggole> Binary search is good even when n is quite small
<scymtym> here, all three examples compile to the same (empty bodied) loop and take the same time to execute. this is not surprising as the compiler can fold ({member,find} 'z '(… z))
<russellw> scymtym, yeah, that doesn't surprise me. which compiler?
<scymtym> sbcl
nowhereman_ has quit [Remote host closed the connection]
<russellw> ah, setting higher optimization level?
<scymtym> no, very safe and slow
nowhereman_ has joined #lisp
<russellw> then what did you do differently? because it did not optimize away the loop body when I tried it
<scymtym> (lambda () (dotimes (i 1000000) (find 'z '(a … z)))) (disassemble *)
<scymtym> how did you check what it did/didn't optimize?
slyrus has quit [Ping timeout: 245 seconds]
<russellw> by noticing that the run time stayed proportional to the number of iterations
<russellw> I did not wrap it in a lambda, which you just did. So I was wondering if that made the difference. But I just tried your version now...
<scymtym> taking time proportional to the iteration count only means that the loop wasn't optimized away entirely. the body still could be and indeed is
<scymtym> maybe that SBCL version didn't fold FIND
<russellw> well the constant of proportionality was a lot more than an empty loop. Anyway, the disassembly I just posted, does not look to me like the loop body was optimized away. This is with a recent version of the compiler.
frodef has quit [Ping timeout: 245 seconds]
pjb has joined #lisp
<LdBeth> nydel: just finished writing assignment in JS
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
regreg_ has quit [Ping timeout: 245 seconds]
lemonpepper24 has quit [Ping timeout: 244 seconds]
longshi has quit [Quit: WeeChat 2.2]
longshi has joined #lisp
razzy has quit [Ping timeout: 245 seconds]
razzy has joined #lisp
m00natic has joined #lisp
dented42 has joined #lisp
graphene has quit [Remote host closed the connection]
cl-arthur has joined #lisp
graphene has joined #lisp
frodef has joined #lisp
dented42 has quit [Ping timeout: 260 seconds]
slyrus has joined #lisp
zfree has joined #lisp
frgo has joined #lisp
frgo has quit [Ping timeout: 245 seconds]
jmercouris has joined #lisp
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 250 seconds]
dented42 has joined #lisp
gravicappa has quit [Ping timeout: 272 seconds]
lavaflow_ has joined #lisp
lemonpepper24 has joined #lisp
emerson has quit [Quit: WeeChat 2.2]
emerson has joined #lisp
orivej has quit [Ping timeout: 252 seconds]
igemnace has joined #lisp
cl-arthur has quit [Quit: Lost terminal]
MichaelRaskin has quit [Quit: MichaelRaskin]
SenasOzys has quit [Ping timeout: 250 seconds]
pierpal has quit [Ping timeout: 260 seconds]
<shka_> keep-if
<shka_> what do you think about ONLY and WITHOUT?
<beach> Hmm.
<beach> I would prefer something like INCLUDE and EXCLUDE for symmetry. But it's moot. We have what we have.
heisig has joined #lisp
esrse has quit [Ping timeout: 252 seconds]
longshi has quit [Quit: WeeChat 2.2]
<dlowe> I like FILTER and SELECT
<beach> Well, like we said before, "filter" is ambiguous. It can mean "keep" or "reject".
<beach> You seem to use it as "reject".
<beach> ... since you have SELECT.
<beach> But other people use it as "keep", apparently.
<beach> ... some other people...
<beach> REMOVE-IF and REMOVE-IF-NOT are fine, because REMOVE means non-destructive.
<ggole> The nice thing about remove/remove-if is that the name fits beautifully for the non-function case, which is not really true of select
<dlowe> right. As unwieldy as REMOVE-IF-NOT is, it is really obvious what it does
<beach> None of the alternatives suggest that.
dddddd has joined #lisp
<ggole> And (reject 1 seq) doesn't really read like "remove one from seq" to me
<shka_> beach: in CL, yes, I have my own library
<shka_> and i did not submit into QL so i can change names
<dlowe> yeah, it's very very easy to make wrappers if you don't like the names
<shka_> it is not wrapper around CL functions
<shka_> cl standard functions
makomo has joined #lisp
<ggole> remove-if and remove-unless?
<shka_> remove-when more like
<ggole> So remove-when and remove-unless, matching the macros. Hmm.
<ggole> That does make a certain sense.
<dlowe> yeah, those are good too
<shka_> hm
<dlowe> To the time machine!
<shka_> don't try to change the past
<shka_> try to shape the future ;-)
warweasle has joined #lisp
<dlowe> impatient people still use the time machine :p
frodef has quit [Ping timeout: 260 seconds]
<warweasle> I used the time machine. The closest I could get everything back to normal ended up with Trump. Frankly, I just quit trying after that.
<warweasle> Although the trains in Nazi-controlled America are AMAZING!
<warweasle> Now we are back to volvos.
<jmercouris> warweasle: What are you talking about?
<dlowe> sorry, in this timeline we only talk about common lisp on this channel
<shka_> warweasle: thanks, my day was not going well, but this was really funny
rumbler31 has joined #lisp
LiamH has joined #lisp
dale_ has joined #lisp
dale_ is now known as dale
shrdlu68 has joined #lisp
<shrdlu68> Good afternoon
<minion> shrdlu68, memo from pjb: trees without pointers: https://pastebin.com/yreWM7NW
rumbler31 has quit [Ping timeout: 260 seconds]
jack_rabbit has quit [Ping timeout: 252 seconds]
Bike has joined #lisp
pierpal has joined #lisp
FreeBirdLjj has joined #lisp
FreeBirdLjj has quit [Ping timeout: 252 seconds]
vtomole has quit [Ping timeout: 256 seconds]
Denommus has quit [Remote host closed the connection]
vtomole has joined #lisp
<shrdlu68> minion: memo for pjb: I'll give this a try, thanks!
<minion> Remembered. I'll tell pjb when he/she/it next speaks.
asarch has joined #lisp
frgo has joined #lisp
thetemplar has joined #lisp
frgo has quit [Remote host closed the connection]
frgo has joined #lisp
makomo has quit [Ping timeout: 252 seconds]
frgo has quit [Ping timeout: 252 seconds]
varjag has quit [Quit: ERC (IRC client for Emacs 24.5.1)]
jkordani has joined #lisp
jkordani_ has quit [Ping timeout: 260 seconds]
astronavt_ has joined #lisp
astronavt has quit [Read error: Connection reset by peer]
makomo has joined #lisp
regreg_ has joined #lisp
rnmhdn has quit [Quit: WeeChat 2.2]
frodef has joined #lisp
pierpal has quit [Quit: Poof]
pierpal has joined #lisp
SaganMan has quit [Quit: WeeChat 1.6]
veinoflegaladvic is now known as veinofincubus
igemnace has quit [Remote host closed the connection]
igemnace has joined #lisp
astalla has joined #lisp
FreeBirdLjj has joined #lisp
papachan has quit [Quit: WeeChat 2.2]
cl-arthur has joined #lisp
<cl-arthur> games
<beach> ?
<cl-arthur> typo :)
rnmhdn has joined #lisp
frgo has joined #lisp
m00natic has quit [Read error: Connection reset by peer]
m00natic has joined #lisp
shrdlu68 has quit [Ping timeout: 252 seconds]
travv0 has joined #lisp
frgo has quit [Ping timeout: 272 seconds]
gravicappa has joined #lisp
frgo has joined #lisp
astronavt_ is now known as astronavt
equwal has joined #lisp
rumbler31 has joined #lisp
shka_ has quit [Quit: WeeChat 1.9.1]
quazimodo has quit [Ping timeout: 240 seconds]
rumbler31 has quit [Ping timeout: 244 seconds]
<vtomole> Hey beach, how's SICL coming along?
equwal has quit [Ping timeout: 245 seconds]
<beach> vtomole: Making steady progress. Thanks!
m00natic has quit [Ping timeout: 260 seconds]
flamebeard has quit []
<beach> vtomole: There is now a #sicl IRC channel where I can blab freely about what I am doing.
<beach> It is even logged by Shinmera's bot
<vtomole> I'll be there
zxcvz has joined #lisp
<beach> I am making very good progress on bootstrapping, and since Clasp seems to want to replace LLVM (which is very slow) by Common Lisp code generating x86-64, I am working on HIR-to-MIR which will eventually be possible to translate to x86-64.
FreeBirdLjj has quit [Remote host closed the connection]
cage_ has joined #lisp
lumm has joined #lisp
m00natic has joined #lisp
Achylles has joined #lisp
FreeBirdLjj has joined #lisp
<vtomole> beach: Replacing LLVM in Clasp seems like a huge project. Good luck to those involved! Why is it slow?
longshi has joined #lisp
<beach> Luckily, we don't have to replicate all of LLVM. Having said that, I am convinced that it would be much easier to write something like that in Common Lisp than in C++.
<beach> It is apparently slow because it is modular.
gravicappa has quit [Ping timeout: 240 seconds]
Jesin has quit [Quit: Leaving]
<beach> I often say "it is impossible to write a C++ program that is both modular and fast", and here is another data point in that direction.
<astalla> Don't you lose C/C++ interoperability though, which was the whole point of Clasp?
<beach> astalla: That's what I would have thought, but drmeister says that he can handle that.
<vtomole> C/C++ interoperability? Is CFFI not enough?
<beach> Apparently not, no.
<djeis[m]> I guess it could still make use of LLVM specifically for the C/C++ interop.
<djeis[m]> For generating the proper shims and the like.
<djeis[m]> While leaving the bulk of codegen to something faster.
<beach> I know very little about this topic. You would have to ask drmeister.
FreeBirdLjj has quit [Ping timeout: 252 seconds]
<djeis[m]> Yea
<djeis[m]> Generating code to access C++ directly is a lot more complicated than just what you can get with CFFI, because C++ is all kinds of nonsense at the ABI level.
<astalla> vtomole: as far as I know, to properly link to C++ code without second-guessing whatever compiler was used to compile it, you need a C++ parser, and C++ syntax is complex enough that a proper parser is very hard to write and basically it requires a whole C++ compiler.
<djeis[m]> Not just a C++ parser, you have to replicate the name mangling proceedure of whatever C++ compiler that lib was compiled with.
<beach> I had assumed that LLVM was a requirement for such interoperability to work, but I only recently learned that drmeister had plans to generate x86-64 code directly.
<ggole> That's always fun.
<beach> djeis[m]: And the (apparently Turing-complete template code).
<beach> djeis[m]: And the (apparently Turing-complete) template code, I mean.
<djeis[m]> I'm fairly certain that LLVM would still be needed for the interop itself, but there's no reason that codegen for the bits that don't involve interop could be done using some other compiler.
<djeis[m]> asm is asm.
<ggole> In practice there's other junk like debug data
Kundry_Wag has joined #lisp
<ggole> You can reimplement all (or some) of that, but it's a lot of work
<astalla> djeis[m]: good point.
<djeis[m]> *couldn't be done lol
<vtomole> Does Clasp compile to LLVM IR now instead of x86-64?
<beach> djeis[m]: drmeister (who is my house guest at the moment) says that all that is required is to follow the calling convention, which is fairly easy.
<beach> They do plan to generate DWARF debug information from Common Lisp code.
<beach> vtomole: Yes.
<beach> I need to go entertain my guests.
Inline has joined #lisp
<ggole> The *c++* convention? I don't think what each compiler does is even documented.
sabrac has quit [Quit: Konversation terminated!]
Kundry_Wag has quit [Read error: Connection reset by peer]
<ggole> For instance, there's a trick which clang(?) does where if every override for a virtual function returns a constant, they replace the function pointer with the relevant constant in the vtables
<ggole> If you have to reverse-engineer that sort of implementation quirk, you'll be in for quite a ride.
Inline has quit [Read error: Connection reset by peer]
Inline has joined #lisp
zfree has quit [Quit: zfree]
<djeis[m]> beach: That makes sense I suppose.
FreeBirdLjj has joined #lisp
anewuser has quit [Quit: anewuser]
Jesin has joined #lisp
shka_ has joined #lisp
travv0 has quit [Ping timeout: 272 seconds]
pierpal has quit [Ping timeout: 252 seconds]
pierpal has joined #lisp
Jesin has quit [Quit: Leaving]
Jesin has joined #lisp
pierpal has quit [Ping timeout: 240 seconds]
equwal has joined #lisp
<razzy> beach: i admire you both, drmeister and you :]
Kevslinger has joined #lisp
<razzy> warweasle: nazis just love trains :]. who could blame them :].
<razzy> soooo efficient
heisig has quit [Ping timeout: 272 seconds]
equwal has quit [Ping timeout: 245 seconds]
trittweiler has quit [Ping timeout: 252 seconds]
<shka_> good evening
asarch has quit [Remote host closed the connection]
<Shinmera> razzy: please try not to keep off-topic chatter going, especially when it's politically charged.
<russellw> what's the best way to test a variable for being equal to one of several strings? with symbols it's (member x '(a b c)) but that uses eql so doesn't work with strings
<dlowe> russellw: you can specify :test
<shka_> russellw: :test #'string=
<russellw> ah, thanks!
<shka_> or use hashtable
<Shinmera> a hash-table with standard test won't help either
<shka_> yes, that's true
<shka_> you will need also specify test for the hash table
<shka_> good catch
<razzy> Shinmera: sorry, i feel ashamed. the politics charge did not occur to me, really
<shka_> dear #lisp, i have a question
<shka_> data frame implementation i am working on, will use copy on write logic to only copy parts of data frame that are actually changed
equwal has joined #lisp
equwal has quit [Read error: Connection reset by peer]
<shka_> however, obviously, it would be beneficial to check if operation on frame actually changes it
<shka_> in order to take burden away from the user
<shka_> i was thinking on it, and it appears to me that eql would be the right way to do so
<shka_> however, there is one corner case that i see
<shka_> namely (make-symbol) and property lists of symbols
<shka_> is it worth it to create custom logic for this case, or is it better to ignore this?
<shka_> or perhaps there is other corner case, where eql would not be sufficient
astalla has quit [Ping timeout: 252 seconds]
equwal has joined #lisp
cage_ has quit [Quit: Leaving]
nowhereman_ has quit [Ping timeout: 260 seconds]
varjag has joined #lisp
FreeBirdLjj has quit [Ping timeout: 252 seconds]
Folkol has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
equwal has quit [Ping timeout: 260 seconds]
southy has joined #lisp
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 244 seconds]
khisanth_ has quit [Ping timeout: 260 seconds]
jkordani_ has joined #lisp
jkordani has quit [Ping timeout: 252 seconds]
shifty has quit [Ping timeout: 244 seconds]
flip214 has quit [Read error: Connection reset by peer]
Essadon has joined #lisp
Essadon has quit [Max SendQ exceeded]
Essadon has joined #lisp
khisanth_ has joined #lisp
travv0 has joined #lisp
flip214 has joined #lisp
ggole has quit [Quit: ggole]
shrdlu68 has joined #lisp
Jesin has quit [Quit: Leaving]
Jesin has joined #lisp
southy has quit [Ping timeout: 252 seconds]
warweasle is now known as warweasle_afk
lemonpepper24 has quit [Ping timeout: 246 seconds]
m00natic has quit [Remote host closed the connection]
nsrahmad has joined #lisp
kajo has quit [Quit: From my rotting body, flowers shall grow and I am in them and that is eternity. -- E. M.]
kajo has joined #lisp
kajo has quit [Client Quit]
nsrahmad has quit [Remote host closed the connection]
kajo has joined #lisp
flip214 has quit [Read error: Connection reset by peer]
trittweiler has joined #lisp
lemonpepper24 has joined #lisp
longshi has quit [Quit: WeeChat 2.2]
flip214 has joined #lisp
longshi has joined #lisp
makomo has quit [Ping timeout: 250 seconds]
graphene has quit [Remote host closed the connection]
graphene has joined #lisp
SaganMan has joined #lisp
southy has joined #lisp
pierpal has joined #lisp
southy has quit [Ping timeout: 260 seconds]
sauvin has quit [Read error: Connection reset by peer]
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
makomo has joined #lisp
msb has quit [Ping timeout: 252 seconds]
msb has joined #lisp
dented42 has joined #lisp
Jesin has quit [Quit: Leaving]
rnmhdn has quit [Ping timeout: 245 seconds]
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orivej has joined #lisp
Jesin has joined #lisp
ski has quit [K-Lined]
jackdaniel has quit [Ping timeout: 252 seconds]
veinofincubus is now known as veinofKoRn
rumbler31 has joined #lisp
shrdlu68 has quit [Read error: Connection reset by peer]
gravicappa has joined #lisp
thetemplar has quit [Ping timeout: 250 seconds]
ski has joined #lisp
rumbler31 has quit [Ping timeout: 252 seconds]
vlatkoB has quit [Remote host closed the connection]
warweasle_afk is now known as warweasle
nanoz has joined #lisp
astalla has joined #lisp
azimut has joined #lisp
azimut_ has quit [Ping timeout: 260 seconds]
igemnace has quit [Quit: WeeChat 2.2]
ym has quit [Quit: Leaving]
shka_ has quit [Ping timeout: 264 seconds]
meepdeew has joined #lisp
beach has quit [Ping timeout: 240 seconds]
southy has joined #lisp
warweasle has quit [Quit: next job]
longshi has quit [Quit: WeeChat 2.2]
astronavt has quit [Ping timeout: 244 seconds]
ym has joined #lisp
longshi has joined #lisp
Myon has joined #lisp
<Myon> svillemot: Hi, are you taking over cl-nibbles from dim, or should I try uploading the fixes for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908641 ?
<drmeister> Hello everyone.
<frodef> hi
<longshi> hello
<svillemot> Myon: I
<drmeister> On reflection, generating code directly from cleavir will probably require figuring out how to set up unwinding and to generate DWARF metadata.
<svillemot> Myon: I will probably do it, but not sure when, so don't hesitate to go ahead
<Myon> svillemot: the autoremoval clock is ticking, but there's a whole month left
<Myon> I'd be more comfortable if you did it because I can't judge any of the patches
<Myon> I can only see if pgloader explodes or not :)
<svillemot> ok, I'll do it
<Myon> merci
scymtym has quit [Ping timeout: 240 seconds]
zxcvz has quit [Quit: zxcvz]
Kundry_Wag has joined #lisp
Kundry_Wag has quit [Remote host closed the connection]
mutenewt has joined #lisp
SenasOzys has joined #lisp
nanoz has quit [Ping timeout: 260 seconds]
scymtym has joined #lisp
rumbler31 has joined #lisp
southy has quit [Ping timeout: 252 seconds]
rumbler31 has quit [Ping timeout: 240 seconds]
gravicappa has quit [Remote host closed the connection]
jkordani has joined #lisp
jkordani_ has quit [Ping timeout: 245 seconds]
Roy_Fokker has joined #lisp
<no-defun-allowed> Morning
<frodef> where?
<no-defun-allowed> Where is this morning?
<frodef> right :)
<Bike> ulaanbataar
<housel> In another channel I'm in (#dylan), it is always morning by convention; makes it easier to choose a greeting across time zones
rumbler31 has joined #lisp
<no-defun-allowed> Yes beach brought that up when I said he was up early.
graphene has quit [Remote host closed the connection]
graphene has joined #lisp
jmercouris has quit [Remote host closed the connection]
<frodef> what
<frodef> 's the idiom for exchanging the value of two variables again?
<_death> (rotatef a b)
<frodef> thanks
southy has joined #lisp
<Achylles> (mapcar (two-x 2 3) '(1 2 3 4)) --> *** Eval error *** Invalid function: 6
<Achylles> why it gives me this error?
<Bike> what's two-x?
cl-arthur has quit [Quit: Lost terminal]
<Achylles> (two-x) --> is a function (* x y)
<Achylles> multiplies 2 numbers
<Bike> so (two-x 2 3) evaluates to 6?
<Achylles> yes
<Bike> so...
<Bike> what did you expect the mapcar to do, exactly?
<Bike> You're basically doing (mapcar 6 '(1 2 3 4))
southy has quit [Ping timeout: 252 seconds]
<Achylles> how do I apply --> (* 6 (1 2 3 4) --> to each list element?
<Bike> Pass a function that multiplies a number by 6
<Bike> such as (lambda (x) (* x 6))
dented42 has joined #lisp
Josh_2 has quit [Quit: ERC (IRC client for Emacs 26.1)]
lumm has quit [Quit: lumm]
Bike has quit [Ping timeout: 256 seconds]
d4ryus has quit [Ping timeout: 245 seconds]
d4ryus has joined #lisp
<oni-on-ion> Achylles: (apply #'* '(1 2 3 4)) ;; ? =)
frodef has quit [Ping timeout: 240 seconds]
<oni-on-ion> i think you are looking for 'currying', looking at your example above
<oni-on-ion> so that (two-x 2 3) becomes a new function with 2 and 3 already passed
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
frodef has joined #lisp
Inline has quit [Quit: Leaving]
<White_Flame> (defun make-multiplier (x y) (let ((scale (* x y))) (lambda (in) (* in scale)))
<White_Flame> (mapcar (make-multiplier 2 3) '(1 2 3 4))
<White_Flame> that performs the *2 3 only once, and multiplies that result over the list
<White_Flame> note that make-multiplier returns a lambda, which is used in the mapcar
<oni-on-ion> julia -- [1 2 3 4] .* 4 => 1x4 Array{Int64,2}: [4 8 12 18]
<aeth> alexandria has both curry and rcurry. (mapcar (alexandria:curry #'* 2 3) '(1 2 3))
<aeth> It is essentially a general and more efficient version of what White_Flame is doing.
<aeth> It is probably not optimized to the degree that it could be.
<oni-on-ion> hmm.
<oni-on-ion> julia magically arranges static code paths, looking for the disasm now
<aeth> What I mean about not optimized is that given a sufficiently smart compiler both (defun foo () (mapcar (alexandria:curry #'* 2 3) '(1 2 3))) and (defun foo () (quote #.(mapcar (alexandria:curry #'* 2 3) '(1 2 3)))) would be compiled to constantly return '(6 12 18) but that's clearly not the case, at least in SBCL.
<aeth> (well, actually it should return (list 6 12 18) in the former case. Slightly different in that modifying the quoted version is undefined and could have unexpected behavior)
<oni-on-ion> i did disasm (mapcar (lambda (x) (* x 8)) '(1 2 3 4)) its only a page, that julia was about 4-5 pages....
<LdBeth> map (2 * 3 *) [1..6]
<oni-on-ion> heh
<oni-on-ion> aeth what is #.
<aeth> oni-on-ion: doing it at reader time, since it's constant data
<oni-on-ion> "#."
<oni-on-ion> ohh. didnt know about that =)
<aeth> I then have to quote it because it tries to evaluate (6 12 18) as a function with two arguments and the name 6
<aeth> (at least in SBCL)
<oni-on-ion> so ur telling me that lisp is the perfect balance and harmony between man and machine
<aeth> oni-on-ion: No, I'm saying that even here Lisp is incorrect because given entirely constant data, a sufficiently optimizing compiler will compile it to a constant return value, without needing a hack like evaluating that at read time
<aeth> s/here Lisp/here SBCL/
<LdBeth> compiler should do that kind of jobs
<oni-on-ion> room for improvement on the implementation side, minor details =)
<aeth> In fact, I wouldn't be surprised if the equivalent multiplication in LOOP on the quoted list *does* return a constant
<aeth> #(1 2 3) and '(1 2 3) are hints to the compiler to make magic happen :-p
<oni-on-ion> hmm still a lot of code. 'thread.alloc-region' eh
<oni-on-ion> #() is vector right ?
<aeth> well, literal vector
<oni-on-ion> yeah =) [] in elisp
southy has joined #lisp
<aeth> are you disassembling the reader version in SBCL? for me it returns '(6 12 18) in 23 bytes
<oni-on-ion> just that above with the mapcap and lambda
<oni-on-ion> 274 bytes eheh
LiamH has quit [Quit: Leaving.]
<aeth> You probably did something that destroyed the constantness of the data, then
<oni-on-ion> how DARE you! nah i just typed in that :
<oni-on-ion> (disassemble (lambda () (mapcar (lambda (x) (* x 8)) '(1 2 3 4))))
<oni-on-ion> might not have needed the extra thing there..
<aeth> oh, no that's right
<aeth> I thought you were disassembling the #. version
<oni-on-ion> hjehe Can't make a compiled function from (8 16 24 32)
<oni-on-ion> [Condition of type SIMPLE-TYPE-ERROR]
regreg_ has quit [Ping timeout: 252 seconds]
<oni-on-ion> ah
<aeth> oni-on-ion: (disassemble (lambda () (quote #.(mapcar (lambda (x) (* x 8)) '(1 2 3 4)))))
<oni-on-ion> hm yeah 23
<aeth> #. is the only way I know how to do this without defining a macro first.
* oni-on-ion studies it
<aeth> I wouldn't use that in production
<aeth> If you have to do something like that ahead of time use a macro, it's clearer
<aeth> and more general
<oni-on-ion> so its just #. inline the result -> quote put it back to list -> yay
southy has quit [Ping timeout: 240 seconds]
<oni-on-ion> ?
<oni-on-ion> for one-off things it is good to know all the tools in the shed
<aeth> oni-on-ion: this won't be as concise as the reader version because I'm using LIST instead of QUOTE: (defmacro times-eight (list-of-numbers) `(list ,@(mapcar (lambda (x) (* x 8)) list-of-numbers)))
<aeth> but then (times-eight (1 2 3 4)) => (8 16 24 32)
<aeth> e.g. (disassemble (lambda () (times-eight (1 2 3 4))))
<oni-on-ion> oh. right, but!
<oni-on-ion> why not (disassemble (lambda () `(list ,@ ..... ?
<aeth> You can get the same thing with (defmacro times-eight* (list-of-numbers) `(quote ,(mapcar (lambda (x) (* x 8)) list-of-numbers)))
<aeth> (the same thing as the reader version)
<oni-on-ion> 341 bytes...
<aeth> oni-on-ion: for me that's done at runtime
<aeth> the macro will be done at macro expansion time
varjag has quit [Ping timeout: 252 seconds]
<oni-on-ion> ok.. so macro expansion counts in the disasm ?
<aeth> The *disadvantage* of the macro approach is that even though it's more general than the reader approach, it still won't always give you want you want.
<oni-on-ion> 349 bytes with list instead of quote o_O
<aeth> e.g. a list of (1 2 (* 2 2) 4) will fail. If you wanted to be totally general, you'd have to walk through, see if something is a number, if it's a number apply the multiplication, and if it's not a number, make sure the multiplication is attempted at run time.
* oni-on-ion veers into icebergs
<aeth> oni-on-ion: Putting the ` and ,@ in the lambda itself is doing the operation at run time each time the function is called, even though your data is constant
<aeth> oni-on-ion: The ` and ,@ in the macro will do the computation once, when compiling it.
<oni-on-ion> i think im just attacking code translation. reason i mentioned balance and harmony earlier, getting to it..
<oni-on-ion> aeth: oh! i didnt know that. when to get macros eval'd at compile? eval-when obviously then ?
<oni-on-ion> for some reason i didnt lose any marbles by assuming ` and @ were compile time or even just eval time.
<oni-on-ion> or because its in a lambda
<oni-on-ion> and. so oh nevermind you answered it. because its not in a macro ?
<aeth> oni-on-ion: this is the full version you want, btw. (defmacro times-eight (list-of-numbers) `(list ,@(mapcar (lambda (x) (if (numberp x) (* x 8) `(* ,x 8))) list-of-numbers)))
<oni-on-ion> wouldnt if numberp add more code though ?
<aeth> oni-on-ion: If it's a number at macro-expansion time (i.e. a literal number like 42) it will do the multiplication then. If it's not a number (e.g. the list (* 3 4)), then it will attempt to do the multiplication at run time
<aeth> oni-on-ion: So it only adds more code if it's not a literal number
<oni-on-ion> ohh. duh. thx for clearing up my synapse pathways
<aeth> (times-eight (1 2 3 4 (* 3 4))) => (8 16 24 32 96)
<oni-on-ion> right, when its more general, as you say =)
<aeth> the macro is essentially taking in '(1 2 3 4 (* 3 4)) and returning '(list 8 16 24 32 (* (* 3 4) 8))
<oni-on-ion> =O
<oni-on-ion> didnt notice that other list in there
<aeth> and it will even work with variables. (macroexpand-1 `(times-eight (1 2 3 4 foo))) => (LIST 8 16 24 32 (* FOO 8))
groovy2shoes has quit [Ping timeout: 240 seconds]
<oni-on-ion> hmmm =) awrsome!
outtabwz has joined #lisp
<aeth> (disassemble (defun foo () (times-eight (1 2 3 4 foo))))
<aeth> Now there still is a generic-* but it's only applied once, to the variable foo, instead of on every item, which are mostly constant. We turned the naive map into the most efficient thing we can do.
outtabwz has left #lisp [#lisp]
rumbler31 has quit [Remote host closed the connection]
astalla has quit [Ping timeout: 272 seconds]
groovy2shoes has joined #lisp
<oni-on-ion> yeah =) =) hm!
Achylles has quit [Ping timeout: 252 seconds]
astronavt has joined #lisp
quazimodo has joined #lisp
<aeth> oni-on-ion: the only catch is that we're not really working on a list. (1 2 3 4 foo) is syntax. (times-eight foo) won't work because it will see the symbol foo instead of a list there, at macro-expansion time.
dented42 has joined #lisp
<aeth> Because that's misleading we can express the macro like this: (defmacro times-eight (&rest list-of-numbers) `(list ,@(mapcar (lambda (x) (if (numberp x) (* x 8) `(* ,x 8))) list-of-numbers)))
<aeth> And then we get this API: (times-eight 1 2 3 4 (* 5 4)) => (8 16 24 32 160)
<aeth> Alternatively, we could attempt to parse the argument in the macro and have a slow version for when it's not what we want. Then we could have (times-eight (list 1 2 3 4)) as the API, and for everything that's not a list that begins with LIST we can provide the slow, runtime route.
* oni-on-ion contemplates it
<aeth> This would be the implementation: (defmacro times-eight* (list) (if (and (listp list) (eql (car (list)) list)) `(list ,@(mapcar (lambda (x) (if (numberp x) (* x 8) `(* ,x 8))) list)) `(mapcar (lambda (x) (* x 8)) ,list)))
<aeth> looks messier than it actually is because I put it on one line for IRC
<aeth> It would get a bit messier if you wanted to also support '(1 2 3) lists
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<aeth> But essentially the idea is that if the list is known at compile time, handle it in an optimal way. If it's unknown, just do the mapcar like you would have done.
Kundry_Wag has joined #lisp
frodef has quit [Ping timeout: 252 seconds]
<oni-on-ion> right =) i will get used to swapping between compile and run time , glad the syntax is super small for it
<aeth> And the final step would be to replace (* x 8) with a function. This gets messy.
<oni-on-ion> there is a macrolet ?
Kundry_Wag has quit [Ping timeout: 252 seconds]
makomo has quit [Ping timeout: 252 seconds]
anewuser has joined #lisp
Pixel_Outlaw has joined #lisp
angavrilov has quit [Remote host closed the connection]
<jasom> isn't (car (list)) always nil?
<White_Flame> yeah, probably wanted to be (car list)
<jasom> clhs define-compiler-macro
<jasom> also consider that for when you might want to behave as a function or a macro depending on your arguments.
Kundry_Wag has joined #lisp
<jasom> also IIRC compiler-macros may be expanded when used in funcall
Kundry_Wag has quit [Read error: Connection reset by peer]
<aeth> jasom: absolutely right, that's the problem with a lisp-2 :-p
<aeth> jasom: You can use "list" everywhere but you still might accidentally use the wrong list
<aeth> I also needed to quote 'list
<aeth> This is the correct version: (defmacro times-eight* (list) (if (and (listp list) (eql (car list) 'list)) `(list ,@(mapcar (lambda (x) (if (numberp x) (* x 8) `(* ,x 8))) (cdr list))) `(mapcar (lambda (x) (* x 8)) ,list)))
<aeth> too much list to not be confusing :-p
<aeth> It's already getting very messy and this is before generalizing (* x 8)
Kundry_Wag has joined #lisp
Kundry_Wag has quit [Remote host closed the connection]
Kundry_Wag has joined #lisp
grault has joined #lisp
grault has left #lisp [#lisp]
longshi has quit [Ping timeout: 264 seconds]
graphene has quit [Remote host closed the connection]
quazimodo has quit [Ping timeout: 252 seconds]
graphene has joined #lisp
quazimodo has joined #lisp
graphene has quit [Remote host closed the connection]
pierpal has quit [Ping timeout: 245 seconds]
graphene has joined #lisp
dale has quit [Quit: dale]
Achylles has joined #lisp
Pixel_Outlaw has quit [Quit: Leaving]
sjl has quit [Quit: WeeChat 2.2-dev]
regreg_ has joined #lisp