#clojure logs

2008-10-13

00:00dnmChouser: How goes it?
00:16cadshehe
00:17cadsstranger in a strange land will honest to goodness make you want to start your own religion
00:17spacebatI wonder if it predates the publication of Dianetics
00:18cadshehe, your _own_ religion
00:24spacebatlast time I tried that I was so drunk
00:25spacebatone of the reasons I rarely drink to excess
01:04danlarkinSo I'm a little confused about gen-class and writing constructors
01:05Chouserheh. yeah.
01:05danlarkinfirst off, I'm not sure what :init is for... is it like a python metaclass?
01:07Chouserno, :init names the clojure function that will be used as the constructor
01:09danlarkinOHhh okay. And then :constructors is for saying hey I want a constructor with this arity, and this arity, and this arity
01:17danlarkinerf, still lost...
01:17danlarkinI want to make a constructor for a class that inherits from JFrame
01:19danlarkinif I just give it an :init 'init, then (defn MyClass-init [this] ...) doesn't match
01:21danlarkinbut I would expect it to?
01:24danlarkinor am I supposed to have MyClass-init take no args and then call the java super() function? but how can I call super() without an object to call it on?
01:35Chousersorry, stepped away...
01:38Chouserinit doesn't take a "this" arg
01:39Chousermy understanding is actually that :init gets called before the object is even created.
01:39Chouseryou tell clojure which of the super class's constructors to call by defining a mapping in :constructors.
01:43danlarkinHmm so how would I parallel a java example of adding things to a JFrame in the constructor?
01:46lisppaste8Chouser pasted "example of gen-class and gen-interface" at http://paste.lisp.org/display/68406
01:46Chouserthat's my working example that I always go back to for reference. Maybe it'll help some.
01:47Chouserit doesn't look to me like there's any JFrame constructor that takes children.
01:47Chouseroh! you mean you'd derive a class from JFrame, and in your class' constructor, add things to itself?
01:48danlarkinmmhmm
01:48Chouseryeah, don't bother. :-)
01:48Chouserjust make a JFrame and add things to it, no need for a subclass
01:49Chouseryou can put all that in a defn, if you want to be able to call it from different places.
01:54danlarkinChouser: tada!!
01:54Chouserah, good.
01:55danlarkinThanks a bunch for your help :-D
01:55Chousernp. gen-class is tricky. Did you end up needing it?
01:56danlarkinalthough I still don't quite get how :constructors works, but I'm gonna punt on that since I don't need it ATM.
01:57danlarkinwell for this specific problem it turns out no, I don't. But as I build up more I may...
01:58Chouserok, good enough. By far the best use of gen-class is no use at all.
01:59Chouserbut to make any sense of it have to have the docs open and that example I posted. Between the two I can usually muddle through.
02:02danlarkinI was mostly using gen-class because I was translating a Java example, which is in the form of a class (obviously) and it didn't occur to me to simply instantiate a new JFrame and modify it :)
02:03ChouserThe solution to every problem in Java is a new class, I think.
02:03ChouserAnyway, I'm off to bed. Have a pleasant whatever-it-is!
02:05danlarkinThanks for the help again, goodnight
02:05danlarkin2AM here :-o
02:06Chouserhere too! I should not be up.
02:07danlarkinI've got off from work tomorrow, lucky me
02:10Chouserme too, but I've still got to get the kids to school.
02:10ChouserOk, really going now.
02:10danlarkinnight
02:14dnmHrm.
02:23danlarkindnm: eh?
02:27dnmTrying to get slime and Clojure working together.
02:28danlarkinwhat part isn't working?
02:28danlarkinand what environment are you on
02:28dnmWindows, Vista.
02:29dnmEmacs 22.3.1
02:31H4nsXdnm: i've been successful with that, but have upgraded to emacs-23. what is the problem?
02:33dnmI think it's my local .emacs config. I'm troubleshooting now.
02:34H4nsXlisppaste8: url
02:34lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
02:34lisppaste8H4ns pasted ".emacs excerpt" at http://paste.lisp.org/display/68409
02:36dnmI know it's heresy and all, but my patience with [X]Emacs was finally exhausted a few years back.
02:36dnmI wish there were a nice IDEA plugin. ;]
02:36dnmH4nsX: Thanks.
02:37H4nsXdnm: i can understand the sentiment - i wish there was a nice native lisp development environment.
02:37dnmIs Cygwin running h:/clojure/clojure.sh for Swank?
02:37H4nsXdnm: yes - but that is just for the classpath setup. a .cmd will do fine
02:37dnmOK
02:38H4nsX(or the jar method described in the swank-clojure doc, but then you'll have to set up your classpath in your .emacs, which i find incinvenient)
07:02cadshttp://cadrlife.blogspot.com/2008/07/clone-wizards-of-time-and-space.html
07:03cadsgosh I wanna be an Intergalactic voluntarily Bald Clone Wizard of Time and Space...
07:03cadsespecially if the womens are be lusting for them
07:04cadsand most especially if I get to play with lisp while I'm at it
09:14yawniekhi! is there any orm in clojure yet?
09:15H4nsyawniek: clojure does not have an object system to begin with.
09:17yawniekhehe right. ok orm was the wrong term then. but a mechanism to persist data. like mnesia or so
09:18H4nsyawniek: i don't think that there is a native database in clojure beyond spit/slurp yet. and you can always use some java db connectivity solution or couchdb or something like that.
09:19yawniekok. thanks
11:05leafwquestion: how can one call clojure code from a java program, transparently? Can perhaps clojure generate a set of .class files (i.e. forsaking dynamic editing and so on)
11:06leafwideally, the clojure code would be in a jar with some static public methods (I guess that's what defn creates?)
11:07tWipahead of time compilation is not currently available, as i understand it
11:12dudleyfleafw: You can use gen-and-save-class to generate .class files with stubs that call out to Clojure functions
11:12dudleyf(doc gen-class)
11:13dudleyfI think Rich is working on true AOT compilation right now, too
12:06pjb3rhickey: So to do the proxy you are talking about for VelocityContext, is it something like this: (proxy VelocityContext [context] (get [key] (context (keyword key))))
12:06pjb3I'm doing it wrong somehow
12:07pjb3but I'm trying to create a proxy for VelocityContext that makes the get method call keyword on the string before doing a lookup in the map
12:07pjb3I haven't used clojure's proxy before
12:08rhickeypjb3: There is an interface called Context - that is what you want to proxy
12:09rhickeyhttp://velocity.apache.org/engine/releases/velocity-1.5/apidocs/org/apache/velocity/context/Context.html
12:10pjb3Ok, sound good, but I'm doing something wrong with the syntax of how I call proxy
12:10pjb3 (let [context {:foo 1}] (proxy Context [] (get [key] (context (keyword key)))))
12:10pjb3Should that work?
12:10rhickeypjb3: mimic: http://clojure.org/jvm_hosted
12:11rhickey(proxy [Context] [] (containsKey [k] ...
12:13leafwdudleyf: thanks for the gen-class tip, seems like clojure has thought of everything
12:17pjb3rhickey: Thanks, it worked!
12:18rhickeypjb3: great!
12:54dnmBoo:
12:54dnmhttp://common-lisp.net/cgi-bin/viewcvs.cgi/root.tar.gz?root=slime&view=tar
12:54dnmI'll have to pester someone to fix this.
12:55dnmProbably in #lisp. Sorry for the ranting.
13:42blabberhi everyone
13:42blabber:)
13:42danlarkinhello
13:45blabbercan't wait for the book to be out in March from pragmatic programmers
13:52rhickeyblabber: I imagine there'll be a beta pdf book before then
13:56blabberawesome
13:57blabberthanks rich
13:57blabberby the way - one line I liked about your intro video "Clojure allows you to code in lisp for a living!"
13:57blabberthat was a million dollar sentence :P
13:58blabberman you're a life saver.
13:59blabberlooking forward to the beta pdf..
14:07rhickeyfast enough to use as REPL
14:08abrooksrhickey: :)
14:50blabbercould anyone suggest any good introductory book on concurrency and parallel programming.
14:55karmazillablabber: Java Concurrency in Practice
14:55blabberkarmazilla: I donot know, or want to know Java - is that a prerequisite?
14:58blabberpreprequisite for the book
15:00karmazillayeah, that would really be an advantage
15:01karmazillaI don't know any language-agnostic books on concurrency and parallelism
15:01dudleyfblabber: It is, but if you intend to do concurrent programming on the JVM, read it anyway
15:02dudleyfIt's a good overview of the problems that arise with concurrency and shared mutable state
15:02blabbersure, will do. thanks.
15:02blabberdudleyf: oh really, that is interesting
15:03blabberdudleyf: that is exactly what I would like to get a stronger understanding off
15:03karmazillain the first couple of chapters, he scares you into reading the rest of the book ;)
15:04dudleyfOr scares you into finding a language that encourages immutability ;-)
15:04blabberI feel before learning clojure, I need to understand the problems that it solves. I will be a happy man if I understand most of clojure.org/state.
15:05blabberJava is not a function language, isn't it difficult writing concurrent programs in Java even if it is for the JVM
15:05rhickeyJava Concurrency in Practice is a terrific book, and a great argument for Clojure or something like it
15:06dudleyfYes, and that book shows just how hard it is to get right
15:08jgracinrhickey: OT, I hope you don't mind me asking, but what is the relation between you and the company that you work for? Do you own that company? I see that at Lisp50, you represent yourself as independent consultant.
15:08rhickeyjgracin: I really am an independent consultant. I work for myself, have an LLC
15:10jgracinrhickey: cool.
15:21chmuIs it possible to implement identical? in clojure
15:22rhickeychmu: in terms of what?
15:23rhickeyi.e. identical? is a primitive notion
15:23chmurhickey: I want to keep track of instances with identical? semantics
15:24rhickeychmu: Clojure has identical?
15:24rhickeyI'm confused
15:24chmurhickey: Yes, but I want to extract some unique identifer, ie "pointer" or reference value
15:25rhickeychmu: Java/JVM doesn't offer that
15:25chmurhickey: The problem is to keep track of nodes visited in a graph
15:26rhickeythe nodes themselves are references comparable with identical?
15:27chmurhickey: Nodes are shared and can therefore include loops
15:27chmurhickey: The graph can have loops
15:28rhickeychmu: you'll need to use something like IdentityHashMap, all of Clojure's data structures use equality
15:29chmurhickey: The java-class IdentityHashMap then?
15:29rhickeychmu: yes
15:30chmurhickey: Do you plan to implement something like this in clojure?
15:32rhickeychmu: I'm trying to get people to use equality semantics as much as possible, but I understand the use case - not sure what the right thing is - almost all non-evil scenarios boil down to what you are trying to do - duplicate detection
15:32rhickeychmu: but you can just put IDs in the nodes
15:33rhickeyyou can't get a physical loop with immutable data structures anyway
15:36chmurhickey: I could have a unique ID in every node but to rely on creating nodes using some factory function increasing a gloabl counter seems a bit fragile too
15:36rhickeychmu: in what way?
15:38rhickeyif you use refs to make a graph, you're fine too, as Clojure's refs have identity-based equals semantics, as should all mutable things
15:38lisppaste8karmazilla pasted "immutable loop" at http://paste.lisp.org/display/68437
15:38chmurhickey: I don't like global data in general :-). Yes, refs could be an option
15:39rhickeykarmazilla: try that in Clojure's data structures
15:40karmazillaI predict the outcome of that attempt won't be worth the effort
15:41rhickeyyou can create infinite looping sequences, but not physical loops
15:41rhickeychmu: you could close over a counter in your getID fn, need not be global
15:41tomppaIn fact, are there any reasonable approaches to functional, cyclic graphs?
15:41rapidorhickey: with lazy evaluation you can get physical loops
15:42rapidoin combination with recursive definitions
15:42rapidosee: http://www.haskell.org/haskellwiki/Tying_the_Knot
15:42chmurhickey: What do mean by "close over"? I'm a lisp/clojure-noob
15:44rapidobut i believe you can't get physical loops with *strict* immutable structures
15:45rapidotomppa: you can encode cyclic graphs with a non-cyclic data structure
15:45rapidograph == [nodes] + [links-between-nodes]
15:46lisppaste8rhickey pasted "get-id" at http://paste.lisp.org/display/68439
15:47rapidoi'd rather use cryptographic hashes of values to generate id's
15:47tompparapido: hmm, I'm feeling slow today; what about when I need to map them
15:47rapidoa global counter is surely to become a bottleneck in a multi-core setup
15:48rapidotomppa: map them (graphs) to what?
15:49chmurhickey: Thnx, of course, the magic world of closures :-)
15:49rhickeyrapido: hashes of values doesn't distinguish node identity, unless it also includes the edges, in which case it won't terminate, unless you can track identity, which was the original question
15:50tompparapido: Let say I have a bunch of Nodes that have circular dependancies between themselves, like one Nodes position depends on other Nodes velocity etc. and I need to update those nodes as quickly as possible
15:51rhickeyrapido: do you know anything specific about the concurrency limits of CAS? I've been told by experts you could pound on it until about 50 cores
15:51rhickeyand of course, you're not going to be giving out ids continuously, so it's not a real concern here
15:52tompparapido: I could simulate pointer equality with UIDs but that's likely to be slow and/or complicated
15:53rapidotomppa: interesting problem - hmm
15:53rapidook, let's encode the graph in a set of nodes and a set of links
15:54tompparapido: that's a fairly usual situation with games, and probably other simulation like scenarios
15:55arohnerrhickey: did you see my resultset-seq bug & patch?
15:55rhickeyrapido: already done, sample code here: http://groups.google.com/group/clojure/msg/df7b0f5673513b85
15:55rhickeyset of nodes, set of links, scales to 600 cores using Clojure's STM (which has one CAS, BTW)
15:56tomppathat's probably quite close to my domain, I'll have to check it, thanks :)
15:57rapidorhickey: ok, got it - looks cool
15:58rapidorhickey: what's clojure set implementation?
15:58rapidorhickey: i know a fast one based on treaps
15:59rhickeyarohner: yes, working on AOT right now, kind of falls in the don't do that category for me, as it's plain maps can't have duplicate keys
15:59rhickeyrapido: the same array-mapped hash tries as the maps
16:00arohnersure it's a bad idea, but the function explodes with an exception that is non-obvious
16:00tomppaoh, btw while I'm here there is a funny problem when running Clojure from Emacs/SLIME/Win, when opening a new JFrame the REPL seems to hang
16:00rhickeyarohner: 'don't do that', not that I won't apply the patch :)
16:00rapidorhickey: the one based on treaps always yields the *same* data structure regardless of insertion order
16:01rhickeytomppa: is it Vista?
16:01rapidowhich means that a (non)equality check between two sets can be made much faster
16:01tomppanope, good ole XP
16:01rhickeytomppa: you could paste
16:01rapidocompare the hashes of two treaps: if they are unequal the treaps are unequal
16:01rhickeylisppaste8: url
16:01lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
16:01tomppaInferioir lisp is still active though, so it's not probably a Clojure problem
16:02blabbergood night people - nice to meet all of you.
16:02rhickeyah
16:02rapidowith treaps you can have very fast union, difference and intersection
16:03tomppawhen running Clojure from command line it just takes a second or to complete the new JFrame. SLIME seems to hang on it and will recover after fooling enough with the inferior-lisp buffer
16:03rapidoand those algorithms can make trivially parallel
16:03rapidoi got it from: http://www.cs.cmu.edu/afs/cs.cmu.edu/project/scandal/public/papers/treaps-spaa98.pdf
16:05rapidorhickey: have you considered treaps when you were searching for an efficient map implementation?
16:07tomppaJust out of curiousity: do people here usually use SLIME/Emacs?
16:08tomppayep, I'm an emacs zealot
16:08arohnerthere are a good number of emacs/slime users, but I wouldn't call it even a majority of clojure users
16:08rhickeyrapido: I think the treaps might be a nice alternative for the ordered sets, for which I'm using a RB tree right now
16:09tomppaIt just occured to me that since it seems that clojure obviously talk the swank protocol, and there is this Eclipse/Swank thing called Cusp... It seems to me like most of the folks familiar with Java would have a passing knowledge of Eclipse
16:12rapidorhickey: and the treap's implementation of a set is easier to do than the RB tree implementation
16:12rhickeyexcept RB tree is already done and I have other things to work on
16:12rhickey:)
16:13rapidorhickey: sure, your todo list must be huge
16:14rapidorhickey: i wonder what's your most pressing todo item?
16:14rhickeyAhead of time compilation right now
16:15rapidowhat will be the benefits of AOT compilation?
16:16rapidofaster startup times?
16:16danlarkinjars
16:16rapidoah, jars.. of course
16:18rapidoOAT compilation looks like a tricky subject in the face of macros, on-the-fly proxies, etc
16:19rapidoi guess serializing the environment to a jar would do some of the magic....
16:20rapido(save-env snap-shot-1.jar)
16:20rapido(load-env snap-shot-1.jar)
16:20rapidoor something like that..
16:34rapidowhich of you are using colloquy? <- sometimes it behaves erratic
16:37rapidomay be clojure is going to be the next 100 year language :)
16:38rapidobut if not, clojure's concepts will most certainly be the next 100 year concepts!
16:39tomppaIt still seems to me that there is too much of the underlying JVM that I would need to know
16:40tomppaI have no problems learning the concepts of the underlying C machine but to spend time on a JVM is a different thing. That of course from the hobbyist/student perspective.
16:40rapidotomppa: just think of the JVM as a platform like sun-solaris or windoze
16:42rapidotomppa: and if you use a small set of standard JVM libraries..
16:43rapidoto leverage a convenient POSIX api
16:43rapidoyou don't need much knowledge of the JVM
16:43tomppaWell, I think it's much easier for languages like Python etc. but Clojure is fairly pure in its functionality and it just constrast a bit too much with the JVM libraries
16:45tomppaHaving an ad hoc FFI is a great thing but will that also mean that there is not going to be that much clojurescy (thin) wrappers for (foreign) libraries
16:46tomppaso that you will end up reading (. foo abstractFactory) on every few lines, which, I think is not quite "clojurescy"
16:47rapidotomppa: i concur: clojure is to java libraries as java libraries are to native libraries (JNI).
16:48rapidotomppa: but you should encapsule java libs with clojure libs
16:48rapidoand than you can use clojure all the way
16:49rapidoand i believe clojure doesn't need to wrap many java libs to be useful
16:49tomppabut, like I said, it is harder for more functional or otherwise "alien" languages
16:49rhickeytomppa: idiomatic wrappers will be developed according to need, what's nice is that they are not necessary to leverage something right away. vs langs that have to wait for libs, sometimes indefinitely
16:50tomppathat's the ad hoc part, and I think it's very nice
16:50rapidoand what's the alternative: re-implement all those useful and practical libraries
16:50rapido?
16:52rapidoit's all about momentum and gaining it by jumping on the biggest lump that is moving :)
16:52tomppawell, Java did also implement lots of useful and practical stuff
16:53tomppaI guess it's just about getting lump moving fast enough and in time :)
16:53tomppare-implement, that is
16:54kotarakbtw, what is the preferred way of writing macros? (list 'foo) or `(foo)? I would expect the latter, since it qualifies the symbols. Maybe (list `foo) (with backquote) is also feasible?
16:55karmazillatrouble is the standard libraries... there's lots of crappy code in the JRE that can't be changed for compatibility reasons
16:55rapidonaturally, immutability and concurrency will force new implementations of previously mutable and sequential algorithms
16:56rapidoonly re-implement when there is a need (for concurrency and immutability)
16:57rapido... getting more and more urgent in the multi-core world .....
16:59rapidoi believe clojure is 'slider' technology that can move us from the current situation to the desired situation, less painfully.
17:02gnuvince_How painful does something need to get before the general mass begins moving? I have not been programming long enough to have witness the OO shift, but what did it take to move all those C and Pascal and whatnot programmers to C++ and Java and Smalltalk?
17:05tomppaI think you can forget the Smalltalk
17:05tomppathe furthest most people look is C# and Java
17:05rapidognuvince_: i had *very* painful moments and most of them had to do with ... destruction of information
17:05rapidodeleting files
17:06rapidothe same file name - but different contents
17:06rapidothe same class name - but different 'implementation'
17:06danlarkinthe size of programs was getting too big for people to keep the whole context in their head, OO helped encapsulate things and made it easier for many people to work on a project at once. That was the big push, IMO. That and a huge, huge, huge marketing budget by sun
17:06rapidothe same method name - but ....
17:07rapidoi got stung by encapsulation *really* bad
17:08karmazillasometimes OO is abstracting away the wrong details :p
17:08rapidoa method that opens a database connection, creates a files and throws an exception
17:08rapidoforgets to close the file and database connection
17:08rapidoall beautifully encapsulated as a third party library
17:09rapidoi don't mind abstractions
17:09gnuvince_I hang in a French-speaking general programming language channel, and most people there seem either totally unaware that their tools are total crap for concurrent programming (most are C and C++ programmers) or just don't care and think that dealing with locks and deadlocks and race conditions is just part of programming and if you can't do it yourself correctly, you're just a bad programmer (they use the same argument for memory management)
17:09rapidobut they shouldn't leak
17:09danlarkinrapido: you can't blame a buggy 3rd-party library on OO :-D
17:09rhickeykotarak: the simpler the better, but use syntax-quote to get name hygiene
17:10kotarakrhickey: I definitively prefer the `() form.
17:10kotarak(which is "syntax-quote" I suppose)
17:11danlarkingnuvince_: people don't like to change. programmers, bankers, politicians, no one
17:11tomppagnuvince_, funny. I would have thought that french were beaten enough with Ocaml ;)
17:11karmazilladanlarkin: to an extent you can... language is the framework wherein ideas are created and described. If the language is faulty/error prone, and the thinker human, then trouble is inevitable. Better languages decreases the probability of trouble.
17:12rapidognuvince_: locks and race conditions are the worst bugs - even worse than memory allocation/deallocation bugs
17:12gnuvince_tomppa: most of us are actually Quebecers, and I'm the only one singing the praises of functional programming. Probably the only one that knows any function language actually.
17:13tomppagnuvince_, oh, sorry for the generalisation
17:13rapidognuvince_: i challenge every programmer that thinks he got manual memory and locking correct for a none trivial application
17:13gnuvince_rapido: preaching to the choir :) I just have a hard time getting the problem through to them.
17:14gnuvince_tomppa: no problem, I actually know many French (from France) programmers who *do* swear by OCaml. OCaml is more popular than Haskell there.
17:14rapidognuvince_: hey, i've got myself burned multiple times
17:14rapidoocaml is nice
17:14danlarkinkarmazilla: agreed. but at the same time, one can write correct code in any paradigm
17:14gnuvince_Basically, once I say the word "immutable", their brains shut down.
17:15gnuvince_Basically, this destroys their entire view of programming: mutating values at specific memory addresses.
17:15tompparapido, ocaml is nice but it _looks_ crappy and has an s*tt* FFI. Among other things...
17:15rhickeygnuvince_: try that on them
17:15gnuvince_Haskell is just more fun
17:15gnuvince_rhickey: gonna read that now.
17:16rapidognuvince_: haskell's got unsafePerformIO or something
17:16gnuvince_rhickey: got any success on friends/colleagues?
17:16gnuvince_rapido: yeah it does.
17:16arohnerrhickey: it would be interesting if you had a "reading list" of stuff you've read and liked
17:16rhickeyyes, definitely - that paper + Clojure
17:17gnuvince_arohner: I quite liked Rich's "State vs Identity" article on the Clojure website.
17:17rapidothis is one of my favorites: http://www.hpl.hp.com/techreports/2002/HPL-2002-32.html
17:18karmazillaI can't even get my collegues to read JCiP... maybe the book looks too big
17:19rapidoand i like this obscure language that never got into the limelight: http://www.cs.ttu.edu/~dcooke/sequencel11-27-2006.pdf
17:21rapidoand i really *really* feel this is very good research: http://deposit.ddb.de/cgi-bin/dokserv?idn=977115860&amp;dok_var=d1&amp;dok_ext=pdf&amp;filename=977115860.pdf
17:22tomppadamn, my wife has killed the university net quota, takes ages to load the .pdfs
17:22rapidotomppa: lol!
17:23tompparapido: hey, the latest True Blood was up!
17:24rapidotomppa: priorities, priorities......
17:24tomppa... tell it to her
17:26rapidooh.... it's getting late here in the netherlands.. got to go ... later...
17:27tomppanight
18:22arohnerrhickey: thanks. you've made me irritated at syntactic commas in all other languages.
18:22arohner:-)
18:22rhickey:)
18:41chmuhas anyone experimented with monads in clojure to express imperative constructs a bit more concise?
18:45chmuI would like to avoid to pass and return state variables. perhaps is refs the way to go in clojure?
19:02arohnerchmu: do you have an example?
19:03chmuarohner: I traverse a graph and have to keep at least two states. Visited nodes (a set) and a string pool offset table (hash table)
19:04chmuarohner: With "classical" functional style I would have to return these values from every function
19:04arohnerwithout knowing your app, it sounds like vars, refs or agents could all work
19:05chmuarohner: vars are per thread and refs are global - right?
19:06arohnerrefs are global, yes.
19:06arohnerVars can have a "default" global value, and then thread local values
19:07arohnervars can also have stack behavior:
19:07arohner(def x 1) (binding [x 42] (a) (b)) (c)
19:08arohnerinside (a) and (b), x will be 42, and will return to 1 when leaving the binding form
19:08arohneryou can also use set! on the var
19:09chmuarohner: ok, could you pass vars created in a binding outside the context?
19:10arohnerare you asking about passing the var object or the value?
19:10chmuarohner: The object. Is the (def x) the only way to create vars?
19:11arohnerI believe so
19:11chmuarohner: I would like to create a var in the first function and then pass on
19:11arohneryou can pass the var around, but (I think) the value will change depending where you are when you evaluate
19:11chmuarohner: ok, perhaps refs are better for my purpose then?
19:12arohnerif you pass the value that the var points to around, that is always immutable
19:13chmuarohner: Is (with-local-vars) similar to (binding)?
19:14arohnerI'm not sure, I've never used it
19:15Chouserhuh, I hadn't looked at with-local-vars before. Both it and (binding) use Var/pushThreadBindings, so I guess they're substantially similar.
19:16Chouserchmu: you can create a ref in a func, pass it around letting other functions change it, and read it at any point including once you've returned back to the initial function.
19:17Chouserbut now that I'm starting to understand with-local-vars, that may be what you want.
19:18Chouserit creates the var for you (unlike "binding" with requires the vars to be defined with def first) but then you can var-set and var-get to change and read the var within the same thread -- no STM or locking.
19:20chmuChouser: Is it also possible to pass vars in (with-local-vars) to other functions?
19:23Chouseryou can pass the var itself, yes
19:24chmuChouser: Great stuff. Thnx :)
19:25Chouserno, thank you -- I didn't know these tricks with Var until trying to answer you questions. :-)
19:26chmuheh
20:06rhickey_anyone looking to try rev 1068 must put ./gen in the classpath
20:24gnuvince_rhickey_: do you have other papers about state that are a good read?
20:28rhickey_gnuvince_: not offhand
20:31gnuvince_ok, thanks.
20:34Chouserrhickey_: for AOTC you're producing class files directions instead of java source?
20:35rhickey_Chouser: yes
20:37blackdogwhat's class files directions?
20:37Chousersorry my typo. "class files directly"
20:37rhickey_my reado
20:38blackdogah ok
20:38rhickey_yes, it ends up being a better first step - no debug info issues, no possible differences with current code emit
20:38blackdogoh no source, why did you change your mind rhickey_ ?
20:39rhickey_I'm hoping there will be good acceptance of the classfiles by converters etc.
20:39rhickey_generating source is always a future option
20:43blackdogremoving the extra compilation step with javac must be a good thing
20:43Chouserhoping -- no testing yet, such as with android?
20:43rhickey_Chouser: right android is one
20:44rhickey_But I think Scala bytecode translates, and they don't gen Java afaik
20:44rhickey_obfuscators would be another
20:45rhickey_should be pretty obscure - non-javac bytecode + mangled names
20:45rhickey_some constructs would be awkward going to Java source - no goto
20:46Chouserthey have java decompilers, right? I wonder if they'd just punt on seeing a goto.
20:48rhickey_javac generates gotos, it's just that Clojure code doesn't correspond to Java constructs
20:48Chouseroh, ok.
20:49blackdogso aot before lisp50 then rhickey_ :P
20:50rhickey_blackdog: maybe
20:50blackdogcool, it was just a joke!
20:50rhickey_I'm pretty close
20:51blackdoggood platform for an announcement though
20:55rhickey_I think I'll be busy justifying Clojure's existence there
20:57blackdogi think most open minded folks will realise it's the NBL ;)
21:08scottj__In order to import files such as Order.java that's in C:\libraries\com\company\lib, all I should need is to start Clojure with java -cp C:/libraries;C:/src/clojure/clojure.jar clojure.lang.Repl and then type (import '(com.company.lib Order)) right?
21:09blackdogalso add c:\libraries to your classpath
21:09blackdogduh
21:09blackdogmissed it :)
21:09rhickey_you'll need Order.class, not Order.java
21:10scottj__ok, there's my problem.
21:20dudleyfrhickey_: Do you know of any actual implementations of FRP systems based on the paper you linked earlier?
21:22rhickey_dudleyf: Clojure is the closest I know of, but doesn't use relations for state
21:25rhickey_I hope to get in Datalog, adding a query model and declarative rules
21:28Chouserthen just store your data in postgres, and you're all set.
21:28rhickey_Chouser: postgres instead of datalog?
21:29Chouserpostgres instead of in-memory relations (for state)
21:29Chouserlargely a joke, though many "classic" web app designs come pretty close to that
21:33dudleyfDo you get Durability (as in ACID) with a datalog implementation, or is it all in-memory?
21:34rhickey_dudleyf: in memory
21:35rhickey_I don't think relational is a good model for in-memory data manipulation
21:36rhickey_So I draw broader conclusions from the paper - the desirability of a data model and a declarative style
21:37dudleyfBut if it doesn't survive a reboot or a crash, it's hard to depend on for business data
21:39dudleyfAnd that's really the only context I have for caring about a data model
21:39rhickey_dudleyf: it's not a replacement for a DB, just a way to manipulate data within a program, vs ORM classes say
21:46emacsenI've heard that Clojure can't do continuations. Is that because of the JVM or a language choice?
21:48rhickey_both
21:48emacsenWell, if you chose not to put them in, it didn't matter if the JVM supported them or not
21:48emacsenSo, why not?
21:48emacsenYou're a smart dude, so I'm curious as to why you don't think continuations are a good thing.
21:50rhickey_well, I think continuations are complicated to implement, and difficult for developers to understand
21:51emacsenOkay. If that's your reason it's a fair one. I don't agree it's any more complicated than other parts of Lisp (which is full of stuff that's "hard to understand") but that's fair
21:52rhickey_compare Clojure's lazy-cons to any implementation of generators on continuations
21:52ChouserPaul Graham implemented continuations in CL using macros. Someone could try that in Clojure.
21:53rhickey_Chouser: those were not real continuations
21:53rhickey_Clojure is really very simple, I've never seen any continuation code that was simple
21:54emacsensimple, no. I've seen some that's really powerful though.
21:54emacsenmaybe it's possible with your data model to fake some of that. I don't know enough to say
21:55rhickey_I understand the theoretical building-block notion, and therefor the fit for Scheme, but when you say, you can use them to implement exceptions, well, already have, generators, already have lazy seqs, threads, etc etc - I don't fid myself needing them
21:55emacsenI'm thinking of an example I saw a speaker talk on this weekend regarding a continuation-based regex parser
21:55rhickey_find
21:56emacsenand the schemers and arkers (all 20 of them) like them for stateful web programming
21:56emacsens/ark/arc
21:57rhickey_I don't think true language continuations are useful for web stuff, rather pseudo continuations in the context of the web app - language continuations capture too much, or don't have enough control
21:57emacsenhttp://www.lisperati.com/arc/regex.html is what I was thinking of (ignore the pic)
21:57emacsennow, I'm thinking "how else could this be done"
21:58emacsenand I guess, maybe you could do something like have a new thread per match
21:58emacsenand then come back at the end, do them all at once
21:59emacsenso, you're probably right
21:59emacsennot strictly necessary
22:01rhickey_I can't read arc code, but I noticed CPS and lazy-lists in the description - again, already have lazy-seqs
22:03emacsenHe presented the code, but I can't reproduce it from memory. There's probably a way to do the same thing.
22:04emacsenSo, let me radically change the subject
22:04emacsenDo you think you'll be in the mid-atlantic (DC) area any time in the next year?
22:05rhickey_emacsen: I'm not saying you can't do cool things with them, but there's a cost/benefit relationship to weigh before adding something like that. So far, very few languages have chosen continuations as fundamentally necessary
22:05rhickey_DC? no plans so far
22:05emacsenyeah. It's a language design choice, and I'm not a language designer.
22:06emacsenand you're probably right- lazy-cons can probably fit the bill most places
22:06emacsenThere are two groups in the area dedicated to "fringe" languages, so was just curious
22:07rhickey_do you have many members?
22:07pjb3emacsen: which two are you referring to?
22:08emacsenpjb3, well, FringeDC and there's one in Reston, I'm looking for the name. Both groups are fairly small. The most people I've seen attend a meeting is 30some
22:08pjb3emacsen: NovaLang?
22:09emacsenthey're a gaming group I believe, Novalang
22:09emacsenoh, no
22:10emacsenthere are two novalang groups... confusing. so maybe. :)
22:10emacsenI won't go all the way to reston for my girlfriend, so not going all the way there for a computer meeting :)
22:10pjb3The one I'm talking about just finished up studying Erlang and is now contemplating the next language
22:11emacsenI have no idea how big/small they are. But yes, I hear they're big on Erlang
22:11emacsenare you a member?
22:11pjb3I'm in Baltimore but in Bethesda a few days a week, so I go to those meetings when I can
22:11emacsenWhy didn't you go to the FringeDC meeting Saturday?
22:12emacsenDC is a heck of a lot closer than Reston
22:12pjb3I was at RubyDCamp in Reston
22:12emacsen(tell me if I'm off topic and I'll move the conversation)
22:12emacsengotcha
22:12pjb3Where does FringeDC meet?
22:12emacsenIt keeps changing (this is something Conrad seems to like, but I don't. Last time we met at HacDC
22:13emacsenMeetings are also only every quarter, so it's hard to keep things going. I think he'd do better to have a meeting every month on a learning track, perhaps