<trev>
Josh_2 this probably does help, but i will need to stare at it for a while
<Josh_2>
Well if you play with #'apply you will understand that little snippet
yosef36 has joined #commonlisp
Algernon69 has quit [Read error: No route to host]
Algernon91 has joined #commonlisp
ahc has quit [Quit: Client closed]
cage has joined #commonlisp
<Bike>
trev: say you have lists = ((1 2) (3 4)). then (apply #'mapcar #'list lists) = (mapcar #'list '(1 2) '(3 4))
<trev>
dammit i'm dumb. i get it now. thanks Josh_2 and Bike
materialfuture has joined #commonlisp
<contrapunctus>
easye`: ?
<mfiano>
trev: It does a matrix transposition. It converts rows to columns and columns to rows.
<trev>
mfiano i knew that part :D
<mfiano>
Oh ok.
<trev>
i wasn't realizing that mapcar takes &rest
<mfiano>
Yes, now try playing with it using lists of different lengths and see if you can understand what is happening.
<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
yauhsien has quit [Remote host closed the connection]
yauhsien has joined #commonlisp
yauhsien has quit [Ping timeout: 256 seconds]
frgo has quit [Ping timeout: 260 seconds]
sander has quit [Quit: So long! :)]
yauhsien has joined #commonlisp
Algernon91 has quit [Ping timeout: 240 seconds]
tyson2 has joined #commonlisp
yauhsien has quit [Remote host closed the connection]
sander has joined #commonlisp
yauhsien has joined #commonlisp
yauhsien has quit [Ping timeout: 256 seconds]
Josh_2 has quit [Remote host closed the connection]
Josh_2 has joined #commonlisp
razetime has quit [Ping timeout: 252 seconds]
Sankalp has quit [Ping timeout: 240 seconds]
Sankalp has joined #commonlisp
<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
yauhsien has joined #commonlisp
<Bike>
if you have your own format in mind, looks like you might need to specialize write-csv-value
<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
scymtym has joined #commonlisp
<bollu>
Bike Hmm, if I have a `struct`, is there some easy way to convert it to a list of its slot values?
<Bike>
Not really, no
MajorBiscuit has quit [Quit: WeeChat 3.4]
froggey-1 is now known as froggey
orestarod has joined #commonlisp
<White_Flame>
bollu: in my experience, stuff like that involves generating your defstruct and support functions like that together
<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
<White_Flame>
classes can do much more dynamic stuff with this than structs
<_death>
if you use (:type list) in the defstruct, it's pretty easy ;)
<bollu>
White_Flame thanks!
<mfiano>
Bike: The author said the class circularity problem is very easy to fix.
<White_Flame>
however, for CSV data you might also just want to stick with alists/plists
<bollu>
_death lol, that's an interesting method, to just change the representation?
<Bike>
mfiano: i actually just finished rewriting half the decoder to fix it. oops.
<bollu>
I now wonder if given a reference to a function, if I can find the name of the defun that defined it?
<mfiano>
He said `notice-recursively` just probably needs to notice the object in place
<bollu>
[I understand that this is a tall ask, since a function reference could have come from a closure or some such]
<White_Flame>
if you just print the function object, your implementation might display it for you
<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
<mfiano>
Bike: They hang out in our lisp dev team's channel #bufferswap if you want to ask anything.
<White_Flame>
SBCL is fairly good at having named/printed representation for defuns, passed-around LABELS functions, anonymous closures, etc
<bollu>
White_Flame that it does, but I was wondering how to get the name as a sting
<bollu>
string*
yauhsien has quit [Remote host closed the connection]
<bollu>
I want to use the functions in csv-fields-to-write as the first row of my CSV
<bollu>
so it would be great if I can access the name of the function
<White_Flame>
in order to get the field names?
<bollu>
I wonder if it's possible to somehow, given a common lisp object, find the classes the object implements
<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
<bollu>
White_Flame I already have the fields I want to write
<mfiano>
Nice to hear.
<bollu>
I simply want to name the first row of the CSV based on the slots I wish to write
<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
<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.
<White_Flame>
code is data; use the code as data when you need that data
<bollu>
White_Flame I think if you see the gist, you will find the list of slots as csv-fields-to-write
<bollu>
White_Flame I wish to know how to access the name of the slot from the slot
<White_Flame>
instead of divining from opaque runtime objects
<bollu>
Oh, wait, are you suggesting I store the *label* of the slot and use the CLOS generic slot accessor functions?
<bollu>
I love CLOS more every day
<White_Flame>
that's not a list of slots, that's a list of accessor functions
<bollu>
right
<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
<White_Flame>
make and use a literal list of slot names
<White_Flame>
specify it just once, and have everything reference it
<bollu>
White_Flame and how do I access slots given the slot name?
<Bike>
another thing i found was that conses (rather than lists) don't support circularity at all
yauhsien has joined #commonlisp
<White_Flame>
you currently have two separate usages of per-slot named things, which will get out of sync if you change teh struct
<White_Flame>
if it's all driven from one slot specification list, then evertyhing will stay aligned
<mfiano>
Bike: Great. I'm sure he will accept a PR when you're done. He is just hesitant of added complexity.
<Bike>
having implemented compile-file before, i already know all kinds of weird trickery that comes up with circular lisp bullshit
<White_Flame>
to access slots by name, you need to have your own mapping
<White_Flame>
classes will give you that for free, though
<easye`>
contrapunctus: Just a friendly wave earlier. Thanks again for the resolving link to Rhodes' _Extensible Sequences_ paper for ABCL.
<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.
<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
<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).
<Bike>
Sure
<Bike>
Need to make sure it actually works for what I want it to do first. Also maybe add some tests
<Alfr>
White_Flame, how do you access a structure's slot by name?
<mfiano>
Always a good idea
<White_Flame>
Alfr: <White_Flame> to access slots by name, you need to have your own mapping
<Alfr>
White_Flame, saving the accessors? Hm ... interesting idea.
<bollu>
White_Flame that's disappointing :(
<White_Flame>
bollu: structs are strongly size/space optimized datastructures, not flexible abstract things
<bollu>
Hmm, is there also no way to get the name of a function from a function?
<White_Flame>
use defclass or associative datastructures for dynamic cases
<White_Flame>
bollu: don't do that
<White_Flame>
you already hae that information in your source code
<White_Flame>
don't go poking into implementation internals for something you already have
<bollu>
White_Flame yes, but I wish to know how. I promise I won't use it in production ;)
<White_Flame>
realign your source code to make your list of slots a first-class data item that the other things use
<White_Flame>
well, I don't know either. It's certaily possible as the implementation printer does it
Dynom has quit [Read error: Connection reset by peer]
<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
<White_Flame>
but that's only if it finds that it's a named defun, and not any other type of function object
<jackdaniel>
where (defstruct a x y z)
<mfiano>
jackdaniel: Why direct and not just c2mop:class-slots?
<jackdaniel>
a braino
<bollu>
White_Flame so I should also switch to classes, instead of structs, I take it
<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.
<Alfr>
bollu, assuming you have a function foo. After (setf (fdefinition 'bar) (fdefinition 'foo)), what should the function-name of #'bar be?
<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.
<White_Flame>
bollu: I have used alists for csv, as well as plain lists and column-name->index lookups
<bollu>
mfiano Yes, beach told me about this a while back.
<bollu>
I'll switch to classes
yauhsien has quit [Remote host closed the connection]
<bollu>
I wish storing slots as symbols gave me good tab-complete :(
<bollu>
White_Flame because I don't want to pull out *all* slots into a CSV, only *most* of them
yauhsien has joined #commonlisp
virgil has joined #commonlisp
<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
<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
<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))
<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.
<mfiano>
I value additive programming much more than the wee bit of performance and refactoring trouble I will get by switching to a struct.
tyson2 has quit [Remote host closed the connection]
n1to has joined #commonlisp
<virgil>
is Practical Common Lisp the best book if I wanted to learn commonlisp?
<White_Flame>
it's the most oft-recommended book here
virgil has quit [Ping timeout: 256 seconds]
jmdaemon has joined #commonlisp
virgil has joined #commonlisp
attila_lendvai has joined #commonlisp
jmd_ has joined #commonlisp
jmdaemon has quit [Ping timeout: 240 seconds]
<Shinmera>
it is still the best, but could do with a new revision. I think seibel talked about something like that last year (?)
treflip has quit [Quit: zzz]
Oladon has joined #commonlisp
<mfiano>
He did, and then said it doesn't seem likely.
<Shinmera>
Ah. Oh well.
<mfiano>
I might be mistaken but I might recall phoe wanting to take on that responsibility after he does CLR.
tyson2 has joined #commonlisp
yauhsien has quit [Remote host closed the connection]
yauhsien has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
minion has quit [Remote host closed the connection]
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
minion has joined #commonlisp
yauhsien has quit [Remote host closed the connection]
aartaka has joined #commonlisp
aartaka has quit [Read error: Connection reset by peer]
aartaka has joined #commonlisp
aartaka has quit [Read error: Connection reset by peer]
aartaka has joined #commonlisp
yauhsien has joined #commonlisp
yauhsien has quit [Ping timeout: 272 seconds]
virgil has quit [Ping timeout: 240 seconds]
virgil has joined #commonlisp
<trev>
virgil i am doing the lisp-koans first and then decided to read PCL
<trev>
i like to have some context before i dive into a book like that
Guest2866 has joined #commonlisp
kpoeck has joined #commonlisp
virgil has quit [Read error: Connection reset by peer]
virgil` has joined #commonlisp
<dbotton>
trev, I'd say that PCL is exactly the book to do before doing lisp-koans
aartaka has quit [Ping timeout: 272 seconds]
<dbotton>
you could even do the koans based on section of book you finished
<trev>
yeah perhaps you are right dbotton
<trev>
i guess i didn't want to take such a deep dive into the language without seeing what it has to offer
yauhsien has joined #commonlisp
Oddity has joined #commonlisp
Oladon has quit [Quit: Leaving.]
grawlinson has joined #commonlisp
yauhsien has quit [Ping timeout: 276 seconds]
tyson2 has joined #commonlisp
trev has quit [Quit: trev]
Guest2866 has quit [Quit: Client closed]
nosolls has left #commonlisp [#commonlisp]
frgo has joined #commonlisp
virgil` has quit [Quit: ERC 5.4 (IRC client for GNU Emacs 28.1)]
<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
<mfiano>
hmm checkl, never heard of it
<Bike>
it's also something rpav wrote
attila_lendvai has quit [Ping timeout: 272 seconds]
<mfiano>
or is that a 1? can't read my own font
<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
<mfiano>
Well he hangs out in #bufferswap as I mentioned. Usually around earlier than now though. Might have left for the day
<mfiano>
Nice!
cl-arthur has quit [Read error: Connection reset by peer]
<Bike>
i may pop in some other time, for the moment i want to stop thinking about conspack
<mfiano>
:)
pve has quit [Quit: leaving]
JoshYoshi has joined #commonlisp
JoshYoshi has quit [Remote host closed the connection]
<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
<Bike>
since there's already a c2mop dependency
Josh_2 has quit [Ping timeout: 276 seconds]
<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
<mfiano>
I did find that kind of ugly
<mfiano>
the defencoding form
<mfiano>
THough I didn't serialize objects much.
<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
Algernon69 has quit [Ping timeout: 260 seconds]
aeth has quit [Ping timeout: 256 seconds]
aeth has joined #commonlisp
paul0 has quit [Quit: Leaving]
pjb has quit [Remote host closed the connection]
n1to has quit [Quit: Leaving]
karlosz has joined #commonlisp
pjb has joined #commonlisp
orestarod has quit [Ping timeout: 260 seconds]
Posterdati has quit [Remote host closed the connection]
contrapunctus has left #commonlisp [#commonlisp]
contrapunctus has joined #commonlisp
tfeb has joined #commonlisp
kpoeck has quit [Quit: kpoeck]
karlosz has quit [Quit: karlosz]
morganw has quit [Remote host closed the connection]