#clojure logs

2009-07-26

00:09hiredman~scala
00:09clojurebotUnfortunately the standard idiom of consuming an infinite/unbounded resource as a stream can be problematic unless you're really careful -- seen in #scala
00:38AnniepooI'm crashing the compiler.
00:38Anniepoois that sufficiently unusual that I should file a bug somewhere?
00:43hiredmanAnniepoo: are you sure you are feeding the compiler valid input?
02:22hiredmanhttp://software.intel.com/en-us/articles/intel-c-stm-compiler-prototype-edition-20/ <-- in 2007 intel released a c/c++ compiler with support for some kind of stm, go figure
02:27slashus2They have a neat little flash demo.
02:35slashus2The tutorial is a little broken, but it is a neat illustration.
02:35slashus2It is "undefined"
03:18Fossi1if you have a gen-class that uses a gen-class, how do you import them/ how do you infer the right build order?
03:22hiredmansounds like trouble
03:22hiredmanwhy are you gen-classing so much?
03:22Fossi1because i use the android api to create a view and other things
03:23Fossi1so i'm surrounded by interfaces i have to implement
03:23hiredmanproxy
03:24Fossi1can try, but the question is still valid
03:24hiredmangen-class is really only if you need to provide a constant name for a class
03:25hiredmanFossi1: it is, sure, and I don't know the answer, but I do know it should very much be a corner case
03:25hiredmanproxy is much prefered
03:25hiredmanand now new-new is almost here
03:25Fossi1hmmm. so, for creating a view, i could proxy from the main class ('activity')
03:26Fossi1is there a nice way to have a proxy in it's own file?
03:26hiredmanwhat do you mean?
03:26Fossi1hmm. that didn't make sense
03:26Fossi1:)
03:27hiredmanyou still need gen-class to generate a program entrance point
03:27hiredmanbut most implementation of interfaces shoudl be via proxy
03:31Fossi1i can't hold any state in the proxies though, right?
03:33hiredmanthe proxy "methods" are fns so you can close over anything you want
03:34hiredmanthe real gotcha with proxies is you cannot add methods that don't exist in the superclass or implemented interfaces
03:35hiredman~gen-class
03:35clojurebotNo, hiredman, you want gen-interface + proxy
03:37hiredman~proxy
03:37clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
03:37hiredman:|
03:37Fossi1hmmm
03:38Fossi1i don't know yet whether that will be a proble
03:38hiredmanit really should not be, any methods used on an object should be part of its interface anyway
03:38Fossi1i guess i will defer the implementation to other namespaces anyway
03:39Fossi1yeah, and then again, it's not a big deal to add another interface
03:40Fossi1and think you just made my life a whole lot easier, thanks again :)
03:40Fossi1s/and/i
03:41hiredmanno problem
03:43hiredmanI am sort of aghast that you went right to gen-class's complications and passed over proxy, most show up here wonder why the methods they try to tack on via proxy don't work
03:49Fossi1well, with such a lot of things to implement, and the compile step inbetween, i thought i'd rather gen-class things instead of adding another layer of indirection
03:50Fossi1but then again, as seid, it made my whole life a lot more complex
03:50Fossi1and if i wanted performance i c/should've used Java in the first place
03:52hiredmanI don't think gen-class results in less layers of indirection then proxy
03:52hiredmangen-class classes are just stubs that call out to the clojure functions
03:52hiredmanwhich seems to be more or less what proxies do
03:53hiredmanI have looked too much at the implementation of proxy
03:53Fossi1might be
03:54Fossi1overall, it prolly was a pretty stupid move :)
03:54hiredmannew-new (which doesn't exactly exist yet) will apparently generate jvm byte code directly be more direct no stubs etc
03:57Fossi1figured from what i read here
03:58Fossi1when you change such stuff (from gen-class to proxy, ...) somehow slime goes nuts
03:59Fossi1anybody know a way to make it forget all bound/compiled things?
04:25Fossi1http://developer.android.com/reference/android/opengl/GLSurfaceView.html "Handling events" - how would one port that to clojure with proxies?
04:33hiredmanso you have a function make-renderer which returns a proxy of GLSurfaceView or something and your main class calls the function and registers the proxy as the renderer
04:38Fossi1hiredman: was that an answer or a question?
04:39hiredmanif you're not sure, it must not be an answer
04:53Fossi1lisppaste8: url
04:53lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
04:57lisppaste8Fossi pasted "android setup" at http://paste.lisp.org/display/84212
04:58Fossi1almost works now
05:29Fossi1ok, now with the proxies, the constructors don't get called i guess
05:30hiredmaneh
05:30hiredman,(doc proxy)
05:30clojurebot"([class-and-interfaces args & fs]); class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the superclass constructor. f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) Expands to code which creates a instance of a proxy class that implements the named class/interface(s) by calling the supplied fns. A single class, if provided, must be first. If not provid
05:32Fossi1actually, i guess it's something else
05:32hiredmanFossi1: I am pretty sure the superclass constructor should be called
05:32Fossi1there's lots of side effects going on in this code, so i guess that's it
05:35Fossi1the object i get from my state later is not the one i called setRenderer on
05:36angermanhow do I unpack a list
05:36angermane.g. ((+ 1 2) (+ 2 3)) -> 3 5
05:36hiredmanangerman: apply
05:36hiredmanbut what do you mean by unpack
05:36angermanbasically I want to use (doto X Y)
05:37hiredmanthat will give you an error because 3 is not a function
05:37hiredman,((+ 1 2) (+2 3))
05:37clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
05:37angermanwhere Y is of the form ((.method "x") (.methdo "y"))
05:37angermani basically generate Y using map
05:38hiredmaneh?
05:38hiredmanstill not making a lot of sense
05:38angermanok
05:38hiredmanwhat do you want to do?
05:38angerman(map (fn [[op key val]] `(.addFilter ~(name key) ~(op *filters*) ~val)) specs)
05:39angermanthat's Y
05:39angermanand then I want to do (doto (Query. "X") Y)
05:39hiredmanand why can't you?
05:40angermanbecause as far as I understand it. Y returns ((.addFilter ...) (.addFilter))
05:40hiredmanno
05:40hiredmanwell, yes
05:40angermanand (doto expects (doto (Query. "X") (.addFilter ...) (.addFilter))
05:40hiredmanah
05:40angermanso I have a set of parentesis too many
05:40hiredmanthis is in a macro yes?
05:40angermanno
05:41hiredmanweird
05:41hiredmanok
05:41hiredmanwell,
05:41angermanbut I guess I could put that map into a macro
05:42angermanI've to admit I'm quite new to clojure and haven't done any lisp aside from some elisp ...
05:43hiredmanyou seem to be constructing a list, is that want you want to do?
05:43Fossi1,(apply doto (String. "X") '((.toString) (.toString))
05:43clojurebotEOF while reading
05:44Fossi1,(apply doto (String. "X") '((.toString) (.toString)))
05:44clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Malformed member expression, expecting (.member target ...)
05:44hiredmanFossi1: doto is a special form
05:44hiredmanor a macro
05:44Fossi1yeah, that's why i wondered
05:44hiredmananyway, it is not applyable
05:44hiredmanbut his example code just contructs a list and does not execute anything
05:45hiredmanwhich is just weird
05:46angermanhow would it be done in a more lisp like way?
05:46Fossi1ah, damn you laziness and side-efects
05:46hiredman,(map (fn [[op key val]] `(.addFilter ~(name key) ~(op {:a 1 :b 2}) ~val)) [[:a :b :c] [:e :f :g]])
05:46clojurebot((.addFilter "b" 1 :c) (.addFilter "f" nil :g))
05:47angermanhiredman: exactly.
05:47hiredman,(-> (map (fn [[op key val]] `(.addFilter ~(name key) ~(op {:a 1 :b 2}) ~val)) [[:a :b :c] [:e :f :g]]) (conj '(doto (Query. "X")) (conj 'doto))
05:47clojurebotEOF while reading
05:47hiredman,(-> (map (fn [[op key val]] `(.addFilter ~(name key) ~(op {:a 1 :b 2}) ~val)) [[:a :b :c] [:e :f :g]]) (conj '(doto (Query. "X")) (conj 'doto)))
05:47clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$conj
05:48hiredmanbah
05:48hiredman,(-> (map (fn [[op key val]] `(.addFilter ~(name key) ~(op {:a 1 :b 2}) ~val)) [[:a :b :c] [:e :f :g]]) (conj '(doto (Query. "X"))) (conj 'doto))
05:48clojurebot(doto (doto (Query. "X")) (.addFilter "b" 1 :c) (.addFilter "f" nil :g))
05:48hiredman,(-> (map (fn [[op key val]] `(.addFilter ~(name key) ~(op {:a 1 :b 2}) ~val)) [[:a :b :c] [:e :f :g]]) (conj '(Query. "X")) (conj 'doto))
05:48clojurebot(doto (Query. "X") (.addFilter "b" 1 :c) (.addFilter "f" nil :g))
05:48hiredmangenerating something like that outside of a macro is just weird
05:49hiredmangenerally a macro would generate a structure like that in place of a call to a macro
05:49angermanhiredman: I tried to wrap the generation of the list into a macro ... but I failed ...
05:49hiredmanthen it would get evaluated
05:49hiredmanI dunno if you want a macro
05:49hiredmanI have no idea what you are doing
05:49angermanwell I have this (Query. "X") object
05:50angermanto which I want to apply the .addFilter methods.
05:50hiredmanwell
05:50angermanand I want to hand in something like (and (= :key1 "value1") (= :key2 "value2))
05:50Fossi1sounds like a job for a macro to me
05:50hiredmanare you planning to then call eval on this?
05:51angermanI've looked at clojureql and came as far as breaking it into the ((= :key1 "value1) (= :key2 "value2"))
05:52angermanhiredman: not directly. I just intend to return the Query object
05:52hiredmanangerman: but the filter methods will not be called
05:52hiredmanthe result will be that datastructure
05:52hiredmana literal list
05:53hiredman'(doto (Query. "X") …
05:53angermanhiredman: yes that's why I though generating the literal list (.addFilter ...) (.addFilter ...) would be fine if I put them into arguments to the (doto (Query. "X") <here>)
05:53hiredmanno
05:53hiredmanno
05:54hiredmanno
05:54Fossi1i think he got your point ;D
05:55hiredmana macro might be what you want, but as confused as confused as you apear to be about runtime vs. compiletime I don't think writing macros is a good idea
05:56hiredmanI kind of doubt a macro is what you want anyway, if you are trying to generate .addFilter calls based on information only around at runtime, then a macro won't work
05:58hiredmanyour best bet is just to loop over your set of arguments to .addFilter
05:58kylesmithI have a security/sandboxing question. I wrote a dsl for a 'database' application. I wrote the dsl in such a way to allow arbitrary user code. Is there a way to sandbox user code running on my server? The alternative is to transfer the data to the user and let them bork their own machine, but even compressed, it would be in the range of 100MB. Thoughts?
05:59hiredmankylesmith: well, that sounds horrible
05:59hiredman~sandbox
05:59clojurebotsandbox is http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html
05:59hiredmanhave fun
05:59angermanhiredman: thanks and sorry. I'll try to loop over it
06:00hiredmannothing to applogize for
06:00hiredmanactually, use for and dorun or doall
06:01hiredman(for [[op key val] specs] (.addFilter query-object (name key) (op *filters*) val))
06:02hiredmanyou will need to wrap it in dorun or doall because for is lazy
06:03kylesmithhiredman: that looks like more than I need. Technically, I don't need full, arbitrary code. I might be talking out of my ass, but would creating a simple whitelist of clojure functions and forms work?
06:04Fossi1well, if you whitelist them, why not put them into the dsl in the first place?
06:04hiredmankylesmith: clojure has a lot of nooks and cranies, it might be easier to just write a mini interpreter
06:05kylesmithPerhaps combined with an execution timeout.
06:05hiredmanclojurebot does blacklisting of some forms, but it is possible to get around that as Chouser demostrates over and over
06:06hiredman,(loop [] (recur))
06:06clojurebotExecution Timed Out
06:07hiredmanhttp://github.com/hiredman/clojurebot/blob/52a02ce8dae22034444fa42e6c2f8f4bb9b986b0/hiredman/sandbox.clj clojurebot's sandbox
06:07hiredmanbased on that earlier sandbox url
06:08kylesmithFossi: I could do that, but mainly I just need to do simple things like (let [tmp (a common subexpression)] `[awesome dsl stuff ~(repeat 3 tmp) more awesome stuff])
06:08hiredmankeep in mind it is possible to get clojure's reader to eval stuff, so make sure to read inside the sandbox
06:08kylesmithand the interpreter for my dsl is already getting complicated
06:10hiredman,#=(java.util.ArrayList. '(1 2 3 4))
06:10clojurebot#<ArrayList [quote, (1 2 3 4)]>
06:10hiredmanhaha
06:10hiredmancute
06:10hiredman,#=(java.util.ArrayList. (1 2 3 4))
06:10clojurebot#<ArrayList [1, 2, 3, 4]>
06:13kylesmithokay, so how would I use clojurebot's sandbox? I'm looking at eval-in-box [_string sb-ns], but what is sb-ns? sub-namespace? I assume _string is the user-string to eval
06:14kylesmithhiredman: what sort of devilry is Chouser able to get past this sandbox?
06:15hiredmankylesmith: not past the jvm sandbox
06:15hiredmanjust past the blacklist
06:16kylesmithahhh, that should be fine then
06:16hiredmanthe jvm sandbox stops you from messing with the filesystem, etc
06:17kylesmithyes, exactly. that's all I need.
06:17hiredmansb-ns is either the symbol naming the namespace, or the namespace object where the code will be evaluated
06:17hiredmanyou will also need the example policy file in the root of the clojurebot git repo
06:18kylesmithanything wrong with just using the user namespace?
06:18hiredmanwhich goes either in .java.policy or somehow you tell java where to find it
06:18hiredmankylesmith: nope
06:18hiredman,*ns*
06:18clojurebot#<Namespace sandbox>
06:19kylesmithokay then. I don't need to implement the sandbox right now, but I'll probably be back here asking questions when I do. Thanks.
06:27kylesmithanother question: Do standard code obfuscation tools work with clojure?
06:31rdsrHi all how is the path parameter in the load function need to be specified if I were to all all files under a certain dir?
06:32rdsrwhat I am doing is this (ns a.b.c) (load "./d/")
06:32rdsrdir d contains some clojure files which i want to load
06:32rdsrd is uder the dir b
06:33rdsrs/uder/under/
06:39hiredman,(doc load)
06:39clojurebot"([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise."
06:40hserushow do i assign a function to a map and then evaluate it later?
06:40hiredmanthis is no assignment
06:40hiredmanyou want to put a function in a map?
06:41hserushiredman: yes
06:41hiredmanyou do it the sameway you add any other value to a map
06:41rdsrthks but I the problem is that while (load "./d/some-file") works
06:41hiredman,(assoc {} :a (fn []))
06:41clojurebot{:a #<sandbox$eval__4154$fn__4156 sandbox$eval__4154$fn__4156@1d53bc5>}
06:41rdsrI can't seem to all all the files under dir d
06:41hserushow would i evaluate it later?
06:41hiredmanhserus: how do you call a function?
06:42hserus,((assoc {} :a (fn [])))
06:42clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap
06:42hserus?
06:42hserusi get the same error
06:42hiredmanbecause you are trying to call the map as a function
06:42Fossi1,((:a (assoc {} :a (fn []))))
06:42clojurebotnil
06:42hiredmanyou don't want to call the map as a function
06:42hiredmanyou want to call the function you put into the map as a function
06:42hiredmanso you need to take it out first
06:43hiredmanrdsr: load does not take wild cards, so you will need to roll your own function
06:44rdsroh ok thks
06:44Fossi1rdsr: check find-namespaces or such in contrib
06:44rdsrthks i 'll check that
06:44Fossi1otherwise a filter and a file-seq does the trick pretty ok as well
07:05hiredman,(let [cons (pl λxy λf (f x y)) cdr (pl λc (c λxy x))] (cdr (cons 1 2)))
07:05clojurebot1
07:08Fossi1o_O
07:19Fossi1mapcat is *strange*
07:20Chousukehow so?
07:20Fossi1i understand the concept, but i find it twists my mind more than i can get it to do anything sensefull
07:20Fossi1same with reduce really
07:22Fossi1it's strange. i have this java class that sets a private value if and throws an exception the second time, but in a do, it doesn't blow
07:26ChousukeFossi1: mapcat is just (apply concat (map f coll coll2 coll3 ...))
07:27ChousukeFossi1: so the mapping operation returns a bunch of collections and concat concatenates them.
07:27Fossi1i *know* what it is and how it works
07:28Fossi1that still doesn't help with using it
07:28ChousukeWell, I haven't had much use for it either.
07:28ChousukeI suppose it's useful if you want to map a function that possibly needs to return multiple elements to replace the original
07:29Fossi1it's already cool for reordering things
07:29Fossi1,(mapcat list [1 2] [3 4] [5 6])
07:29clojurebot(1 3 5 2 4 6)
07:29Fossi1or whatever
07:31Chousukereduce is a bit trickier I guess.
07:31Chousukebut it's useful if you have to accumulate something.
07:34Fossi1yeah, that is the easy usecase
07:34Fossi1i just started to use it for other things as well
07:34Fossi1you can like, concat strings or such
07:35hiredman,(pl (↕reduce range $ 10 λxy (+ x y)))
07:35clojurebot45
07:35Fossi1hiredman: what the hell is that stuff? ;D
07:35hiredmanFossi1: (apply str …)
07:35lbjhiredman: What is this multitalented pl macro you did ?
07:35hiredmanfor string concat
07:36lbj~pl?
07:36clojurebotthe repl is holding onto the head of sequences when printing them.
07:36Fossi1hiredman: well, given your 'concat' is a little more complex
07:36Chousukereduce can actually be used to implement map :P
07:36hiredmanerm
07:36Chousukewhich is fun.
07:36hiredmanChousuke: are you sure? I think it is the other way around
07:37hiredman~transform
07:37clojurebottransform is http://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj
07:37Chousuke,((fn [f coll] (reduce (fn [acc x] (conj acc (f x))) [] coll)) [1 2 3 4])
07:37clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--4900$fn
07:37Chousukehmm
07:37hiredmanold version of pl is there
07:38Chousuke,((fn [f coll] (reduce (fn [acc x] (conj acc (f x))) [] coll)) inc [1 2 3 4])
07:38clojurebot[2 3 4 5]
07:40hiredman,(pl (↕reduce range $ 10 '() λxy (conj x (inc y))))
07:40clojurebot(10 9 8 7 6 5 4 3 2 1)
07:40Fossi1"ugh, read the source. this started as a very specific function and turned into a very generic one." <3
07:41hiredmanit's the truth
07:41Chousukehiredman: I can't read that pl stuff at all :P
07:42hiredmanit is mostly just for fun and playing with zippers
07:43hiredmanusing macros + zippers for code transformation is neat
07:44hiredman,(pl (↕reduce range $ 10 '() λxy (↕conj inc $ y x)))
07:44clojurebot(10 9 8 7 6 5 4 3 2 1)
07:53lbjhiredman: What is that first character called, and how do you make it? (?reduce...
07:55hiredmandunno what it is called
07:56lbjThank you for answering the first of two questions
07:56hiredmanI make it by either pasting it from some place I have it already, or using a abbr I have defined in my .vimrc
08:05Fossi1i'm lost. if i (let [c JavaThing] (do (.changeSomething c) (.useC c))), c should be changed, right? or do i need to ref it or something?
08:06hiredmanfor starts you don't need a do there
08:06hiredmanimplicit do in a let
08:07Fossi1hmmmm. i still like the do as kind of a clear sign that i'm about to use sideeffects
08:11Fossi1but still, the Thing NPEs on me, which could only really happen if it's not the instance i called the first method on
08:14hiredmansprinkle some prns around
08:32Fossi1hmmm. since the introspection on android is a little handicapped, it's kinda hard to tell, since this class has no getter either
08:46Fossi1ouch
08:46Fossi1in my proxy, i defined the method i'm supposedly calling all the time
08:46Fossi1thus shadowing it
08:52Fossi1so, there's the betrayal
08:53Fossi1i can't call super, right?
08:53Fossi1or can i just not call super in protected methods?
08:53Fossi1the docs are a bit ambiguous
09:13Fossi1~gen-class
09:13clojurebotNo, Fossi1, you want gen-interface + proxy
09:13Fossi1~gen-interface
09:13clojurebotGabh mo leithscéal?
09:13Fossi1~gen-interface
09:13clojurebotGabh mo leithscéal?
09:24Fossi1any hints on correct gen-interface usage?
09:48Fossi1phew
09:53Fossi1so now i'm back to the same problem i had with gen-class
09:54Fossi1how do you use these generates interfaces and how do you infer the right build order?
09:55Fossi1new twist to it: "Exception in thread "main" java.lang.NoClassDefFoundError: java/lang/"
10:00Fossi1i mean writing interfaces in java is not that bad, but that can't be *it*, can it?
10:07ChousukeI'm not even sure if gen-interface works anymore :P
10:07Chousukeit sounds like something pre-AOT
10:10Fossi1thing is: i have this proxied object that gets run in another thread and i can send it a message, but without another interface, i don't have a method of mine to call
10:14StartsWithKlisppaste8: help
10:14lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
10:14rhickeyChousuke: gen-interface should work fine
10:15lisppaste8StartsWithK pasted "gen-interface and proxy" at http://paste.lisp.org/display/84226
10:17StartsWithKis this what you are trying to do?
10:18Fossi1yeah, something like that
10:19Fossi1just that i get the above exception on compile and emacs naturally can't find the class at all
10:19StartsWithKaot step is ok?
10:19StartsWithKyou can see in your 'classes' directory com/exmaple/IFoo.class
10:20Fossi1yes
10:21Fossi1let me remove them and try again to be sure
10:23Fossi1actually, what are you supposed to put into that macro for no return value?
10:23StartsWithK[methodName [] void]
10:23Fossi1ah, void works much better than nil :)
10:24StartsWithKtakes no args and returns nothing
10:24blbrown_winI am assuming Java doesn't have a similar syntax to this: a = 1e6
10:24Fossi1now it's compiling again
10:24Fossi1thanks
10:25Fossi1still, the precompile step is kinda unnice. now i have to tell emacs about the build dir as well
10:27StartsWithKblbrown_win: http://is.gd/1NxbM
10:30blbrown_winStartsWithK, you are one of those. RTFM.
10:30blbrown_winlooks like this might work. double d2 = 1.234e2
10:44achim`hi! is there a way to create a chunk from a java array?
10:44rhickeynaming question for the day - what to name the things created by new new?
10:45rhickeyachim`: clojure.lang.ArrayChunk
10:51achim`rhickey: thanks! i wasn't sure whether that's part of the official api
10:54rhickeyachim`: It's not, why do you need it?
10:59achim`rhickey: it would be handy for I/O: reading bursts of bytes into arrays, but hiding the array stuff. i have been doing this with seqs of arrays and was wondering whether it would work with chunked seqs
11:02achim`but ArrayChunk doesn't seem to work with primitive arrays
11:03rhickeyachim`: just going to ask that
11:04rhickeyso, you could emulate what it does, but if you are trying to avoid boxing the bytes you might be better off with seqs of arrays for now
11:22AWizzArdanyone here used javacc for lexing purposes + Clojure?
11:24achim`rhickey: you're right. i just started looking at chunked seqs. also, there's no way to get to the array, once wrapped in an ArrayChunk (which makes sense in terms of immutability, of course)
11:24achim`sadly, java doesn't have readonly arrays
11:32AWizzArdis there a way similar to Java to check for a char being between a range? (if (<= 65 my-char 77) ...)
11:32clojurebotfor is not used enough
11:32rhickeyAWizzArd: coerce to int
11:32AWizzArdoki
11:32rhickey,(int \A)
11:32clojurebot65
12:30rhickeyobj as special form name for new new?
12:30rhickey(obj this [bases] [super-ctor-args]
12:30rhickey :volatile [some captured names]
12:30rhickey :other-flags tbd
12:30rhickey (method1 [] ...)
12:30rhickey (method2 [] ...))
12:31rhickeythis-name, :volatile, :other-flags all optional
12:32rhickeypronunciation is a bit rough, objet like in French?
12:36rottcoddwould object be too long?
12:37rhickeyrottcodd: not necessarily
12:48arbschtobject feels more natural than obj
12:48rhickeycould also be new:
12:48rhickey(new [bases] [super-ctor-args]
12:48rhickey :as this
12:48rhickey :volatile [some captured names]
12:48rhickey :other-flags tbd
12:48rhickey (method1 [] ...)
12:48rhickey (method2 [] ...))
12:49Chousukenot necessarily a breaking change, is it?
12:50rhickeythe bigger question is what to call what this creates? it is a little like an anonymous inner class (not quite) and a little like a closure (will eventually be used to implement fn)
12:50rhickeyChousuke: new like that is not a breaking change
12:50ChousukeClassure? :P
12:51arbscht(being this [..] ...)
12:51arbschtcall it a "being"
12:52ChousukeAny reason you're not making the :options just a simple map? would be easier to work with from macros and all :/
13:04achim`i like obj, its creations being objs. one new concept, one new name. overloading new has its benefits (both make instances), but might also be more confusing
13:51lbj1How many bugs have been found in Core this year ?
14:12achim`hmmm ... probably a stupid question: is there a way to not retain head in a function that's passed a lazy seq and has to consume it entirely?
14:13lbj1You mean like dorun ?
14:17Chousukeit shouldn't retain the head if you don't explicitly hold on to it when you do recur :P
14:25achim`lisppaste8: url
14:25lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
14:26lisppaste8achim pasted "off with its head" at http://paste.lisp.org/display/84232
14:27achim`i basically need "doseq-and-forget" :)
14:30maaclWhat is the easiest way of doing simple job scheduling (e.g. call a function every 10 min) in Clojure? I looked at http://bit.ly/gOgRx but this seems a little elaborate for something as simple.
14:31Fossi1i was about to say quartz
14:32Fossi1also, the job is pretty much already done, so why not use that?
14:32lbj1maacl: Depends on the job - For some tasks a worker-thread which calls it self with a given delay will suffice
14:33achim`maacl: Executors/newScheduledThreadPool
14:33achim`maacl: and then (.scheduleAtFixedRate ...)
14:33achim`maacl: Executors is in java.util.concurrent
14:36maaclah - thanks for the feedback - will give Executors a look
14:44Fossi1man, i suck at designing 'stateless' systems ;D
14:45Fossi1i'm trying to get some design into things upfront, but i'm somehow captured in all those OO patterns
14:45Fossi1maybe i shouldn't worry about it at all and see where i arrive
14:49lbj1Which categories of programming would you normally argue are best suited for FP ?
14:58achim`is this correct?: when a function takes a lazy seq argument and has to consume it entirely to produce the result, the only way to not retain head is to recur without looping?
15:23krumholt_is there a good book about functional software design or functional algorithm design?
15:26ataggartrich put up an amazon bookshelf of the stuff he read when designing clojure
15:27ataggartmight be something in there
15:27ataggartof course there's SICP if it's really new to you
15:27ataggartlike it is for me
15:28lbj1Which categories of programming would you normally argue are best suited for FP ?
15:28krumholt_ataggart, ok thanks.
15:28ataggartfound it
15:28ataggarthttp://www.amazon.com/gp/richpub/listmania/fullview/R3LG3ZBZS4GCTH/ref=cm_pdp_lm_title_1
15:28krumholt_oh fantastic thanks
15:28Fossi1lbj1: i don't get what that means
15:29ataggartlbj1: any where you can, I would think
15:29lbj1Fossi1: Would you say that FP is really suited for game development for instance? data parsers? etc..?
15:29ataggartall of the above
15:30ataggartit's lke asking what OO is best for
15:30ataggartso long as you're not having to write machine code, it's really up to you
15:31lbj1I'm not sure thats right, but ok, thats one view
15:31duck1123The only thing that FP really isn't good for is code you want to be brittle and hard to test.
15:31ataggartwell if you have an opinion, feel free to voice it
15:31Fossi1from my opinion just now, game coding is a little weird
15:31ataggartduck1123: lol
15:32Fossi1so many side effects
15:32ataggartyes, side-effect heavy, or lots of state manipulation
15:32Fossi1but then again, every serious computer program has lots of in-/ and outputs
15:32ataggartbut I read a neat article making the argument that there isn't as much of that as one initially supposes
15:32ataggartlet me see if I can find it
15:33Fossi1that'd be cool
15:33ataggarthttp://prog21.dadgum.com/23.html
15:33ataggartthat
15:33Fossi1i guess i'll have a look at some functional game engines on the way as well
15:33ataggartas Rich and others have said: a program without side-effects can only heat up your computer
15:34duck1123I think the snake game is a good example of how you would think to have a lot of mutable state, but if you think about the problems right, there is very little
15:34lbj1How little?
15:34ataggartyup, I'm glad he put that in the book
15:34Fossi1i guess it comes down to: have a loop, modify game state, push that into the rendering
15:34ataggartlbj1: have you read the clojure book yet?
15:34hiredmanhttp://www.st.cs.uni-sb.de/edu/seminare/2005/advanced-fp/docs/sweeny.pdf <-- "The Next Mainstream Programming Languages: A Game Developer's Perspective"
15:34lbj1ataggart: No, and I dont plan to
15:35duck1123I think like < 10% of the code dealt with mutation
15:35duck1123my book is in the other room
15:36Fossi1thanks hiredman
15:37ataggartIt'd be really nice if we could collect these links on the clojure site somewhere
15:38hiredmanclojurebot: delicious
15:38clojurebotdelicious is http://delicious.com/clojurebot
15:38hiredmanclojurebot posts all urls from the channel, tagged with nick+channel
15:38ataggartah excellent
15:38duck1123it would be cool if clojurebot did something like the bot in #swig where he could track all the url's mentioned in chat
15:38ataggartlol
15:38duck1123nvm then
15:57Fossi1too much haskell for me :D
15:58Fossi1but interesting nevertheless
15:58lbj1Very
16:33Fossi1i sthe idiomatic way to add a single element to a seq: ,(concat '(1 2 3) '(4))?
16:34hiredmanthere is no idomatic way to add to the tail of a seq
16:34hiredmanyou can do it, but it is just not how the structure is designed to be used
16:38ataggartor you can rephrase "add to the tail" to "start returning this other seqence when the first one is empty"
16:41Fossi1actually, i just want a smallish vector or something with a special value at the end
16:41ataggartah, then use vec
16:42Fossi1,(vector '(1 2 3) 4)
16:42clojurebot[(1 2 3) 4]
16:42ataggart(vec '(1 2 3))
16:43ataggart,(vec '(1 2 3))
16:43clojurebot[1 2 3]
16:43Fossi1and then?
16:43ataggart(conj (vec '(1 2 3)) 4)
16:43ataggart,(conj (vec '(1 2 3)) 4)
16:43clojurebot[1 2 3 4]
16:43Fossi1ah, conj
16:43ataggartconj on a vector adds at the end
16:44Fossi1but is it guaranteed that will always be that way?
16:44ataggartyup
16:44ataggart(doc conj)
16:44clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
16:44ataggart,(doc conj)
16:44clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
16:44ataggartguess the detail is elsewhere
16:44ataggartbut yes, vectors at the end, lists at the head
16:44Fossi1guess so as well
16:44ataggart,(conj '(1 2 3) 4)
16:44clojurebot(4 1 2 3)
16:45Fossi1because i looked for that for a while
16:45Fossi1yes sir, my app works
16:46Fossi1i can now display a colored screen and make it change color randomly on touch
16:46Fossi1a small step for a game, a big step for me ;D
16:46ataggartexcellent
16:46ataggart"touch"?
16:46Fossi1clojure on android with opengles
16:47ataggartah neat
16:47Fossi1took a while to set up, but there was quite a base to start from as well
16:48Fossi1or at least some bits n pieces :)
16:48Fossi1bedtime now, i need to get up at 7 and code some more :D
16:48RaynesOne small step for games, one huge step for Clojurians.
16:52Anniepoowhoo hoo - Clojure on Android?
16:53AnniepooFossi, how did this miracle come about?
17:00Chouserrhickey: I'm curious if you'd entertain syntax for newnew that avoids the sub-form (foo ...) when defining foo
17:00Chouserproxy is currently one of the few places that (foo ...) means anything other than invoking foo.
17:02Chousermaybe, for example: (new [AFn] [] (defm invoke [a b] ...))
17:06hiredmanthat would be the only place where def something doesn't result in a modification to global names
17:06Chouserfwiw, I think I prefer 'new' to 'obj'. "Use 'new' to create a 'Clojure object', which is Java object but whose methods can close over locals..."
17:07Chouserhiredman: hm... Well, I'm not sold on a particular name, but I think any name would be nice compared to no name at all.
17:07Chouser(method invoke [a b] ...)
19:59wulfmax?
19:59wulfmaxhelp
20:00durka42?
20:00wulfmaxsorry,typo
21:02mebaran151,(+ 1 1)
21:02clojurebot2
21:02mebaran151,(defn xyz [] (+ 1 1))
21:02clojurebotDENIED
21:02mebaran151,((defn xyz [] (+ 1 1)))
21:02clojurebotDENIED
21:02mebaran151,((fn xyz [] (+ 1 1)))
21:02clojurebot2
21:06mebaran151do fn's allow for names only to enable simpler recursion
21:07hiredmanthey are useful in a number of situations
21:07hiredmanlike if you have an otherwise anonymous function that you send to an agent that wants to keep sending ittself off to an agent
21:07hiredmana lazy-seq generated by a fn