libera/#commonlisp - IRC Chatlog
Search
15:50:17
trev
would someone mind explaining how this works in plain english? https://github.com/google/lisp-koans/blob/master/koans-solved/mapcar-and-reduce.lisp#L58
15:54:46
Josh_2
(apply #'mapcar #'list '((a b c) (d e f))) -> (mapcar (lambda (x y) (list x y)) '(a b c) (d e f)). Something like that
15:57:07
Josh_2
(apply #'mapcar #'list '((a b c) (d e f)(g h i))) -> (mapcar (lambda (x y z) (list z y z)) '(a b c) '(d e f) '(g h i))
16:00:11
easye`
<https://github.com/armedbear/abcl/pull/490/files#diff-ccaa655ebf1432951ff70b34dcd6e82428cba2c5035e8077c7b183a6551bba3dR98>
16:14:40
Bike
trev: say you have lists = ((1 2) (3 4)). then (apply #'mapcar #'list lists) = (mapcar #'list '(1 2) '(3 4))
16:24:56
mfiano
trev: It does a matrix transposition. It converts rows to columns and columns to rows.
16:28:09
mfiano
Yes, now try playing with it using lists of different lengths and see if you can understand what is happening.
16:29:19
trev
i ended up reading the docs after asking (wrong of me) and that also helped me create a mental image of how the iteration goes
17:16:31
bollu
Hmm, How do I use cl-csv to write a `struct` ? `cl-csv:write-csv-value` seems to have coerced the entire struct into a string, which was not what I expected
17:20:11
Bike
if you have your own format in mind, looks like you might need to specialize write-csv-value
17:20:46
Bike
given that structs are readable, i guess you can just provide a :formatter that uses cl:write? and then figure out how to read it back
17:22:41
bollu
Bike Hmm, if I have a `struct`, is there some easy way to convert it to a list of its slot values?
17:32:29
White_Flame
bollu: in my experience, stuff like that involves generating your defstruct and support functions like that together
17:33:00
White_Flame
eg, you have your list of slots that you want, and codegen the actual defstruct call and the defuns for all the per-slot handling routines
17:34:12
bollu
I now wonder if given a reference to a function, if I can find the name of the defun that defined it?
17:34:26
bollu
[I understand that this is a tall ask, since a function reference could have come from a closure or some such]
17:35:06
White_Flame
if you just print the function object, your implementation might display it for you
17:35:21
Bike
mfiano: among other things, i don't think it is possible with decode-object working like it does. if you have two objects that contain each other, there is no way to decode one without already having the other
17:35:23
mfiano
Bike: They hang out in our lisp dev team's channel #bufferswap if you want to ask anything.
17:35:48
White_Flame
SBCL is fairly good at having named/printed representation for defuns, passed-around LABELS functions, anonymous closures, etc
17:36:56
bollu
I wonder if it's possible to somehow, given a common lisp object, find the classes the object implements
17:37:22
Bike
mfiano: thank you, but i think i'm doing ok right now. i still haven't had to alter the wire format at all, so i think it's going fine
17:38:19
White_Flame
yeah, you need to have a list of fields somewhere; generate your defstruct from it, and use the list to print your csv title line and other iterators
17:38:25
mfiano
Bike: I think it's fairly well-designed from my memory of the code. My only complaint, is a complaint with all of his projects: WITH-SLOTS being used everywhere.
17:38:39
bollu
White_Flame I think if you see the gist, you will find the list of slots as csv-fields-to-write
17:39:00
bollu
Oh, wait, are you suggesting I store the *label* of the slot and use the CLOS generic slot accessor functions?
17:39:17
Bike
mfiano: yeah, it's pretty good. i haven't e.g. had to touch the encoder at all. it just seems like circular references are a little underexercised
17:39:41
Bike
another thing i found was that conses (rather than lists) don't support circularity at all
17:39:49
White_Flame
you currently have two separate usages of per-slot named things, which will get out of sync if you change teh struct
17:40:00
White_Flame
if it's all driven from one slot specification list, then evertyhing will stay aligned
17:40:03
mfiano
Bike: Great. I'm sure he will accept a PR when you're done. He is just hesitant of added complexity.
17:40:19
Bike
having implemented compile-file before, i already know all kinds of weird trickery that comes up with circular lisp bullshit
17:41:36
easye`
contrapunctus: Just a friendly wave earlier. Thanks again for the resolving link to Rhodes' _Extensible Sequences_ paper for ABCL.
17:41:36
mfiano
Oh, yeah looks like it needs a bit more work then. I'm glad you're hacking that to make it better. I use that project from time to time.
17:41:42
White_Flame
this is why a more dynamic structure even if just alists might be a better option if you're doing stuff liek this
17:44:25
mfiano
Bike: Please let me know when you're done hacking on it so I can update my sources (if you don't get a PR merged).
17:45:13
Bike
Need to make sure it actually works for what I want it to do first. Also maybe add some tests
17:46:55
White_Flame
bollu: structs are strongly size/space optimized datastructures, not flexible abstract things
17:47:59
White_Flame
realign your source code to make your list of slots a first-class data item that the other things use
17:48:20
White_Flame
well, I don't know either. It's certaily possible as the implementation printer does it
17:48:28
jackdaniel
(mapcar #'c2mop:slot-definition-name (c2mop:class-direct-slots (find-class 'a))) ; while not explicitly portable, I think that it should work on all implementations
17:48:37
White_Flame
but that's only if it finds that it's a named defun, and not any other type of function object
17:52:37
mfiano
bollu: Structs are a hinderance in most cases. They do not complement the interactive development nature of Common Lisp, and there is only single inheritance.
17:53:20
Alfr
bollu, assuming you have a function foo. After (setf (fdefinition 'bar) (fdefinition 'foo)), what should the function-name of #'bar be?
17:53:30
mfiano
You should always start out with classes, and optimize later if need be. Class slots having generic accessors makes it very easy to perform additive programming practices.
17:53:37
White_Flame
bollu: I have used alists for csv, as well as plain lists and column-name->index lookups
17:55:24
bollu
White_Flame because I don't want to pull out *all* slots into a CSV, only *most* of them
17:56:07
bollu
so it's nice that when I store the functions that access the struct slots, I know that they're typed in right, because auto-complete and SBCL complains if you refer to an non-existing function via #'non-existent-function
17:56:20
White_Flame
ok, I've done that, too. generated a function which filtered the columnby index, based on the column names to include in order
17:56:25
bollu
while I won't have this if I just store a list of slot names like (def fields-to-write (list :a :b :c :d))
17:58:18
mfiano
I would also say that you should even think carefully before optimizing from standard-objects to structure-objects. Additive programming is very important for modularity and overall good software architecture.
17:58:47
mfiano
I value additive programming much more than the wee bit of performance and refactoring trouble I will get by switching to a struct.
18:44:33
Shinmera
it is still the best, but could do with a new revision. I think seibel talked about something like that last year (?)
18:47:38
mfiano
I might be mistaken but I might recall phoe wanting to take on that responsibility after he does CLR.
19:58:42
trev
i guess i didn't want to take such a deep dive into the language without seeing what it has to offer
21:22:12
Bike
mfiano: think i have reached a stopping point with my conspack fork (https://github.com/Bike/cl-conspack)
21:22:35
Bike
mfiano: unfortunately i realized that not only have i not actually been running the tests, i can't actually figure out how to, so i might need to ask about that at some point
21:24:07
Bike
i also got it working with my actual program, and now the serialization is a fifth of the space as my non-conspack solution, so that's cool
21:24:28
mfiano
Well he hangs out in #bufferswap as I mentioned. Usually around earlier than now though. Might have left for the day
21:30:41
Bike
most of the changes relate to objects. i might try (later) putting in some mop magic so you don't need a defencoding form for each class you want to serialize
21:33:04
Bike
or at least so you can skip all the slot names. i already put something in so defencoding forms kind of work with inheritance
21:36:09
mfiano
I mostly used it for serializing a bunch of octet vectors with a lisp dsl index at the head to find things. game assets and such