#clojure logs

2008-03-04

16:00albinoWhy in this screencast can you not use the word variable instead of symbol?
16:01arbschtwhich one?
16:01albinoclojure data strcutures part 1
16:01arbschtright. which point in the screencast are you referring to?
16:03albinowell I wasn't refering to anything specifically, someone (I think rhickey) is saying symbols
16:03albinoI would like to understand what differentiates a symbol from a variable
16:03rhickeynot all uses of symbols are variables, so I didn't want to equate them
16:03rhickeya symbol is an object
16:04rhickeyit might name a var(iable)
16:04rhickeyit might name an immutable local
16:04rhickeybut symbols themselves don't have storage slots, unlike CL
16:06arbschtcan you fake that with metadata?
16:07rhickeywhy?
16:07arbschtjust wondering. it might not be good style
16:08rhickeysymbols do support metadata, mostly to allow hinting to the compiler
16:08rhickeyof course it could be misused
16:08rhickeybut once you have a globally accessible name, you have a var anyway
16:09rhickeyso why piggy-back on the metadata?
16:09arbschtmainly to overload it
16:10arbschtlike you might with SYMBOL-PLIST in CL
16:10rhickeybut you'll have to pass them around - two symbols with the same name can be different objects, with different metadata they definitely are
16:10arbschtright
16:11rhickeyClojure global vars are much closer to CL symbols than Clojure symbols
16:11rhickeyCL interned symbols at least
16:12albinoso variable implies mutability and we want to get away from that notion?
16:13rhickeypretty much, global vars are mutable mostly to allow function redefinition/fixes
16:13rhickeyotherwise they should be used mutably only after per-thread binding
16:14rhickeywhich is safe mutation
16:14rhickeyor put refs in vars
16:14rhickeyor agents
16:14rhickeythe idea is to used the controlled mutation strategies built in to Clojure
16:15albinowell I hear the CL folks talk about symbols all the time
16:15albinokind of weird coming from the C++ background, variables man variables!
16:15rhickeyC++ variables disappear after compilation, CL/Clojure symbols are objects
16:30ChouserMaybe I'm misusing keywords, but I find I do (. (str k) (substring 1)) a lot
16:31ChouserI guess I wouldn't want "str" to string the : off, even though "keyword" tacks it on.
16:31rhickey(name :foo) -> "foo"
16:31Chouserwoohoo! Thanks!
18:31rhickeyset ops and relational algebra are up:
18:31rhickeyunion, difference, intersection, index, project, select, join
18:32rhickeydocs coming
18:32rhickeyrelations are sets of maps
19:05rhickeysets now (really) up, with docs