freenode/#lisp - IRC Chatlog
Search
6:44:31
no-defun-allowed
i find cl has much more descriptive and verbose names for things than other languages
6:44:46
no-defun-allowed
for example, destructuring-bind does what match might do in some other languages (and d-b sounds cooler too :)
6:48:25
no-defun-allowed
sci-hub doesn't have a copy of the Art of the Meta-Object Protocol which is a bit sad
6:52:16
no-defun-allowed
i disagree but that is probably cause we're on different sides of publishing
6:53:33
no-defun-allowed
people who write books obviously should get paid but often the books are very expensive
6:53:49
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.
6:55:21
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
6:56:26
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
6:58:19
no-defun-allowed
i digress, but i believe the only people that expensive textbooks and resources benefit are the publishers
7:18:17
aeth
White_Flame: but I don't think it went away, I think there are just tons of loopholes to do things indirectly
7:23:49
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.
7:23:49
aeth
White_Flame: actually iirc (from Wikipedia/Wikimedia licensing) it's not public money => public domain, it's US federal government employee => public domain
7:24:39
beach
nydel: Yes, and that's the difference between "grammatical phrases" and "idiomatic phrases".
7:25:03
aeth
White_Flame: https://en.wikipedia.org/wiki/Copyright_status_of_work_by_the_U.S._government
7:25:08
nydel
beach: that's the exact thought i was having but i couldn't put it together! you always do that hehe.
7:27:52
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.
7:28:30
White_Flame
was SBCL put into public domain because of something like that, or just because the forkers wanted it there?
7:34:30
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
7:34:56
nydel
beach: if you've a moment, is there anything terribly wrong with this way? https://bin.disroot.org/?176144b172fe6c0b#HQajk0WF/JIlPVJBtmkvE0P7/Gc0A7U2y7YakIi7fsk=
7:35:48
no-defun-allowed
you can't guarantee you'll get away with tail recursion, even if done right
7:36:37
nydel
no-defun-allowed: thank you for checking it. oh right of course, i'm doing the defaults in the cond for some reason
7:36:59
no-defun-allowed
(loop for item in list for length from 0 summing item into sum finally (return (/ sum length)))
7:38:55
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
7:38:56
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)
7:39:36
no-defun-allowed
nothing must be changed other than removing the cond clause that sets up "defaults"
7:40:13
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
7:40:26
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
7:41:55
nydel
beach: would you count this definition among idioms that repulse? e.g. "ty" in english? ;)
7:41:56
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.
7:42:37
beach
nydel: You mean your definition of AVERAGE? It is definitely a very strange way of defining it in Common Lisp.
7:44:50
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.
7:45:10
nydel
yes i am going for strange definitions. it seems to be helping me get back into the spirit.
7:45:15
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.
7:45:38
beach
Then the stack can't grow very much, and there is really no other choice than recursion for trees.
7:49:24
nydel
for fun this is the one i wrote right before the recursive: https://bin.disroot.org/?f8fd4643252795ce#jcpt0Rz6orIIGMNGlpcxKlqxSROwPI78TucjdmkESac=
7:49:44
no-defun-allowed
beach: you can always pop and push your conses on a stack but that's very rarely needed
7:49:52
beach
SaganMan: Very well thank you. I think I have enough material for 2, maybe 3 ELS submissions.
7:49:54
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)
7:50:19
no-defun-allowed
nydel: you should use DO if you're going to just mutate, it spares a few conses
7:52:32
nydel
beach: oh that's great, was unaware of "sum" used like that. i still need to divide by the length if that way
7:53:09
beach
nydel: And you would never write it like that anyway. You would initialize ANSWER to 0 and loop over the entire list.
7:54:52
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
7:56:29
jackdaniel
nydel: if its arguments are known at the compilation time - why not. otherwise just define a function and declare it inline
7:56:43
no-defun-allowed
(defmacro average* (&rest foo) (#.(if (prefers-apply-p you) 'apply 'reduce) #'average foo))
7:57:13
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)
7:58:28
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?
7:59:13
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)
8:00:24
beach
SaganMan: That will depend on the program committee after they examine the paper submissions. :)
8:02:01
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.
8:04:21
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.
9:08:56
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
9:19:43
russellw
The above is also true of CCL. Presumably they just put much more effort into optimizing lists
9:22:08
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
9:22:11
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))))
9:22:31
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))))
9:25:23
beach
russellw: In SBCL with a million elements, using FIND on the list and on the vector gives indistinguishable times.
9:26:07
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
9:26:23
russellw
the compiler does not remove the code entirely, as can be verified by trying different loop counts
9:27:00
russellw
indistinguishable times with a million elements is an interesting data point; it is at least considerably closer to what one would expect
9:27:07
beach
Anyway, you can not design a performance test that way. It will measure something else.
9:28:27
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
9:28:30
beach
With 10 million elements, find gives 0.080 seconds in one case and 0.079 in the other.
9:29:37
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.
9:31:00
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
9:33:15
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
9:36:52
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?
9:38:07
russellw
nydel, my hypothesis was that vectors would be faster than lists for testing membership. That hypothesis has been comprehensively disproven
9:40:13
ggole
If this operation is consuming a lot of time, you could (probably) do a lot better than switching between member and find
9:41:38
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
9:42:38
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))
9:44:53
russellw
then what did you do differently? because it did not optimize away the loop body when I tried it
9:47:42
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...
9:48:56
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
9:49:59
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.
12:43:44
beach
I would prefer something like INCLUDE and EXCLUDE for symmetry. But it's moot. We have what we have.
12:50:50
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
13:05:21
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.
15:21:45
beach
vtomole: There is now a #sicl IRC channel where I can blab freely about what I am doing.
15:23:20
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.
15:28:44
vtomole
beach: Replacing LLVM in Clasp seems like a huge project. Good luck to those involved! Why is it slow?
15:29:28
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++.
15:30:16
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.
15:30:46
beach
astalla: That's what I would have thought, but drmeister says that he can handle that.
15:34:39
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.
15:35:17
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.
15:36:34
djeis[m]
Not just a C++ parser, you have to replicate the name mangling proceedure of whatever C++ compiler that lib was compiled with.
15:36:46
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.
15:38:11
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.
15:48:01
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.
15:54:32
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
15:55:07
ggole
If you have to reverse-engineer that sort of implementation quirk, you'll be in for quite a ride.
16:39:33
Shinmera
razzy: please try not to keep off-topic chatter going, especially when it's politically charged.
16:40:13
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
16:42:54
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
16:43:40
shka_
however, obviously, it would be beneficial to check if operation on frame actually changes it