3 ms·
I understand map. Here's the code I was trying to understand. https://github.com/nakkaya/net-eval/blob/master/src/net_eval/core.clj#L16 https://github.com/nak
by tomp 13y ago
I understand map.
Here's the code I was trying to understand.
https://github.com/nakkaya/net-eval/blob/master/src/net_eval/core.clj#L16 https://github.com/nakkaya/net-eval/blob/master/src/net_eval...
I'm not sure I do even now. I mean, I kinda know what different symbols and functions do, but I couldn't write it myself.
- nickik 13y agoWhen you say full, of magic I think you mean the core langauge, witch is actually very simple. The example you provide is from a small test lib somewhere one github. Lets look at the macro, once you understand the basic macro concepts, witch are actually quite simple but still hard to understand. Its like a normal function, exept that the function code will be added to the var as data.
- llambda 13y agoIt's a (fairly simple) macro that defines a function which while doing so associates a quoted function definition (the same as the function being defined) with the metadata of the defined function's var: it might require a double reading (based on my inferior description) because it's got some meta-ness going on. But the salient point here is there's really nothing magical about what's happening there.
- andrewvc 13y agoIf you understand clojure that code sample isn't hard to understand. Of course, I don't really know what it does, because reading 4 lines in a library without knowing anything else is always confusing.
- Anderkent 13y agoIt puts the code of a function into its metadata so that it can send it for remote evaluation easily (see fire-request below that extracts the :task metadata and sends it to a remote nrepl server).
- fogus 13y agoI'm confused. Is it magical because you don't understand it, or do you not understand it because it's magical? It seems like you're saying the first one.
- moomin 13y agoAgreeing with everyone else here: there's no magic, but macros and metadata are fairly late topics in Clojure, and starting on a piece of code responsible for distributing code across a network... well, it wouldn't be my favourite place to start. Of course, the power of Clojure is that you actually can express this concept in the language. RMI looks pretty ugly by comparison.