libera/#commonlisp - IRC Chatlog
Search
13:56:14
hayley
With only one machine, it is perfectly fine to use mere threads, which share an address space, and thus you can literally just give a thread the object in question.
13:57:38
nij-
I see, phoe, and one working implementation is swank-crew right? I will look into it :)
13:58:39
hayley
If the work is trivial to parallelize, then I would look into lparallel and toy with PMAP, PREDUCE, PREMOVE-IF-NOT, etc. If not, then you might want to brush up on parallelism before anything.
13:59:14
nij-
Back to compiler. beach, do you recommend noobs like me to start with understanding how C codes are compiled into assembly? Or can I just try to understand how it's done for CL? I have much more patient for CL than for C.
13:59:25
hayley
Maybe I should write another chess AI some day. My first and last one nearly worked, but I messed up the negamax thing and it ended up playing the worst move half the time.
14:00:38
phoe
nij-: yes, swank-crew builds over swank-client which is an implementation of swank protocol in CL.
14:02:48
beach
nij-: OK, there are (at least) two aspects to a compiler. One is translating the source language to intermediate form. The other is optimizing the intermediate form.
14:03:59
hayley
Seriously, I remember messing with threading in...2018 while I was waiting for a meeting to pick classes for my final year at high school.
14:04:25
beach
nij-: And, as phoe points out, for the points about OR and LET, the second part is more interesting.
14:04:31
phoe
stuff like narrowing variable lifetimes, figuring out constants, eliminating dead code, etc..
14:06:33
beach
nij-: That book is a good overview of techniques, and the general descriptions are good. But if you ever want to write a compiler, whatever you do, don't base it on his code.
14:08:26
beach
nij-: All books assume a simple source language like C without closures and stuff, so languages like Common Lisp complicate stuff, but you still get the general idea from his book.
14:08:44
hayley
nij-: I think that the parts an application programmer needs to know about are relatively language independent, at least if you have a reasonable language. Otherwise hell no.
14:09:56
beach
shka: I am talking about his data structures. They are all arrays indexed by integers.
14:11:17
shka
it honestly astonish me that anybody would try to teach anything non-numeric with Fortran of all things
14:11:20
hayley
Well, to some extent, you do also have different intermediate languages and representations (words you don't need to care about: SSA, CPS, ANF, basic blocks, sea of nodes...) but I guess the optimisations are invariant still.
14:13:18
_death
the fortran style has its own advantages sometimes, though in Lisp we tend to use (maybe overuse) the pointers approach a lot.. you can read about it in http://www.the-adam.com/adam/rantrave/st02.pdf
14:13:46
hayley
nij-: I would guess a book would not cover the specific IR of some real compiler, so you are welcome to imagine your own IR to think about optimisations with.
14:14:36
shka
beach: i would not dare say such thing, i mean he somehow became very well acquainted with compilers
14:15:29
beach
But then, I hear there are people using languages such as C++ to write compiler frameworks such as LLVM. That's weird too.
14:17:50
shka
yeah, C++ is not the best choice, but again given the selection of the mainstream languages and corporate politics it is understandable
14:18:33
shka
you wanna automatic management? C# or java, both of which are very much connected to MS and Oracle respectively.
14:19:27
beach
Like I often say, people go to a lot of trouble, and waste a lot of time and energy, to avoid learning Common Lisp.
14:21:06
hayley
According to Wikipedia, LLVM originated as a project to investigate dynamic compilation techniques. With the exception of KleinVM for Self, I don't think there were any "just in time" compilers not written in C++ at the time.
14:23:24
pl
I think Python would count too, even if arguably it uses older logical framework than LLVM
14:24:08
hayley
Ironically now it seems LLVM is too slow to use for a JIT, with the exception of optimizing the hottest loops.
14:25:55
hayley
shka: What I mean is that metacircular dynamic compilers were mostly non existent. But as pl said, Python the compiler did exist then.
14:27:16
beach
hayley: I have been wondering whether the slowness of LLVM is due to this phenomenon that I often cite, namely that it is impossible to write a C++ program that is both fast and modular.
14:27:23
scymtym
beach: Aaron Hsu's thesis has a more well-founded position on avoiding pointers in compilers than "only knowing fortran": https://scholarworks.iu.edu/dspace/handle/2022/24749 . i'm not sure whether it contains his statement about pointers being "the refined sugar of programming", though
14:27:48
beach
I mean, I can't imagine that the LLVM people attempted to write a monolithic program of that size.
14:29:43
beach
hayley: But I haven't studied the LLVM code to see whether they make heavy use of things like smart pointers and/or reference counting.
14:30:04
scymtym
beach: very likely true. i was pointing out (ha) other possible reasons for wanting to avoid pointers
14:32:03
beach
... smart pointers, reference counting, or perhaps just a lot of copying to keep the reference count to 1 or 0.
14:36:24
hayley
I don't know what the LLVM developers do, but I watched a presentation on the Java C2 compiler, in which Cliff said he did a lot of hash consing in order to keep everything in cache.
14:37:42
hayley
And in the context of a compiler, you could be slack and use an arena allocator, assuming no IR or other temporary data outlives compilation.
14:46:59
hayley
So garbage collection could be somewhat better on the cache, provided that there are temporary objects which die.
14:47:37
beach
So it's an unwanted source of the same kinds of bugs that manual memory management has. Right?
14:47:55
hayley
But if the compiler doesn't run for long, and nothing outlives compilation, the programmer can be lazy and remove the arena at the end of compilation.
14:50:48
hayley
Still, you could achieve much better locality of reference if there is any garbage produced. And for sufficiently large compilation units, the memory usage would become a problem, so I doubt that LLVM solely uses arenas.
14:51:48
hayley
ACTION imagines this isn't far off how an explicit memory management fan would talk about a program with a GC.
14:54:31
hayley
If there were cleanly separated passes, you could have separate allocators for each pass.
14:56:31
beach
I am always in favor of general-purpose techniques rather than special-purpose ones. So it seems to me work should be put into a good tracing GC.
14:58:37
hayley
shka: w.r.t the cache, I think the example of hash consing was for type inference. As that compiler also does something like Kildall's algorithm, it also makes a fair few intermediate types, and getting that done with quickly would be good.
15:20:14
nij-
Ah - the link to the internal manual for sbcl in this site is down - http://www.sbcl.org/manual/#Internals-Documentation
15:21:53
nij-
Btw, as wscl is going on - can we expect a program that checks if an implementation satisfies spec wscl?
19:16:04
mfiano
99999999999999999999999999999999999999999999999999999-098iu77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:06
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:08
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:10
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:12
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:14
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:16
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:18
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:20
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:22
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:24
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:26
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:28
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:30
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:32
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:34
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:36
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:38
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:40
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:42
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:44
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:46
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:48
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:50
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:52
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:54
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:56
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:16:58
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:17:00
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:17:02
mfiano
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
19:17:04
mfiano
77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777788888888888888888888888888888888788888888888666666666666666666666666666666666666
20:21:27
Josh_2
if I have a list with 100 different elements, each element has a slot whose value is a colour like orange, green, blue, is there a quick way I can sort them into individual lists by that colour?
20:24:24
lisp123
Josh_2: So to understand correctly, you have a list, say (A B C D E F G), and you want to split it into (A B) (D F) (E) (G) where each of the sublists are of a certain color?
20:25:18
Josh_2
sometimes there are sneaky ways you can do this in CL without realizing, no point reinventing the wheel
20:26:04
lisp123
http://www.lispworks.com/documentation/HyperSpec/Body/f_mem_m.htm - then use a lambda function to test for equality
20:28:35
phoe
(serapeum:partitions (list (lambda (x) (= 0 (mod x 3))) (lambda (x) (= 1 (mod x 3))) (lambda (x) (= 2 (mod x 3)))) '(1 2 3 4 5 6 7 8 9))
20:31:10
lisp123
https://stackoverflow.com/questions/36634561/common-lisp-idiom-for-filtering-a-list-and-applying-a-function-to-the-unfiltered
20:31:13
phoe
something that can turn '(:green :red :blue) into a list of lambdas that check if the color of an object is :green, :red, :blue
20:31:47
pjb
phoe: (com.informatimago.common-lisp.cesarum.list:equivalence-classes '(1 2 3 4 5 6 7 8 9) :key (lambda (n) (mod n 3))) #| --> ((9 6 3) (8 5 2) (7 4 1)) |#
20:32:43
lisp123
Bike: (which is probably likely) - I guess then the trick would be to CDR through the list and push to a hash table for that color?
20:34:04
lisp123
Josh_2: see above, loop through the items, and push each object onto a hash table with that color as a key (appending to the list for each color as you go on)
20:34:46
Bike
https://github.com/informatimago/lisp/blob/master/common-lisp/cesarum/list.lisp#L651-L665 which is more or less how pjb's function works.
20:34:58
pjb
(defmacro generate-keyword-predicates (&rest keywords) `(progn ,@(mapcar (lambda (keyword) `(defun ,(intern (concatenate 'string (string keyword) "P")) (object) (eql object ',keyword))) keywords))) (macroexpand-1 '(generate-keyword-predicates :red :green :blue)) #| --> (progn (defun redp (object) (eql object ':red)) (defun greenp (object) (eql object ':green)) (defun bluep (object) (eql object ':blue))) ; t |#
20:35:30
pjb
Josh_2: if the colors are not known at compilation-time, then you don't want to generate functions for each of them.
20:35:50
Bike
"the automatic creation of new arrays and hashes as required every time an undefined value is dereferenced" eck
20:35:56
pjb
Josh_2: no code compiled can know what those function names would be if the color keywords are only known at run-time.
20:43:52
zephyr
i'll throw in https://plaster.tymoon.eu/view/2586#2586, looks similar to other suggestions
21:37:56
Bike
sm2n: i just loaded introspect-environment on sbcl 2.1.7 and don't see any errors. there is a compiler note but i am pretty sure it is harmless.