3 ms·
That's an nice idea, using #<datastructure> as a straight-up constructor. I've always found hash-tables to be a colossal pain to create in Common Lisp. I tried
by pnathan 14y ago
That's an nice idea, using #<datastructure> as a straight-up constructor. I've always found hash-tables to be a colossal pain to create in Common Lisp. I tried to create a special JSON-esque syntax in CL for them, but it wasn't a smooth semantic drop-in.
- rdtsc 14y agoYeah I think it is pretty neat too. I had a couple of design ideas. This way I can persist some other structures (from Python for ex): For set(): (#set v1 v2 ...) For circular object graphs, I can encode an object reference to avoid serializing the same object twice: (#ref oid) Then of course there are custom class names I can pass in to serializer and deserializer: (#MyClass (attr1 val1) (attr2 val2) ...) This might not map to all languages but it worked for me.
- pnathan 14y agoCL uses # as a special character; I rewrote the idea into the (CL-standard idiom) `make-map` nomenclature: https://gist.github.com/4709844 https://gist.github.com/4709844 But yea, I hadn't thought of particularly using this idea. It's a good idea from Python (or maybe its older than that, IDK). :-)
- aerique 14y agoIsn't calling it a "colossal pain" a bit of hyperbole? A simple wrapper function should take away most of the pain.