freenode/lisp - IRC Chatlog
Search
22:54:29
aeth
_death: Right, one collection of bits for one thing, use an integer. One bit for a sequence of things, use a bitvector and iterate both sequences simultaneously in one LOOP/DO/etc.
22:55:23
aeth
You can even get sophisticated and have a 2D array, where the first part of the AREF is the same as the AREF for the bitvector
23:06:50
edgar-rft
summary so far: bit-vectors are useful to distinguish fixnums (number family) from semaphores (boolean family), everything else so far I consider as "esoteric use-cases", any disagreements? :-)
23:08:08
phoe
bit vectors have constant performance characteristics whereas integers don't when they evolve into bignums
23:09:11
fwoaroof[m]
because that means that bit-vectors can also be used with non-fixed-length sequences of bits
23:10:05
aeth
edgar-rft: In C, everything's a sequence of bits, in CL, the underlying hardware is unspecified. This makes CL closer to the underlying hardware, because floats are iirc stored in special registers as a separate thing and treating them as just bits like C treats them is inefficient and probably requires a conversion.
23:12:56
aeth
fwoaroof[m]: I'd say being able to use them in MAP is more useful. That is, going back to the earlier struct... (defstruct foo (foos (make-array 30000 :element-type 'single-float :initial-element 0f0) :type (simple-array single-float (30000))) (active? (make-array 30000 :element-type 'bit :initial-element 0) :type (simple-array bit (30000))))
23:13:01
aeth
you can do this: (let ((foo (make-foo))) (map nil (lambda (foo active?) (unless (zerop active?) (format t "~A~%" foo))) (foo-foos foo) (foo-active? foo)))
23:13:37
aeth
You can't do that by manually creating your own bitvectors out of fixnums whose indices don't match the other sequence's indices
23:14:45
aeth
I could definitely see myself doing something like this if I could remember that such a thing can be done, but odds are I'd forget and write a messy LOOP instead
23:15:49
aeth
You could even map-into the foos array based on what the bit-vector tells you to do, although you might want to reorder things, so at that point the built in higher order functions might not be that useful
23:17:56
aeth
You could also make that an octet vector and assign a meaning to each bit and get really fancy and low-level-ish.
23:21:41
aeth
You could go much further if there were a lot of buildings for working with multidimensional arrays since 2D array rows gives you so much more here.
23:24:27
phoe
I would like living in a CL building because then I could just leave trash anywhere in my flat and then it would get automatically collected
23:27:42
edgar-rft
Thank you all, I think I have really learned something! And you can be proud ouf yourselves because makinge edgar learn something is a really remarkable achievement.
3:51:54
aeth
Speaking of CL buildings, "edifice" would be a great name for a text editor. It's probably already in use as a name, though.
4:10:02
edgar-rft
it doesn't even matter what words mean at all because I'm using them like *I* want
5:41:13
fe[nl]ix
beach: Google does semantic search nowadays, so try searching for "edifice software"