2008-03-04
| 16:00 | albino | Why in this screencast can you not use the word variable instead of symbol? |
| 16:01 | arbscht | which one? |
| 16:01 | albino | clojure data strcutures part 1 |
| 16:01 | arbscht | right. which point in the screencast are you referring to? |
| 16:03 | albino | well I wasn't refering to anything specifically, someone (I think rhickey) is saying symbols |
| 16:03 | albino | I would like to understand what differentiates a symbol from a variable |
| 16:03 | rhickey | not all uses of symbols are variables, so I didn't want to equate them |
| 16:03 | rhickey | a symbol is an object |
| 16:04 | rhickey | it might name a var(iable) |
| 16:04 | rhickey | it might name an immutable local |
| 16:04 | rhickey | but symbols themselves don't have storage slots, unlike CL |
| 16:06 | arbscht | can you fake that with metadata? |
| 16:07 | rhickey | why? |
| 16:07 | arbscht | just wondering. it might not be good style |
| 16:08 | rhickey | symbols do support metadata, mostly to allow hinting to the compiler |
| 16:08 | rhickey | of course it could be misused |
| 16:08 | rhickey | but once you have a globally accessible name, you have a var anyway |
| 16:09 | rhickey | so why piggy-back on the metadata? |
| 16:09 | arbscht | mainly to overload it |
| 16:10 | arbscht | like you might with SYMBOL-PLIST in CL |
| 16:10 | rhickey | but you'll have to pass them around - two symbols with the same name can be different objects, with different metadata they definitely are |
| 16:10 | arbscht | right |
| 16:11 | rhickey | Clojure global vars are much closer to CL symbols than Clojure symbols |
| 16:11 | rhickey | CL interned symbols at least |
| 16:12 | albino | so variable implies mutability and we want to get away from that notion? |
| 16:13 | rhickey | pretty much, global vars are mutable mostly to allow function redefinition/fixes |
| 16:13 | rhickey | otherwise they should be used mutably only after per-thread binding |
| 16:14 | rhickey | which is safe mutation |
| 16:14 | rhickey | or put refs in vars |
| 16:14 | rhickey | or agents |
| 16:14 | rhickey | the idea is to used the controlled mutation strategies built in to Clojure |
| 16:15 | albino | well I hear the CL folks talk about symbols all the time |
| 16:15 | albino | kind of weird coming from the C++ background, variables man variables! |
| 16:15 | rhickey | C++ variables disappear after compilation, CL/Clojure symbols are objects |
| 16:30 | Chouser | Maybe I'm misusing keywords, but I find I do (. (str k) (substring 1)) a lot |
| 16:31 | Chouser | I guess I wouldn't want "str" to string the : off, even though "keyword" tacks it on. |
| 16:31 | rhickey | (name :foo) -> "foo" |
| 16:31 | Chouser | woohoo! Thanks! |
| 18:31 | rhickey | set ops and relational algebra are up: |
| 18:31 | rhickey | union, difference, intersection, index, project, select, join |
| 18:32 | rhickey | docs coming |
| 18:32 | rhickey | relations are sets of maps |
| 19:05 | rhickey | sets now (really) up, with docs |