#clojure logs

2009-04-12

02:35cp2lib names inside prefix lists must not contain periods
02:35cp2whats this about?
02:35cp2from
02:35cp2(read-classfile-header (DataInputStream. (FileInputStream. "../t.class")))
02:36hiredman,(doc read-classfile-header)
02:36cp2thats my own function
02:36cp2but, shouldnt matter
02:36cp2because it worked before
02:36hiredmanoh no
02:36hiredmanclojurebot
02:36cp2:(
02:37cp2i see
02:37cp2load-lib is throwing it
02:37cp2 (throw-if (and prefix (pos? (.indexOf (name lib) (int \.))))
02:37cp2 "lib names inside prefix lists must not contain periods")
02:37cp2the hell
02:37cp2oh
02:37cp2oops
02:38cp2mucked up a vector in (ns .... (:use [.....
02:39hiredmanerp
02:40hiredman~botsnack
02:40clojurebotthanks; that was delicious. (nom nom nom)
03:43durka42is my answer to http://code.google.com/p/clojure/issues/detail?id=104 nonsense?
03:53hiredmanit convinced me
04:36Lau_of_DKTop of the morning gents
07:04Lau_of_DKAnybody suffered from this? "org.lwjgl.opengl.OpenGLException: Cannot use Buffers when Pixel Unpack Buffer Object is enabled (NO_SOURCE_FILE:0)"
07:05Lau_of_DKIts thrown when I try to use createWindow - Its worked flawlessly for ages, but after a reinstall of my OS, it now borks
07:13hiredmanhttp://lwjgl.org/forum/index.php?topic=2537.0%3Bwap2
07:15hiredmanhttp://www.jmonkeyengine.com/jmeforum/index.php?action=printpage%3Btopic=6047.0
07:16hiredmanthe second link looks helpful
07:25Lau_of_DKThanks hiredman
07:25Lau_of_DKI think it might be related to the latest nvidia driver, it doesnt give permissions to the video group, do access /dev/nvidiactl
07:27Lau_of_DKhaha, same conclusion they reached
07:27Lau_of_DKThanks hiredman, you hit it spot on
07:27hiredmanglad it worked
07:28Lau_of_DKIts not working yet, but Im in the right zone now
07:29Lau_of_DKgotta restart x, brb
07:33Lau_of_DKOk - something worth noting about LinuxMint - for some reason it doesnt add your primary user to 'video' when creating it - and for some reason, it gets compiz going even w/o....
07:34Lau_of_DK(working now)
07:37Lau_of_DKhey rhickey , long time no see
07:37rhickeygood morning
07:46Lau_of_DKSo rhickey , have you got Gerald J hacking away in Clojure yet?
07:46rhickeynot yet
07:47Lau_of_DKk
09:53leafwsomeone's at work
09:56hiredman:D
09:56hiredman*read-eval*
10:58cconstantineis there a way to do named optional arguments?
11:02singhvyes.. you do it by giving your function multiple bodies. see the code sample here: http://clojure.org/special_forms
11:10cconstantineso, it looks like to do optional named arugments the caller needs to pass a map...
11:11cconstantineam I reading that right?
11:17Carkconstantine : that's right
11:18cconstantinethats.... slightly awkward
11:20Carkwould you rather have this be done behind the scene ?
11:20Carkand pay for the cost of it on every function ?
11:20lisppaste8cconstantine pasted "testing optional arguments" at http://paste.lisp.org/display/78450
11:21cconstantineI believe in CL it's done as a macro, so the cost is paid at compile-time
11:21cconstantinemy paste doesn't work for some reason
11:21singhvthe map way is one way to do it. but by multiple bodies i meant something else:
11:21dliebkeMost of the functions I write have optional named arguments without the caller supplying a map. I make the map myself using (apply assoc {} options), where the function signature is something like [x y & options]. so the caller can just call (foo x y :opt1 1 :opt2 2)
11:21lisppaste8cconstantine annotated #78450 "untitled" at http://paste.lisp.org/display/78450#1
11:22lisppaste8cark annotated #78450 "untitled" at http://paste.lisp.org/display/78450#2
11:22cconstantineoh right
11:22singhvit's when you give your function multiple implementations each with different argument lists, and have some of them call other versions
11:22Carkconstantine : how does CL know on the call site ?
11:23cconstantineCark: not sure, I might be wrong now that I think about it
11:23singhvsorry, you said *named* optional arguments - ignore me.
11:23lisppaste8cark annotated #78450 "untitled" at http://paste.lisp.org/display/78450#3
11:24cconstantinedliebke: that sounds like exactly what I need... could you show me?
11:26cconstantinesinghv: hehe, yeah I can get optional arguments just fine... I have 3 arguments. 1 is required, the other two are optional
11:26cconstantineTo be able to specify 0, 1 or 2 of the optional arguments I need to name them
11:28Carkyou could go like this : (fn [required & optionals] ... then check that every odd argument is the correct name in your function
11:28Carkbut it isn't as good for editors as the map solution
11:28lisppaste8dliebke annotated #78450 "optional named arguments" at http://paste.lisp.org/display/78450#4
11:30cconstantinedliebke: ok, so you convert the &optional to a map, then pull out keys
11:30dliebkeyes
11:32Carkbut slime won't show you the argument list that way
11:34dliebketrue. So, I write elaborate documentation strings for my functions showing the available options and their default values (but I need to do that anyway)
11:35Carkthis is only to avoid the braces in your call site ?
11:37dliebkeyes, I writing a R-like statistical library, and I want my function calls to be as close to the original R syntax as possible.
11:38cconstantinehttp://groups.google.com/group/clojure/msg/51bb53ca077154f8
11:46cconstantineIt seems like the arguments passed from the caller could be resolved at compile-time, making named optional arguments just as fast as a normal call
11:51cconstantineHow do I do destructuring in an optional argument?
11:51cconstantinenm
11:55Lau_of_DKuser> (defn foo [a & options]
11:55Lau_of_DK (let [[b c d] options]
11:55Lau_of_DK (map println [a b c d])))
11:55Lau_of_DKYou mean like that?
11:55cconstantinethat kidna works, but that doesn't give me reording
11:55Lau_of_DKYou asked about destructuring?
11:56cconstantineI was thinking an arg-list more like: [req {a :a b :b c :c :or {a 1 b 2 c 3}}]
11:56cconstantineand the map can be optional through another arg-list without it
11:57cconstantineso a call would look like: (some-func a {:a 1})
11:58Lau_of_DKI'd say it depends on the actual case - its not really a matter of destructuring
11:58cconstantinethat is a destructuring
11:59cconstantineit works, but has some { }s in the call
13:17Cark" <cconstantine> It seems like the arguments passed from the caller could be resolved at compile-time" what if you change the definition of the called function after the call site is compiled ?
13:30cconstantineuh, don't do that?
13:31cconstantinewhat happens if you change the definition of the called function to add an argument?
13:31cconstantineor remove an argument
13:33Carkthat's lisp we're doing here ... very dynamic
13:33Carkand one of the reasons of named optional arguments is just that, so that you can add argument
13:33Carks
13:35Carknow if your call site is compiled so that it "magically" knows the named arguments, you'de better make sure the algorithm takes into account the possibility that some arguments might be added, or the order of arguments might change
13:35Carkso in the end you keep the runtime cost
13:36Carkyou still need to look the name up at runtime
13:38cconstantineso what happens if you add an argument to a function and the call sites aren't recompiled?
13:38cconstantineI'm not saying it isn't a problem, but I'm not seeing why it isn't a problem for regular arguments
13:39Carkit's a problmem for regular arguments
13:39Carknot so for optional arguments
13:39cconstantinebut it isn't a problem for optional arguments through a &rest because that's passed as a list
13:39Carkright
13:43cconstantineso why not just have it be a runtime failure when the arguments change same as with regular non-optional arguments?
13:44Carkone of the purposes of named optional arguments is precisely to let you add them or change their position without causing any problem
13:44Carkthat's in my opinion anyways
13:46cconstantineah, I just want to be able to have a a set of arguments that aren't required
13:47cconstantineif they aren't named you have to have preceding arguments in the argument list
13:47Carkthere is a construct in the language to do what you want, and it's stricly more powerfull than what you need
13:47Carkso what's the trouble ?
13:48cconstantineI guess the trouble is I don't know it :)
13:48Carkwell we showed that to you earlier
13:49Lau_of_DKclojurebot, seen technomancy?
13:49cconstantineoptionally passing in a map?
13:49Lau_of_DK~seen technomancy?
13:49clojurebotno, I have not seen technomancy
13:49Carkconstantine : that's a way to do it yes
13:50cconstantineCark: that (and the other options) is close enough, but not exactly what I want
13:50Carkyou want CL style named parameters
13:51Carkright ?
13:51cconstantinebasically yeah.
13:52Carkyou could make your own defn macro if that's absolutely what you want
13:52Carkbut it seems a lot of work for something that's already there
13:52Carki would argue that the clojure way is best
13:52Carkyou have two orthogonal concepts
13:52cconstantineeh. We can disagree because the clojure way works :)
13:53Carkon concept is destructuring
13:53Carkand the other one is function call
13:53Carkthey're kept separate
13:53cconstantineright
13:54Carkin CL, you have destructuring (destructuring-bind) and destructuring arg lists
13:54Carkthat's mudying the waters !
13:55cconstantineif I didn't want muddy waters I'd be in scheme... but I want to get stuff done
13:56Carkright, so why not use the existing facilities ?
13:57cconstantineit forces me to either redefine how to define functions, or rewrite a pattern every time I want to use it
13:58Carkby pattern ? you mean the curly braces
13:58Cark?
13:58cconstantineright now, I'm just using the pattern, and forcing callers to pass in a { ... } for optional arguments
13:58cconstantinethere is a call-side pattern (the curly braces) and a caller side pattern (accepting no options and passing in a {}
13:59cconstantines/caller/callee
14:00Carkin order to avoid the problem with calers not needing any argument you can define you function like this : (denf bleh ([required] (bleh required {})) ([required {:keys [a b c]}] ....))
14:00clojurebotthis is not a bug
14:01cconstantineright, that's a pattern
14:01cconstantineit works, but it's something that could be standardized and abtracted away with a standard macro
14:01Carkwell then make a macro and be done with it =P
14:04cconstantine might, but it would be nice to have to macro extend to the call-site and do it there.
14:04cconstantineI'll have to think it through a bit more, and try to get it into clojure.contrib
14:05Carkfirst you would need to change the way function calls work
14:05Carkthat cannot be done with a library i think
14:05Carksecond i don't think that's a good idea
14:06cconstantineif the macro (defn-with-optional-named-arguments some-func [ ...]) made a macro named some-func that called a gensymed func
14:06cconstantineit could even wrapp the macro in a (var ...) to make it passable
14:07Carkthen you can't map it anymore
14:07cconstantineall the call-site macro would do is convert a (some-funct a) to a (some-funct a {})
14:07cconstantinecan't map it?
14:07cconstantineoh, like (map ...)
14:08Carkyes
14:08cconstantineI believe there is a way to do that (to be able to pass 'or' and 'and')
14:09Cark#(or %1 bleh)
14:09Carkthis goes to show there are troubles anyways
14:10cconstantineno, I mean a simpler way
14:12cconstantineyeah, it's (var macro)
14:14cconstantineeh, the more I think about it the more this has problems with functions used as higher order funcs
14:15cconstantine'this' being a macro that makes a macro
14:36Lau_of_DKcconstantine, Im sorry I didnt see your question before now http://failblog.files.wordpress.com/2009/02/fail-owned-ownership-fail.jpg?w=500&amp;h=112 ... Did you get this resolved?
14:36cconstantinemostly yeah
14:37Lau_of_DKGood
15:17durka42 ,(var or)
15:18yasonWhen moving data around like in tuples or small lists, is it more idiomatic to use vectors or lists?
15:18durka42,(var or)
15:18clojurebot#'clojure.core/or
15:21durka42i might use a vector
15:21durka42depends on what you're doing with it though
15:22yasondurka42: vectors seem more natural since there's better syntax for creating them
15:23yasondurka42: mostly they'll just end up in some other place, probably deconstructed into variables
15:24yasonlists and dotted pairs are just more traditional in lisps -- might not hold in clojure though :)
15:25yasonwhen would it be more sensible to use lists?
15:25durka42well, vectors are faster for random access
15:26durka42lists are better for appending and prepending
15:26yasonso new copies of vectors are made when something is added in them?
15:27durka42well, yes and no
15:27durka42data structures are immutable
15:27durka42so you always get a "new" one
15:27durka42but it will be mostly copy-on-write
15:27yason(as opposed to lists consed together from new heads and old tails)
15:28Chouservectors are faster for appending, lists faster for prepending
15:28durka42http://clojure.org/data_structures
15:28Chouseryason: for your general question, I think vectors are most often slightly more idiomatic
15:29yasonChouser: that makes sense, you can extend vectors easily and you can (cons head old-list) more naturally. So is there any other essential differences besides random access and prepending/appending?
15:30yasonChouser: Ok, I guess I'll go with vectors then. Just wanted to check I'm not abusing them somehow. I'm just used to Lisps where vectors are maybe less generic than lists.
15:33yasonAnyway, I think Clojure is pretty damn great and programming with it is great fun. I've also realised that JVM is actually rather nice as soon as you stick a real language onto it, which I would probably have missed without Clojure. :)
16:09cconstantineI've got a weird problem... pasting
16:10lisppaste8cconstantine pasted "cconstantine" at http://paste.lisp.org/display/78466
16:29digashhow does one destructures Map into key values?
16:29digash,(let [[key val] {:a "a" :b "b"}] [key val])
16:29clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap
16:30digashoops, ignore my stupidity.
16:31digashi've obviously wanted a doseq or first.
16:31digash,(let [[key val] (first {:a "a" :b "b"})] [key val])
16:31clojurebot[:a "a"]
18:03cconstantineWho do I talk to for a code-review and possible inclusion in clojure-contrib?
18:20danlarkinthe mailing list
18:54RaynesHas anyone noticed how massively boring Scala is? :|
18:55danlarkinif you don't have anything good to say...
18:56hiredmanyou know #scala had a vote and decided not to log the channel
18:56hiredmanbizzare
18:57digashMy coworker bought the Scala book and the firs mention of concurrency is somewhere after p700.
19:04gnuvince_I find that most statically typed languages are much more complex than dynamic ones.
19:04gnuvince_Compare Clojure, Python, Smalltalk and Factor to Scala, C++, Java and Haskell and tell me the first four are not much simpler than the latter 4.
19:07digash"Our main goal is to ensure race safety with a type system that's simple and expressive enough to be deployed in production systems by normal users."
19:07digash-- http://lamp.epfl.ch/~phaller/uniquerefs/
19:07digashI feel that I am not "normal user".
19:08Raynesdanlarkin: Oh, it's good enough to make me hate Java even more, but it's still boring.
19:09gnuvince_Raynes: I agree that Scala doesn't seem to have the "oomph" effect of Clojure or Haskell.
19:15cp218:04 < gnuvince_> Compare Clojure, Python, Smalltalk and Factor to Scala, C++, Java and Haskell and tell me the first four are not much simpler than the latter 4.
19:16cp2oh yeah
19:16cp2definitely
19:16cp2i find it funny, all of my friends who are using c++, java, tell me 'oh clojure is so complex because of all the parentheses' etc
19:17gnuvince_There's something about knowing all the quirks and exceptions of C++ that people find so appealing.
19:17cp2heh
19:17gnuvince_"Wow, you must really be a good programmer if you know what a private virtual static friend function is!"
19:20RaynesAnyone who says Clojure is complex or bad because of the parentheses needs to be killed. :|
19:20hiredmanthats kind of harsh
19:20danlarkinyeah I don't really get where your anger comes from Raynes
19:20hiredmanmaybe shipped off to a re-education camp
19:22RaynesWell, not literally...
19:29StartsWithKanyone used Cloak to automate tasks from clojure?
20:09RaynesI want to learn Forth.
20:10pstickneso learn it :)
21:27Chouserrhickey: spent any more time on self-hosted clojure?
21:34rhickeyChouser: only in thinking about namespaces and modularity. I'm trying to get all known issues on the table in looking at self-hosting. A big one is the mismatch between namespaces and the way Java and especially Java module systems (OSGi etc) look at things
21:34Chouserok
21:34rhickeythere's a fundamental conflict between all-ns and modularity
21:35Chouserfor better modularity you'd need some namespaces to be visible to less that the whole clojure world?
21:35rhickeyyes, and to track class visibility in general
21:36rhickeyit dovetails with classloader issues, which are still a pain
21:36Chouserindeed
21:37rhickeythe fundamental problem is you can't do classForName on behalf of someone else, i.e. in library code
21:38Chouserwhere "someone else" is a different modules of the OSGi variety? Or where "someone else" is any other lib?
21:40rhickeyIt comes into play with regular classloaders - i.e. if a child classloader can see something Clojure's classloader can't, it can't successfully import it, because it is library code in Clojure that calls classforname
21:41Chouserok, and the jvm is paying attention to the class that owns the method doing the actual classForName call?
21:42rhickeyYou can use context classloaders, but then you need to know that is happening, and most of the module systems don't. They are presuming the immediate consumer calls Class.forName, which does a stack walk to find the classloader of the caller (which could be a bundle classloader) and all works fine - try to proxy the forName call and it fails
21:42rhickeyThe bottom line is namespaces need to be found the same way classes are found
21:43rhickeySo, my thinking is a connection between com.my.ns and com.my.ns$Namespace.value, where the latter is a clojure.lang.Namespace
21:44rhickeyget rid of the master namespaces collection
21:44rhickeyin a modular system, namespaces should be no more fully enumerable than classes - i.e. not at all
21:45Chouserinteresting
21:45Chouserif I've got the a namespace object, getting to the package where all its classes are defined is easy
21:46rhickeythis will provide many benefits, including the ability to load most of Clojure just once and share it with many ephemeral loading contexts, be that web apps, or NetKernel stuff, or OSGi...
21:47Chouserand for any given namespace name, finding the namespace object is also simple -- computed both ways then, right, no further connection needed?
21:47rhickeymaking namespaces align with classloader and module visibility is key
21:48rhickeyChouser: right, namespace-name leads to class leads to namespace object, not sure about the need to go the other way
21:50rhickeythis obviously impacts the compiler - it can't presume a single global namespace world, and will need to generate code that will leverage the visibility it will have when loaded (i.e. it may be able to see things clojure.lang can't)
21:50clojurebotthis is not a bug
21:51RaynesI wish they made bags of nothing but buttered popcorn jelly beans. :\
21:53ChouserRaynes: http://www.jellybelly.com/Shop/ProductDetail.aspx?ProductID=40137&amp;ProductGroup=Buttered_Popcorn
21:53RaynesO.O
21:53Chouserthat's a case of 24 bags, 3.5 oz per bag. Should hold you for a while.
21:53RaynesChouser: You're my hero. hiredman: You're off the hook.
21:58Chouserrhickey: does that mean that any runtime reflection would have to be done differently?
21:59Chouseras in, not in a library that may not be allowed to look at the class being reflected upon?
21:59Chouseror could it examine an instance of Class that's specifically passed in?
22:07lepassiveHi anyone using Enclojure with NetBeans 6.7 ?
22:08rhickeyChouser: I don't think there will be issues there
22:09RaynesI don't think Enclojure supports NetBeans 6.7, but I might be incorrect.
22:09lepassiveRaynes, that's right I can't get it working with 6.7 :(
22:10Rayneslepassive: I believe there is a thread about it on the Enclojure group.
22:12lepassiveRaynes, thanks alot i found the thread
22:13Rayneslepassive: No problem. Good luck.
22:46Mechow does java reference string regex captures?
22:47hiredman$1
22:48hiredman,(.replaceAll "22nd" "(\\d+)nd" "$1ND")
22:48clojurebot"22ND"
22:48Mecthanks, tried \1 and got some bizarre results :D
22:49hiredmanyeah