#clojure logs

2008-12-16

00:07arohneris the github mirror of clojure contrib working for anyone else?
00:07arohnerit says the last commit is dec 7
02:38Lau_of_DKTop of the morning gents
03:07slanganhttp://www.computersight.com/Programming/Five-Strangest-Programming-Languages.397205
03:07slanganLOLCODE ^^ so friggin funny
03:07slanganhttp://www.computersight.com/Programming/Five-Strangest-Programming-Languages.397205
03:07replacayeah, that was a big reddit today
03:08slanganoops
03:08slangan"IM IN YR LOOP - IM OUTTA YR LOOP"
03:08slanganHAI
03:08slanganCAN HAS STDIO?
03:08slanganVISIBLE "HAI WORLD!"
03:08slanganKTHXBYE
03:08replacayeah, but it needs a graphics subsystem that shows pics of your LOLCATs while the prog runs
03:12zakwilsonlolcode was on reddit months ago.
03:15ivanslangan: http://www.esolangs.org/wiki/Language_list
04:02AWizzArdWhen I have a string filled with xml, how can I parse it?
04:02Lau_of_DKSee Zip-filter
04:03AWizzArdin the clojure.xml package?
04:03Lau_of_DK(xml-> (xml/Parse "xml-file.xml") :root :child [:element "Custom search"])
04:03AWizzArdwell yes, but (clojure.xml/parse ...) does not work on strings
04:04AWizzArdit wants a file or a url
04:05Lau_of_DKThats where Zip-filter comes in
04:05Lau_of_DK(zip/xml-zip (xml/parse "file.xml"))
04:05AWizzArdin what package can I find it?
04:05Lau_of_DKContrib somewhere, Chouser wrote it
04:05AWizzArdyeah, only that I don't have a file
04:05Lau_of_DKhuh?
04:06AWizzArdI have a string filled with xml.
04:06AWizzArdIf it were a file or a url I would use clojure.xml/parse
04:06Lau_of_DKAs I recall there's also a func which takes a string
04:07AWizzArdthis is what I am looking for :-)
04:07Lau_of_DKinfact, doesnt (zip/xml-zip ) do that?
04:07AWizzArdit takes a string s, but only returns [s nil]
04:08Lau_of_DK(defn parse-str [s]
04:08Lau_of_DK (zip/xml-zip (xml/parse (new org.xml.sax.InputSource
04:08Lau_of_DK (new java.io.StringReader s)))))
04:09albinoparse-str sounds like it parses a string :)
04:09AWizzArdyes
04:09AWizzArdbut it's not included I guess?
04:10Lau_of_DKIm not sure :)
04:10AWizzArdI mean, you just wrote it yourself, right?
04:10Lau_of_DKNo I found it in the bottom of zip-filter.clj, under examples, commented out :)
04:10Lau_of_DKI think its a little helper Chouser wrote
04:11AWizzArdic
04:17AWizzArdgood, works, thanks
04:22wipewindowsCan I haz purpose with life K thanks?
04:27jdzslangan: such purposes are hard to find. and they are not in this channel. kthnxbye.
05:39hiredmanclojurebot: sicp?
05:39clojurebotsicp is http://www.codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages:Clojure:Chapter_1
05:40hiredmanclojurebot: sicp is also <reply>those guys are such dorks
05:40clojurebotIk begrijp
05:56AWizzArdclojurebot: max users?
05:56clojurebotNo entiendo
05:56AWizzArdsehr gut
05:59hiredmanclojurebot: max people
05:59clojurebotmax people is 116
06:03AWizzArdis that number (user-) overwritable?
06:03hiredmanyes
06:03AWizzArdclosurebot: max people is 4
06:04hiredmannice try :P
06:04AWizzArdCan you please lock this?
06:05hiredmanwhy?
06:05AWizzArdto be able to trust this number (because it inherits trust in you)
06:08jdzwhat is max people and why would anybody want to trast such a number?
06:08jdz*trust
06:09hiredmanjdz: it stores the max people clojurebot has seen in the channel
06:09hiredmanI dunno why someone would trash it, and I am not sure that I care if they do
06:11jdzmax as in "highest number of people present at one time" or "how many [different] people have visited the channel"? (i assume it counts stats for this channel ;)
06:11hiredmanit doesn't really do stats
06:11AWizzArdat the same time
06:11hiredmanjdz: max at any one time
06:12jdzwell, i don't see much use of this number if it does not reset daily or weekly
06:12jdzand if it does not store the history
06:12hiredman*shrug*
06:13jdzexcept for entertainment reasons
06:15AWizzArdHi black
06:15blackdog_hi
06:52slanganhow do you use databases in clojure?
06:52blackdog_clojure.contrib.sql is a good place to start
07:07AWizzArdslangan: you have your own namespace, such as (ns com.slangan (:require (clojure.contrib [sql :as sql]))) and then in that namespace you can say (sql/with-connection ...) and so on.
08:05wipewindowshow do I pull contrib?
08:18aperottewipewindows: contrib is hosted on sourceforge, are you asking for the svn address?
08:20aperottehas anyone noticed that you get different behavior when using (load-file ...) versus calling each form in a file yourself in a repl?
08:33clojurebotsvn rev 1161; refactored Comparator into superclass of functions only
09:19clojurebotsvn rev 1162; EPL in header
10:03aperottehello all, can anyone think of why some of the forms in a file might not be evaluated when using (load-file ...). If I load the file into emacs, select the contents and evaluate region, they all get evaluated.
10:05Chousernone of them get evaluated with load-file?
10:06aperotteno, all of the def's get evaluated
10:06aperotteand the defn's
10:06aperottebut then I call a few of the defined functions
10:06aperottethey don't get run for some reason
10:07Chousercan you trim it down to a single defn and a single call?
10:07aperotteI'll try, give me a few
10:11slanganhow do I install contrib? do I just place it in some folder and then import it?
10:13hoeckslangan: yes, or you build a jar with ant
10:13hoeckand import that
10:14rhickeysvnsync-ing Clojure to Google Code - taking forever
10:17aperotteChouser: It's going to take me some time to trim it down, I'll come back once I can isolate the problem
10:18Chouseraperotte: ok. for what it's worth, the only thing I can think of is that the namespace var *ns* may get pushed/popped for a load-file
10:18Chouser...but I can't think of how that would break anything in your case
10:25shoover`rhickey: whoa, never saw lisp/clojure.lisp before
10:26aperotteChouser: hmm ... ok, I'll keep that in mind while testing
10:27rhickeyshoover`: doing some archaeology?
10:27shoover`when I went to the google project, that's how far along the sync was
10:27rhickeyah
10:28rhickeytaking only slightly less time to sync than to write from scratch...
10:29shoover`thinking in Common Lisp, Clojure, .NET and JVM simultaneously must've been fun
10:29rhickeyshoover`: yeah
10:30Chousukehm
10:31ChousukeI guess teh move to google code means I'll have to reclone clojure... I hope GC will at least be faster than sourceforge :P
10:32Chouserbrowsing svn via the web is much faster at google code. fast enough to be usable even.
10:34Chousukegoogle code is definitely superior to sourceforge.
10:35Chousukestill, I keep wishing there was an official mirror using some DVCS :)
10:35rhickeyChouser: yes, everything about gc's web interface is so much faster
10:36rhickey... rev 370 ... fourth restart ...
10:36ChousukeI wonder if there is a way to get check-in notifications for the SVN repo in google code via some google api.
10:36Chousukethat way you could have an automatically updated git/mercurial/whatever clone of it.
10:37ChousukeRSS might be good enough.
10:39Chouserwhy push when you can poll, right? :-P
10:40rhickeyLooks like I can setup an address for commits and one for issue changes
11:06rhickeyhttp://groups.google.com/group/clojure-commits
11:06Chouserah, nice idea.
12:14rhickey200 revs left ...
12:14RSchulzThe full commit history is being replicated at the GC repo?
12:14rhickeyI hope so
12:21Chouserit looks that way
12:26RSchulzWhen you say "it looks that way" are you seeing the commits on the feed at the foregoing link? 'Cause I'm not.
12:26rhickeyRSchulz: they're not new commits, so I wouldn't expect them there
12:26RSchulzThey have a special "import an existing SVN repository" capability?
12:27rhickeyRSchulz: yes, a one-shot thing
12:27RSchulzCool.
12:27triddellI can see the various revisions and view the diffs etc.
12:27rhickeyone multi-hour extravaganza apparently
12:28triddellat 1055 and climbing
12:28rhickeymaybe we shouldn't fiddle around in there too much until it finishes?
12:28Chouserright, not at the feed, but by examining the browsable svn repo I can see old versions of files.
12:28triddellnp :-) ... that's exactly how I'd feel
12:29rhickeyfinal lap...
12:36RSchulzOn the lighter side, here's an IM I just sent to a Lisp programmer buddy of mine: Clojure keeps getting cooler. I can sense where this is headed. I'm going to end up in a state where writing Java makes me feel dirty.
12:37rsynnottirritated is more common than dirty, I suspect
12:45zakwilsonI feel dirty when I have to use some Java library that requires a lot of mutation (e.g. constructors that don't take reasonable args, requiring the use of setters)
12:47rhickeysvn checkout http://clojure.googlecode.com/svn/trunk/ clojure
12:47rhickeyhave at it
12:48rsynnottyay! Non-incredibly-slow svn :)
12:48rhickeyhttp://code.google.com/p/clojure/source/browse/
12:49rhickeyhttp://code.google.com/p/clojure/source/list
12:51gnuvinceYou changed the license?
12:53rhickeygnuvince: yes, to EPL a couple of days ago, to facilitate this move - successor to CPL
13:00Chousukeheh
13:00Chousukegit cloning the new repo now. it's still low, but way faster than sourceforge :P
13:00Chousukeslow*
13:04zakwilsonclojurebot: svn?
13:04clojurebotsvn is https://clojure.svn.sourceforge.net/svnroot/clojure/
13:05zakwilsonclojurebot: svn is http://code.google.com/p/clojure/source/checkout
13:05clojurebotIk begrijp
13:05Chousukefive minutes and already half done. this is not so bad after all
13:10alphazeroclojurebot: svn is http://clojure.googlecode.com/svn/trunk/
13:10clojurebotRoger.
13:11alphazeroURL: http://clojure.googlecode.com/svn/trunk
13:11alphazeroRepository Root: http://clojure.googlecode.com/svn
13:11alphazeroRepository UUID: a41a16f3-9855-0410-b325-31a011a03e7c
13:11alphazeroRevision: 1162
13:11alphazeroNode Kind: directory
13:11alphazeroSchedule: normal
13:11alphazeroLast Changed Author: rhickey
13:11alphazeroLast Changed Rev: 1162
13:11alphazeroLast Changed Date: 2008-12-16 09:10:56 -0500 (Tue, 16 Dec 2008)
13:13ChouserChousuke: surely there's a way to use my existing git repo and just retarget the upstream one.
13:14duck1123_Chouser: I would think that git-svn wouldn't like that unless they were actually the same repository, just moved
13:15ChousukeChouser: probably, but... my reclone just finished :)
13:15Chousukeif you have local modifications I guess you need to export them as patches :/
13:23RSchulzWell, for us readers-only, that was completely painless. I did a little switcharoo with directories after the check-out, copied over my src/Clojure.iml (not to be confused with Rich's clojure.iml!) and voila! Even IDEA didn't mind.
13:39rsynnottrfgpfeiffer_: they differ only by capitalisation?
13:39rsynnottsorry, RSchulz
13:39RSchulzI was unaware of Rich's when I set up my IDEA module. But mine's also in the src/ subdirectory while Rich's is at the top.
13:39RSchulzNot that it matters, mine's never going to leave my system.
13:47RSchulzIs Clojure-Contrib migrating to GC, too?
13:48ChouserI think it will, but I suppose it has to be compeletely switched over to EPL first.
13:51Lau_of_DKGood evening good folk
13:56zakwilsonGood day, Lau_of_DK.
13:57zakwilsonIf you'll recall that file format we were talking about a few days ago, it's even more bizzare than I thought.
13:57Lau_of_DKI remember, what did you find ?
13:59zakwilsonThe official editor software generates files that make sense (parameter_id in one file matches parameter_id in the other), but the nearly 400 device files supplied as a downloadable package do not.
14:00zakwilsonThe official editor and the lighting controller can read and use these files.
14:00Lau_of_DKSounds a little unintuitive, isnt this documented somewhere?
14:01zakwilsonSo I can make a working editor that will produce working files, but I cannot edit the files provided by the vendor.
14:02zakwilsonDocumented? Ha!
14:02Lau_of_DKIs the two-way thing important in your situation ? I remeber you want to provide a single-format solution to light-shows?
14:05zakwilsonIt's not important for that goal, but I want to start by making an editor for a single file format, and it would be nice if it's fully functional.
14:06Lau_of_DKMaybe you'll be the guy who writes the one Lamp to rule them all! :)
14:06zakwilsonI actually have the controller in question and the provided device editor is horrible. It's slow, unstable and only runs on Windows.
14:06zakwilsonI intend to release the replacement editor as open source, and use it as the basis for me one editor to rule them all.
14:07Lau_of_DKSounds charming, but its good that you get some RE experience, thats always fun
14:08zakwilsonI'm not sure I want to glorify it by calling it reverse-engineering. Figuring out what labled fields in a CSV file mean isn't that hard.
14:09zakwilsonFiguring out that some fields are generated by adding/multiplying other fields is a little harder... as is discovering that overflow of a signed int is part of the design.
14:09rsynnottzakwilson: on a machine of some particular word size, I assume? :)
14:10Lau_of_DKI read your previous statement as you wanting to dive into the controllers driver? The one you said was slow and unstable
14:10sohailzakwilson, maybe the thing to do is create your own format :-)
14:12zakwilsonGetting in to the controller's software is beyond me right now.
14:12zakwilsonI intend to create my own format, but that needs to be translated in to formats various controllers can read.
14:13deklundquick question: 'use' is not transative? (does not appear to be). I just want to verify... i.e. if I use on a ns, I don't get the libraries/namespaces that the used namespace references?
14:13zakwilsonrsynnott: yes
14:13zakwilsonit seems to be 32-bit
14:14zakwilsonwhich means I should be able to rely on overflowing ints with Clojure's unchecked arithmetic.
14:14RSchulzdeklund: I'd hope not! But seriously, no.
14:15deklund:) thanks
14:15rsynnottit'd probably work in 32bit mode on a 64bit machine
14:15rsynnottbut if you had the source and built it 64bit, it would probably NOT work
14:15RSchulzzakwilson: In the x86_64 world, at least, 32-bit programs run just fine as is. They need their usual complement of dependent libraries in 32-bit form, but the hardware for x86_64 is a superset at the user level.
14:16rsynnottsame with Ultrasparc, I think; when running a 32bit app overflows happen as you'd expect
14:17zakwilsonThat makes sense. I don't have an x86_64 machine yet. Oddly enough, I do have an Ultrasparc.
14:19rsynnott32bit software running on an x86_64 just sees an ordinary x86
14:19rsynnottno extra registers or anything :)
15:03Lau_of_DK(doc emit)
15:03clojurebotIt's greek to me.
15:04hiredmanonly clojure.core
15:16hiredmanactions sent to agents happen in order right?
15:18RSchulzhiredman: According to http://clojure.org/agents they do.
15:18RSchulz"Actions dispatched to an agent from another single agent or thread will occur in the order they were sent, potentially interleaved with actions dispatched to the same agent from other sources."
15:21hiredmanexcellent
15:24RSchulzhiredman: Is this the first you're using Agents? I wrote my first code for them yesterday and I gotta' say, I think they're very cool.
15:25RSchulzBut I really wish I could figure out how to keep them from hindering shutdown via CTRL-D at the REPL.
15:25RSchulzRegistering them as a JVM shutdown hook doesn't seem to work.
15:26RSchulzI should say, registering an execution of (shutdown-agents) via the JVM shutdown hook doesn't work.
16:47Lau_of_DKIn which revision did doseq change to vector bindings?
16:50RSchulzLau_of_DK: Since it's meant to mimic (for ...), it seems natural. Anyway, I never encountered it in another form.
16:51Lau_of_DKMr. Schulz, it seems that the change was made after 1089
16:52RSchulzWhat binding form did it take before then? A list?
16:52Lau_of_DK(doseq i (range 10)
16:53Lau_of_DK(println i))
16:53Lau_of_DK1
16:53Lau_of_DK2
16:53Lau_of_DK3
16:53Lau_of_DK...
16:54RSchulzAh. Much more limited than (for ...)'s capabilities, then?
16:54Lau_of_DKThe purpose of the change was to allow for :when :while keywords
16:59SimonAdameithi
16:59SimonAdameitHow do I measure the size (length) of a collection?
17:00hiredman(count ...)
17:00SimonAdameitthanks!
17:00SimonAdameitI obviously searched for length :)
17:02RSchulzKeep in mind that doing so will force a lazy collection and will never terminate for an unbounded one.
17:02Chouserbut is constant-time for a PersistentList
17:05RSchulzChouser: All of them?
17:06Chouserall instances of PersistentList? yes.
17:07RSchulzI meant all subtypes, but I see it has none. Other implementations of IPersistentList do not have constant-time (count ...) behavior, do they?
17:10ChouserI don't think it's guaranteed, but right now the only other implementor of IPersistentList is APersistentVector, which also should be ableo to do count in constant time.
17:14dmileswas DotLisp and clojure expected to be almost the same syntax?
17:15dmileshttp://code.google.com/p/opensim4opencog/source/browse/trunk/bin/test.lisp
17:15hiredmandmiles: http://dotlisp.sourceforge.net/dotlisp.htm <-- explains why the syntax might be similar
17:15dmilesoh cool
17:17RSchulzChouser: I posted to the list, but I guess I could / should have just mentioned it here, but Atoms are missing from the type chart.
17:17ChouserRSchulz: hm! thanks.
17:25gnuvince_If send-off immediately returns, how come doing a send-off of 20 elements takes nearly 10 seconds?
17:26Chousergnuvince_: because you're doing something else in your loop that takes nearly a half-second?
17:27RSchulzOr because as soon as you send a task off the thread assigned to the receiving Agent becomes active and runnable?
17:32gnuvince_Chouser: The loop just does the send-offs
17:35gnuvince_net.gnuvince.comics> (time (doseq [[comic a] comic-agents] (send-off a conj (try (fetch-comic comic) (catch Exception e nil)))))
17:35gnuvince_"Elapsed time: 23271.9988 msecs"
17:36Chousergnuvince_: nope, that's a common mistake. send-off takes a function not a block of code.
17:36gnuvince_Chouser: that's what I do
17:37gnuvince_(send-off a conj (...))
17:37Chouserooh, maybe send and send-off should assert their arg is a IFn
17:37Chousergnuvince_: ah, good point.
17:38gnuvince_Unless the try/catch is executed before the send-off
17:38Chouserbut you're still evaluating the arg (fetch-comic) before passing its return value to send-off
17:38Chouserright
17:38gnuvince_Which would actually make sense
17:38Chouserright
17:38gnuvince_ok
17:38gnuvince_Thanks
17:38gnuvince_I'll see what I can do
17:38gnuvince_Well
17:39gnuvince_While I'm here
17:39gnuvince_Here's the problem I want to solve: I want to fire up a bunch of threads and accumulate their results in a single ref
17:43hiredmanmake it a thunk, arg to the func you send to the agent
17:44hiredmanclojurebot: haskell?
17:44clojurebotYo dawg, I heard you like Haskell, so I put a lazy thunk inside a lazy thunk so you don't have to compute while you compute.
17:45danm_heh
19:26aperotteChouser: I asked this morning about (load-file ...) versus evaluating each expression in a file at the repl. Are there concurrency issues that might lead to differences in how things might be evaluated in those two settings?
19:29RSchulzaperotte: I think it's a virtual certainty that what you're seeing is not about concurrency unless you're evaluating forms that directly or indirectly trigger threaded execution (Agents, e.g.)
19:31Chouseraperotte: does the problem go away when you trim it down?
19:32aperotteIt's hard for me to trim it down because I have a bunch of definitions that build on one another
19:33aperotteI'm not using agents ... only refs
19:34aperotteChouser: I tried toy examples, but I didn't have the same problem
19:35aperotteRSchulz: ok, even if I'm using a java library deals with threads and might lock?
19:35RSchulzThe more so!
19:36RSchulzThe bottom line is that logically (with sequential execution assumptions) there's no difference between (load-file ...) and one-by-one evaluating the forms in the loaded file.
19:37RSchulzThe fact that you're seeing a difference and that you know you're (indirectly) executing explicitly threaded code strongly suggests that that code is not entirely thread-safe.
19:37Chouseraperotte: can you sprinkle println's through the file?
19:37RSchulzIs the pattern of execution (or the difference between the two modes of evaluation) repeatable? Or unpredictable / variable?
19:38RSchulzChouser: Heisenbug territory!
19:38Chouseryep
19:38aperotteI haven't tried println's through the file because I know it gets to the last statement
19:38aperotteBut it is completely repeatable
19:38ChouserI understand -- I'm curious if the first println's would execute or if none of them would.
19:39aperotteok, I'll give it a try
19:40ChouserRSchulz: I'm not sure exactly what to do with atom in the graph
19:41RSchulzI don't know how it fits into the type structure. What's the problem?
19:41RSchulzaperotte: Are you running on a multi-CPU or multi-core system?
19:42Chouserwhen you use 'atom' it creates an instance of clojure.proxy.java.util.concurrent.atomic.AtomicReference$IRef
19:42aperotteRSchulz: I'm running on a single cpu, single core system
19:42ChouserI can add that to the graph, but AtomicReference$IRef doesn't strike me as a particularly useful name
19:43aperotteChouser: all of the (println ...) statements sprinkled through my code work
19:43RSchulzWhat I did when I first started playing with your chart generator code was to add a predicate of my own to detect Obj / IObj, which had not been accommodated at that time in your code.
19:43RSchulzThen I associated that with the others in your big map of type predicates.
19:44RSchulzSo even though there was no (obj? ...) in Clojure, my modification to your generator acted as if there was and the graph was generated accordingly.
19:44RSchulzThe same should be possible with Atoms.
19:44aperotteChouser: however, between two of the println statements I sprinkled exists some code that should take about 20 seconds to run, and the println's happen within 4 seconds of one another ... I'm very confused why there's a difference at all
20:02Chouseraperotte: wow.
20:03ChouserRSchulz: it's not a problem of the code, it's how the chart should look
20:03ChouserI suppose I could use the word 'atom' in lowercase and leave out the cryptic class name entirely
20:03RSchulzYes, but the point is that you can influce that by faking a pair in the map between labels and type predicates.
20:04RSchulz...influence...
20:04RSchulzActually, the only "faking" is of an (atom? ...) predicate.
20:05gnuvince_paste
20:05gnuvince_lisppaste8: paste
20:05hiredmanlisppaste8: url
20:05gnuvince_lisppaste8: paste?
20:05lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
20:05lisppaste8gnuvince pasted "Looks okay?" at http://paste.lisp.org/display/72271
20:06gnuvince_Chouser: how does that look?
20:09Chousergnuvince_: well, does it work? :-)
20:09Chousergnuvince_: any particular reason you don't use the value from *comics* as the agent's state?
20:10gnuvince_It works
20:10gnuvince_Chouser: I don't really need the state of an agent
20:10gnuvince_I'm merely using them to launch new threads
20:11Chouserdo you really want the fetch-comic call to re-run if there's contention on the ref?
20:11gnuvince_no
20:11gnuvince_I guess having fetching the value once is enough.
20:11gnuvince_s/having//
20:13gnuvince_So I'd better move out the try/catch out of the dosync?
20:13Chouserright. I think that will also lead you to a more "functional" definition fetch-comic.
20:14Chousergotta run -- I'll be back later.
20:14gnuvince_See ya
21:35RSchulzChouser: Perhaps the funkiness surrouding Atoms comes from the fact that they're Clojure proxies. See (defn atom) in .../core_proxy.clj
21:42ChouserRSchulz: yes
21:43RSchulzI don't know how that helps, but perhaps it points the way. Still, the use of a user-supplied (you're the user) atom? predicate seems like a workable hook.
21:43RSchulzYou could also ask Rich for an atom? predicate in the Clojure core.
21:44Chouserno, I don't need anything like that.
21:45Chouserthis is just about how to label the graph
21:45RSchulzThen I think my technique will work.
21:45Chouserall the other classes we care about have names. Ref, Symbol, etc.
21:46ChouserBut what name should I give this thing? There is logical class that could be named Atom, but because it's a proxy class its name is not terribly useful.
21:47ChouserI'm looking now at adding "constructor" function names to the graph
21:47Chouserthat would add things like 'hash-map', 'sorted-set' and such to the appropriate ovals. Then adding 'atom' to this new one would be consistent.
21:51RSchulzThe name should just be Atom. The membership criteria would (for now) be (loosely speaking) (and AtomicReference IRef).
21:52Chouserno, there is no thing called Atom
21:54RSchulz(defn atom? [thing] (and (instance? clojure.lang.IRef thing) (instance? java.util.concurrent.atomic.AtomicReference thing)))
21:54RSchulzI know, but people will understand what an Atom (or "atom") is in the context of the graph.
21:56RSchulzRegardless, you should probably consult Rich about this so you can depict the class structure accurately.
21:57Chouseryou don't think they'll be surprised when they write try to write an 'instance?' test and find there's no clojure.lang.Atom class?
21:58RSchulzWell, that's why there should be type-discriminating predicates for every distinct kind of entity in the core!
22:20deklundhi all... what am I missing here? (let [ #^{ :a 1 :b 2} x [1]]
22:20deklund (meta x))
22:21deklundreturns nil
22:25Chouserdeklund: the #^ reader syntax attaches meta to the symbol x at reader time.
22:25ChouserI think.
22:26Chouseryou might want: (let [x (with-meta [1] {:a 1 :b 2})] (meta x))
22:27deklundchouser: thanks. I guess I need to stretch my mind about that 'read' time distinction... i am not yet getting it.. ( I am guessing this is something fundamental)
22:28Chouserperhaps -- I'm not sure I quite get it yet.
22:28deklund:) good to know
22:30Chouserdeklund: http://groups.google.com/group/clojure/msg/919455504c57659e
22:32deklundI was just reading that... I guess the distinction is that the #^ reader macro assigns to a 'form' object
22:32deklundwith-meta is more for runtime 'user' objects
22:32deklundsound plausible? warmer?
22:35Chousermaybe, but 'form' objects and 'user' objects aren't very different
22:36Chouserwhen read, your first example creates a symbol x with the meta-data you gave.
22:37Chouserthe compiler looks in that hash for a :tag key for type hints. Macros could use that metadata.
22:37Chouser(I'm thinking this through out loud -- makes more sense to me each time I try)
22:38deklund:)
22:38Chouseronce compiled, I don't think you can get to that symbol x anymore, though.
22:39deklundinherently, you are using it, though... so how would it be lost
22:39deklund?
22:39Chouserno, the compiler used it to produce bytecode. In the bytecode it's probably just a java local, not a Symbol object anymore.
22:40hiredmanclojurebot: you in?
22:40clojurebotGabh mo leithsc�al?
22:40Chouserrhicky's not here to correct me when I wander off the true path. :-/
22:40deklundso ... in that case, (let [ x #^{ :a 1 :b 2} [1]]
22:40deklund x)
22:41deklundis the second x a new symbol?
22:41deklundi thought they got interned... and x was not lost
22:43Chousersymbols are not interned in Clojure
22:45Chouser(identical? (symbol "x") (symbol "x")) ==> false
22:45deklundahh... so the second x is considered a new form symbol
22:45deklundok... neat (def #^{ :a 1 :b 2} x [1])
22:45deklund(meta x) returns => nil
22:45deklundbut
22:46deklund(meta #'x) => {:file "NO_SOURCE_FILE", :b 2, :line 1, :a 1, :ns #<Namespace user>, :name x}
22:46Chouserright, in that case the meta is attached to the Var as well -- I'm trying to find where that happens.
22:47Chouserof course you can also (def x #^{:foo :bar} [1])
22:48deklundI get a compiler error on that one
22:48Chouserhm!?
22:48deklundi tried that switcheroo with the let form and got a compiler error too
22:49deklundjava.lang.NoClassDefFoundError: clojure/lang/Compiler$MetaExpr (NO_SOURCE_FILE:1)
22:49deklund [Thrown class clojure.lang.Compiler$CompilerException]
22:49Chouseryou build from svn?
22:49deklundlast week
22:49Chouserdid you "ant clean" before "ant"?
22:49hiredmanboth works here
22:50deklundi'll try the ant clean
22:50deklundand an svn up
22:52deklundyup.. mea culpa. I needed to do an "ant clean"
22:52ChouserI think this is where the code is produced to copy the metadata from the symbol to the var: http://code.google.com/p/clojure/source/browse/trunk/src/jvm/clojure/lang/Compiler.java#327
22:55deklundjust to be sure... the metadata is being copied to var or to the value of the var?
22:57deklundI'm going to have study the java in depth..
22:57Chouserto the Var itself
22:59deklundok. now that I got rid of the compiler problem
22:59deklund(let [ x #^{ :a 1 :b 2} [1]]
22:59deklund (meta x))
22:59deklundreturns {:a 1, :b 2}
23:00deklundthe switcheroo works...
23:01deklundin that case I could make this argument:
23:02deklund(let [ x #^{ :a 1 :b 2} [1]] (meta x)) returns ---> {:A 1, :b 2}
23:02deklund(let [ #^{ :a 1 :b 2} x [1]] (meta x)) returns ---> nil
23:02deklund(let [ #^{ :a 1 :b 2} x [1]] (meta 'x)) returns ----> nil
23:02hiredmancorrect
23:02deklundin the first case, the metadata is associated with object itself
23:02hiredmanyes
23:02deklundin the second it's associated with the symbol x
23:03deklundbut not it's evaluated object
23:03hiredmannot the symbol
23:03hiredmanthe var
23:03deklundand in the THIRD... the second x is a new sybol
23:03Chouserhiredman: nope, no Var here
23:03hiredmanbut
23:03hiredmanfine
23:03deklundvar?
23:03hiredmanI lose
23:03deklundok
23:03Chouser:-)
23:03hiredmanclojurebot: hiredman?
23:03clojurebothiredman is a three-toed sloth
23:04deklunddoes this THIRD scenario seem plausible?
23:04deklundyou said symbols are not interned, so that could explain the nil return
23:04Chouserhiredman: Vars are created by 'def', 'intern', 'with-local-vars', but not by 'let'
23:05Chouserdeklund: I think so
23:05Chouserbut we should be able to ask for the meta of the same symbol...
23:05deklundi would think so too
23:06deklund but as you said... (identical? (symbol "x") (symbol "x")) returns false
23:06deklundso there might be no way to get the same symbol
23:06Chouserright, but I mean the *same* symbol, not just a symbol with the same name...
23:07deklundyes
23:07Chouseryeah, I'm not getting it. still trying...
23:07deklundi think I'm closer
23:07Chouser(let [z 0] (meta '#^{:a :b} z))
23:08Chouserthe ' quotes the meta and symbol together. Like:
23:08Chouser(let [z 0] (meta (quote #^{:a :b} z)))
23:09deklundoh goodness. :) now I'm more confused
23:09Chouserno no, stay with me!
23:10deklundi'll try
23:10Chouserwe're using meta to ask for the meta of a quote symbol
23:10Chouserquoted symbol
23:11deklundok.. i think i see where you're going
23:11deklundfirst off... i thought quote only worked on the form right next to it
23:11Chouserso the meta of the symbol itself, not of the value or of some other symbol with the same name
23:11deklundyes
23:12Chouserdeklund: that's right, except the reader takes the #^ metadata annotation and the following symbol together
23:12deklundi see that... and the fact that the quote works on the 'form right next to it implies the metadata is part of the next form
23:12Chouserdeklund: in other words, #^ is the one exception to ' ... I think.
23:12Chouserexactly
23:12deklundread time... it's becoming clearer
23:13deklundok... i see what you did there.
23:13Chouser(macroexpand '(let [z 0] (meta '#^{:a :b} z)))
23:13Chouserthe ' quotes the z which just happens to have had metadata attached to it already.
23:14deklundas attached by the reader
23:14deklundyes
23:14Chouser(binding [*print-meta* true] (prn '(let [z 0] (meta '#^{:a :b} z))))
23:15deklundi think i see the path to clarity
23:16deklundi wonder if there is a way to get to that symbol later
23:18Chouseryou can get to it in a macro, but after that I doubt it.
23:18deklundchouser: excellent.. thanks for walking through that with me
23:19Chouserand thank you! I understand it much better now.
23:20Chouser(defmacro pm [x] (println x "has meta" (meta x)) x)
23:20Chouserlet [z 0] (pm #^{:a :b} z))
23:20Chouserwith, of course, a leading (
23:22deklund i see, we're in a different evaluative mode with macros
23:22Chouserright, the parameter x in pm is the actual symbol that the reader is handing us -- the instance of Symbol with the metadata that the reader attached.
23:23Chouserof course that's still a different z symbol than the one in let's vector.
23:23deklundyes
23:24deklundbut there was still that var issue...
23:24Chouserwhat is that?
23:25deklund(def #^{:foo :bar} x [1])
23:25deklund(meta #'x)
23:25deklundi think the _value_ of the var is getting the metadata
23:25deklundis that not what the #' reader macro does?
23:25Chouserah, no.
23:26Chouserif you (def x), then later when you say just x it does the dereference and gives you the current value there.
23:26Chouser...because in normal programs, that's what you want.
23:26Chousersaying #'x or (var x) is sorta preventing the deref and giving you the Var object.
23:27deklundahh i misread the api... that makes sense
23:27Chouseryou can call the 'get' method of the Var object to get it's current value.
23:27Chouser(.get (var x))
23:27deklundor (var-get) apparently
23:28Chouserwell sure, if you want to use the "documented" and "supported" API
23:28Chouser:-)
23:28deklund:)
23:28deklundso as a Var object is interned, we can get at its metadata later
23:28Chouseryes!
23:28deklundnot so with symbols
23:28deklundok
23:28deklundpor fin!
23:28deklundagain thanks...
23:29deklundtime to hit the sack and have meta dreams
23:29Chousersame here. good night