#clojure logs

2010-06-18

00:02hiredmanactually, it works for me
00:02hiredmanare you using a recent snapshot?
00:16ceptorialdoes anyone recommend a way to decide whether to use (:key map) or (map :key)?
00:35rdsrHi all, on creating a table with a text data type I receive a sqlsyntaxexception
00:35rdsrhere's the gits http://gist.github.com/443235
00:35rdsr*gist
00:35rdsrI'm using the c.c.sql lib
00:36rdsrThe error mesg received is Syntax error: Encountered "" at line 1, column 91.
00:37cemerickhiredman: yeah, it works fine for me everywhere else too. I only created the gist because it sounded like you didn't think finally was supposed to work in conjunction with a recur in the try block.
00:42hiredmanI can't say I am surprised though
00:43rdsrI'm using Derby as my DB
00:43rdsris text datatype not supported in that?
00:44hiredmantry/catch/finally is a linked set of gotos and recur is a goto, so mixing them is bound to be interesting
00:44hiredmanrdsr: I'd check the derby docs
00:44hiredmanhttp://db.apache.org/derby/manuals/reference/sqlj123.html
00:45rdsrthks hiredman, doing that right now
00:46hiredmanman, tail calls will be so much fun
00:47rdsrthks hiredman, I'm using CLOB instead now and it seems to work
01:27zakwilsonclojure.xml/parse can't seem to handle the character \# in a filename.
02:20daakui have this odd issue where `rlwrap clj` gives me reverse-i-search (Ctrl-r) correctly, but it doesn't work (nothing get's triggered) with `rlwrap lein repl` (i'm on a mac, with clojure 1.1) -- anyone have any ideas on why this might be?
02:21daakuhmm.. it seems like `lein repl` actually has it's own readline equivalent
02:26daakuoh, lein 1.2-snapshot has this fixed. cool
03:11daakuis there anything that offers real tab completion (live, not precomputed) in the command line repl?
03:13raekslime in emacs autocompletes vars in the current namespace
03:15daakuraek: i'm not invested enough yet to use/setup/learn emacs :(
03:15wwmorgandaaku: enclojure has decent autocompletion
03:16daakuwwmorgan: is that netbeans only?
03:16wwmorgandaaku: yes
03:17daakui'm a vim user, i guess ideally i'd like to keep the repl separate and keep using my vim/screen setup
03:17raekwas it enclojure that hade something similar to paredit?
03:23daakuinteresting.. enclojure has support for a "standalone repl" mode
05:34cad_from_austintest
05:36cad_from_austinI was hoping for insight into an elusive clojure.contrib.sql problem. I have a read function that works when I load the code into a repl within the defining namespace, but that throws and error when the code is executed from another namespace with (:use defining.namespace). I actually get a jdbc error - check syntax
05:47Fossitest
05:47DarthShrineTest failed.
05:58gerryxiao,(clojure-version)
05:58clojurebot"1.2.0-master-SNAPSHOT"
05:58gerryxiaohello
05:59cad_from_austinI'd appreciate any help on the above, even "you don't understand namespaces"
05:59gerryxiaohow to know whether the number is boxed?
05:59gerryxiao,(let [a 3] (class a))
05:59clojurebotjava.lang.Integer
05:59gerryxiao,(let [a (long 3)] (class a))
05:59clojurebotjava.lang.Long
06:02gerryxiao(defn ^:static fib ^long [^long n] nil)
06:03gerryxiao,(defn ^:static fib ^long [^long n] nil)
06:03clojurebotDENIED
06:15mikemI see some symbols used inside macros which end with a # -- what does that signify?
06:16LauJensenmikem: thats gensym, gives it a unique name in the expansion
06:16mikemLauJensen: ok, that makes sense. thank you!
06:17hoeckcad_from_austin: please paste your code somewhere (and maybe the exception you get)
06:18cad_from_austinMikem: I've actually just now resolved the problem, but have another question
06:18cad_from_austinI wound up just restarting swank. Is there something I should know about copy and pasting files from my source to the repl?
06:20mikemcad_from_austin: I think you meant hoeck :)
06:20hoeckcad_from_austin: basicall not, if the namespace has been previously loaded into the repl
06:20hoeck*basically
06:22hoeckcad_from_austin: do you copy whole files literally into the repl?
06:22hoeckcad_from_austin: (require 'the.namespace :reload) should be more convenient
06:22cad_from_austinPretty often, yes.
06:24LauJensenhoeck: or :reload-all
06:36cad_from_austinWhere should I put the reload-all?
06:38cad_from_austinChrist, nevermind. I got it.
06:39LauJensencad_from_austin: Sorry - I had that line on my screen the whole time, but because there was no highlighting, my mind seemed to have filtered it out ... scary :)
06:40RaynesLikewise, actually. :|
06:40RaynesI was playing tetris. :)
06:46LauJensenRaynes: The penumbra version? :)
06:46RaynesNot a Clojure tetris.
06:46RaynesI suck at graphics programming.
06:46cad_from_austinLauJenson: Which line?
06:47Raynescad_from_austin: The line where you asked where to put reload-all
06:47cad_from_austinAh.
06:51cad_from_austinHoly crap this is useful. Thanks guys.
06:51RaynesReload is a gift from the great brackety gods.
08:01eevar2icfp starting now-ish
08:14LauJensenRaynes: Doesnt matter if you suck. Tetris is in one of the demos that come with Penumbra :)
08:16RaynesLauJensen: Oh.
08:36Licenserhmm reading the page about statics it looks impresive!
08:36LauJensenLicenser: When will you learn, its just a prank, clojure will never be statically typed
08:37LicenserLauJensen: I'm vaxinated against learning, it was a long and painfull process, including torture, brainwashing and humiliation - I think they called it school
08:38LauJensenOuch - Just say no
08:38LauJensenAnyway, Im kidding of course, statics are cool
08:38Licenser:P
08:58LicenserI start to dislike all that meta annotation stuff :( it gets to look more complicated then useful
08:59LauJensenBecause they changed #^ to ^ ?
08:59LicenserNo but reading the code in the example it starts to look odd
09:00Licensertoo much of ^ in there
09:00LauJensenBut you so rarely need it, its not a general thing
09:00Licenseryes but it'd look cooler if it were a macro/special form/function
09:00TweyIsn't it deprecated for (meta …) anyway?
09:00Licenserlike (static ...)
09:00TweyOh, right, I see.
09:01LauJensenI disagree
09:01Licenserwhat I mean is we start to have many many many special character combinations
09:01Twey(with-meta …)?
09:02Licenserreader macros are kind of cool on the one hand but if we end up with perlish charcter chaos it gets ugly
09:03Licenseralso the whole macro syntax can be quite cryptic
09:03Licenserwith @,~,` and '
09:03Licensernow we also got $, and always had #(whatever behind it)
09:04Licenserdoes it make any sense what I mean, i talk about readability here, it is code lengthy effective but can get cryptic quite quick sadly
09:16raekhttp://github.com/richhickey/clojure/blob/8c9b0574a83f6c77576325b724c837cf4143eb33/src/clj/clojure/java/io.clj#L263
09:16raekshouldn't this be "make-output-stream"?
09:17Licenserone think I don't understand about the static stuff, will the static branch break the fact that numbers 'just work'?
09:20raek(output-stream (Socket. "clojure.org" 80)) throws "Cannot open <#<Socket Socket[addr=clojure.org/75.126.104.177,port=80,localport=52729]>> as an OutputStream." for me...
09:20raekbut (input-stream ...) works fine...
09:21raekSocket does not seem to be extended to IOFactory correctly
09:24Licenserraek: an output stream is a stream you can write to
09:25Licenserand I might be mistaken but I don't think you can write to clojure.org's webserver
09:26raekthat was just an example of something that yields a working socket
09:26raekI'm aware of how HTTP works
09:26Licenserwell but it is a read socket I think
09:26Licensernot a write socket, at least I think
09:26Licenseror wait no you should be able to write to it
09:26raekyou need to send the request...
09:27Licenseroh details :P
09:27Licenserbut perhaps you need to wrap it in something before that?
09:27LicenserI am confused but you may be right
09:27raekI think I can make a fix for this myself
09:28raekbut I haven't signed the CA yet
09:28cemerickrhickey: I tripped all over recur last night. Two problem cases: https://gist.github.com/e9bb4c44adf8d9a195dd
09:29cemerickIf I had a magic wand, recur from within the try block, regardless of target, would run the finally block. That may be too complicated to implement though.
09:30raekSockets have two methods called getInputStream and getOutputStream
09:30cemerickIn that case, recur out of a try should be disallowed.
09:30cemerickHowever, it seems like recur whose target doesn't leave the try/catch/finally should be allowable.
09:30raekSocket is extended to clojure.java.io/IOFactory
09:31raekbut only half of the protocol is implemented
09:32Licenserheh
09:32rhickeycemerick: yes, recur + try needs work
09:34cemerickrhickey: Shall I open a ticket or is this a 10 minute quickie?
09:34Licenserhmm when I understand the mailing list correctly the new branches will remove automatic overflow to bigint? I find that a huge step backwards even for the sake of performance, I personally would not trade a easyer syntax / working for performance for the 'it just works' effect
09:34rhickeycemerick: it's a huge job and there are already tickets I think
09:35cemerickok, I'll double check
09:35tcrayfordcemerick: I keep on wanting to work on adding your "ideal clojure ide" features to intellij, but getting it build really sucks, and the guy who runs it is not good for help :(
09:36tcrayfordI'm pretty sure I can implement most of them pretty quickly, just doing so outside of emacs looks like a right pain
09:36cemerickrhickey: If it's any easier, a temporary change to disallow recur from try entirely would be preferable to the silent dropping of the finally IMO.
09:37rhickeycemerick: you are talking about case #2, yeah, I don't know why that's not caught
09:37cemerickrhickey: right, that's really painful
09:37rhickeycurrently it's mostly draconian about it
09:37rhickeycemerick: you really wrote something like #2?
09:39cemerickrhickey: yes, I had a recur in the try, with a loop target outside the try, and a finally block that was deleting the temp files that were being looped through after they were processed in the try. I kept running out of disk. :-)
09:39cemerickwhoa, I botched that sentence :-O
09:40mikemwhat's the easiest way to launch a clojure script from the command line without compiling it first?
09:40cemericksimilar to (loop [[file & files] files] (when file (try (process-file file) (recur files) (finally (.delete file))))), but with a lot more stuff going on :-)
09:42tcrayfordmikem: there's a bash script included in contrib
09:42tcrayfordhttp://github.com/richhickey/clojure-contrib/blob/master/launchers/bash/clj-env-dir
09:43mikemtcrayford: ok, looking at it now
09:43cemericktcrayford: hrm, yeah, I've heard similar things. :-( I had high hopes when IDEA open-sourced the base, but there doesn't seem to have been a lot of traction on any IntelliJ open-source projects that I've heard of.
09:43tcrayfordcemerick: I emailed the author about it in april, and still haven't got a response
09:44tcrayfordI already know how to write most of the stuff you've requested, might just go and do it in emacs and then ask the people who write the IDEs to steal it
09:46cemericktcrayford: I don't think there's a lot of stuff there that's truly difficult, the tough part is getting it in one place and making it accessible to a broad audience.
09:46danlucrafttcrayford: I would steal anything you wrote for Redcar if you OKed it
09:47tcrayforddanlucraft: if I do this, the first thing in the readme is going to be a note for IDE writers to steal everything and anything they want
09:47danlucraftbrill
09:49tcrayfordthough note that most of my stuff requires access to a running repl which has all of the source code loaded into it
09:49tcrayford(for whatever project is being worked on)
09:50cemerickdanlucraft: what's the UI toolkit you're using?
09:50danlucraftswt
09:51cemerickit is written in jruby then?
09:51danlucraftcemerick: yep. almost entirely
09:51cemerickah, ok
09:51cemerickyou should change your FAQ :-)
09:52danlucrafthmm
09:52danlucraftcemerick: to say it's written in JRuby?
09:52danlucraftdone!
09:53danlucraftcemerick: I read your posts on ideal clojure env
09:53danlucraftmade some notes
09:53danlucraftI saw you said "Textmate (!)" :)
09:53cemerickI think I only made one, but sure. :-)
09:53cemerickYeah, TM is an oddball choice for sure.
09:53danlucraftwhat's the ! for?
09:53tcrayforddanlucraft: the problem for him is that redcar won't have amazing java support like the other ides
09:53cemerickIMO, anyway
09:54danlucraftcemerick: I mean, I think I get it, but why would you say ™ is no good for clojure?
09:55cemerickdanlucraft: Well, there's not much to the bundle, and TM is a bit of a dead-end until someone writes a replacement. ;-)
09:55tcrayfordcemerick: a bunch of the stuff you have in there is already in swank (find usages, go to declaration), and the IDE people could definitely yoink that
09:57cemericktcrayford: Yeah, but actually implementing the functionality isn't the hard part.
09:57cemerickintegrating it into the IDE is.
09:57tcrayfordvery true
09:57cemericke.g. getting discovered namespaces recognized as "types" is a good example
09:58danlucraftwhat's a discovered namespace?
09:59danlucraftas opposed to a regular namespace?
09:59mikemtcrayford: ok, I got the clj-env-dir script working, however it seems my .clj file needs an explicit call to (main) in order to run. is it possible to invoke main from the command line somehow?
09:59tcrayfordmikem: I don't know, I just use lein for everything :/
09:59cemerickdanlucraft: one that your editor or build tool has recognized as a namespace to support navigating to it or compiling it.
10:00mikemtcrayford: hehe ok, no worries :)
10:00mikemthanks for the help
10:03danlucraftcemerick: ok
10:07rhickeycemerick: you haven't weighed in yet on the ggroup re: enhanced primitives. More naysayers right now.
10:08djpowellhmm, would it be good for clojure.main to support running the (-main) function somehow?
10:09cemerickdjpowell: there's a ticket for that, I think technomancy opened it
10:09cemerickrhickey: I'll dig in a little later -- but, I'm on very shaky ground there. I fail forward when it comes to mathy stuff. :-(
10:16cemerickrhickey: looks like 4:1 against, if I can summarize so callously. And here I was focusing on equality semantics.
10:16mmarczykincidentally, I wonder if the introduction of the num/prim/equal branches means that 1.2 is settled and basically in testing?
10:17mmarczyk(surely this stuff isn't meant for inclusion at this stage)
10:18mmarczykcemerick: thanks for prodding me along re: the ca, by the way, should arrive sometime soon (today? Monday?) :-)
10:18cemerickmmarczyk: excellent :-) I'm already using the multi-comparator :-)
10:18mmarczykcemerick: oh cool, happy to hear that :-)
10:19cemerickmmarczyk: apparently it is intended for 1.2
10:20Licenserso I might hold a short presentation of clojure on a ruby meeting, I know some of you already did some presentations, are there any advice what are good points to tacke?
10:21mmarczykam I correct in estimating that this would make 1.1 -> 1.2 a bigger deal than Python 2.6 -> 3.1 ? :-)
10:22cemerickyeah, it's already a pretty huge release compared to 1.1
10:23mmarczykI would have thought that the new numeric stuff would require a pretty significant testing effort before release, while the other stuff is probably pretty well tested already
10:23cemerickwell, there's a fairly large body of automated tests
10:24cemerickbut yeah, I think adding the prim, static, etc stuff will extend the stewing period
10:24cemericknote there's not been a beta release yet *shrug*
10:24mmarczyktrue
10:24cemerickhanging out in #clojure makes one think everything's just around the corner
10:24Licenserheh
10:25Licensertcrayford: you can start c-in-c already :P
10:25tcrayfordhah :P
10:25mmarczyk;-)
10:25LicenserI mean many of use are already using 1.2 I guess
10:25mmarczykI know I do
10:26mmarczykprotocols / records are really pretty helpful
10:26Licenseryap
10:26tcrayfordman this is sorta confusing
10:26Licensertcrayford: what is?
10:26tcrayford,(= '() (map identity '()))
10:26clojurebottrue
10:26_fogus_Someone started a 1.1 REPL and I felt physically ill. I wondered how they got along without types/protos/records
10:26tcrayfordthat
10:27mmarczyktcrayford: huh?
10:27tcrayford(= empty-seq empty-list)
10:27mmarczyk_fogus_: so, prudence (staying on the stable boat &c.) has adverse effects on your health? ;-)
10:28mmarczyknot to say I wouldn't feel similar, though I'm afraid I have a sillier reason (how could we live with #^ in place of ^!?) :-)
10:29silveenDoes anyone know of a bb2html'ish PHP script that handles code syntax highlight for different languages?
10:29tcrayfordI can sorta understand why the empty seq is equal to the empty list (they print the same), but its still somewhat weird
10:31djpowell,(= '() (sequence nil))
10:31clojurebottrue
10:31mmarczyk,(= [] ())
10:31clojurebottrue
10:31tcrayfordah
10:32tcrayfordthat makes sense
10:32_fogus_equality partitions ftw
10:32rhickey_fogus_: got slides?
10:33_fogus_for the talk last night?
10:33rhickeyyes
10:33_fogus_I will have them up today
10:35_fogus_it was a fun talk. but I think I talked too fast :(
10:36tcrayfordpractice gets you better
10:36liebke_fogus_: You did a great job, I enjoyed it a lot!
10:37_fogus_liebke: Thanks! I thought the Q&A was pretty thoughtful
10:37liebkeI agree
10:37_fogus_People seemed genuinely excited about Clojure/core also
10:38rhickeyliebke: want to clean up the incanter test failures on equal branch? mostly things of the (= 113.0 113) variety. Would need to become (= 113.0 113.0) or (== 113.0 113) Any such fixes would be backward compatible
10:39liebkeI think they were more excited about trying to improve Clojure's out-of-box experience :-)
10:39rhickeyliebke: it's breaking my argos tests
10:39liebkerhickey: will do
10:39rhickeyliebke: thanks
10:39liebkeI told them about how I kept breaking your argos tests :)
10:40rhickeyheh
10:40rhickeyI love having argos
10:40liebkeI love you having argos
10:40_fogus_love fest
10:42technomancygroup hug!
10:43liebketechnomancy: we also talked about your keyboard pants, and the future of wearable computers :)
10:45technomancysweet.
10:45liebkeI'm considering making mouse-shoes
10:45technomancyclojurians have a nose for futurism
10:46technomancyliebke: I am actually considering a foot pedal for mic mute to assist with voip pairing
10:46technomancywould make it easier to work in noisy coffee shops with bean grinders going off in the background
10:46liebkeyou are the future :)
10:46_fogus_treat him well
10:46liebkeah, you're pairing at coffee shops, that's cool
10:47technomancyhehe
10:49rhickeyso, only inc, dec, +, -, * have overflow issues. If you are in favor of the default being throw on overflow, what suffix would you suggest for the promoting versions, and vice versa, if the default was promote, what suffix for the throwing versions?
10:51Licenserstatic-inc static-dec static-+ static-- (looks ugly) static-* (or stat- or just s-)
10:51rhickeye.g. things like +n for generic [n]umeric addition, or +o for addition with [o]verflow or [o]ptimized
10:51Licenseror inc! +! -! *!
10:52vu3rdd_fogus_: is your capclug presentation available somewhere for download?
10:52rhickeyLicenser: ! for 'hurry up!' ?
10:52Licenser! for hurry up! for watch out! for might throw!
10:52Licensergeneraly for need to look at this!
10:52mmarczykI'd go with prim-add / fast-add or something for fast math
10:53Licenserand it'd be consistant with the transistant things ! functions are faster but need special care
10:53mmarczykbut Licenser's idea is pretty cool :-)
10:53mmarczykoh, that's true (the parallel to transients)
10:53Licenserand it also says 'I freaking know what I'm doing!!!!'
10:54_fogus_how about +slow -slow *slow :p
10:54Licenserheh
10:54vu3rdd_fogus_: sorry, didn't read the conversation above. Looking forward to go thru it
10:54mmarczykLicenser: yeah!
10:54mmarczyk(inc Licenser)
10:55_fogus_vu3rdd: It should be (back) up later today. I took it down to move it but had to run
10:56Licenserwe could also make it +§
10:57Licenserwhich reminds me, clojure is the perfect language for lawyers you can call variables §3
10:59ChousukeI'd rather have + and - etc. be the fast ones
10:59mmarczykjust out of curiosity -- why?
10:59ChousukeIf you anticipate that overflows will be a problem, you can prepare for it
11:00mmarczykif you anticipate anything of the sort, you know what you're doing
11:00Chousukemeanwhile, anyone else writing regular maths code will get speed.
11:00LicenserChousuke: but that is an expert decision and the default one should be what is surely good for non experts too
11:00Chousukewell, of course. Programmers can be expected to know what they're doing.
11:00LicenserChousuke: In what world do you live?!? :P
11:01Licenserjust think bout it, when people start to write stuff and start with simple things as fact and boom things go down and they wonder why and have to figure out how to typehint and and and
11:01AWizzArdHehe, can one translate it that directly from german to english?
11:01Licenserthat isn't nice
11:01mmarczykChousuke: ah, that's just not true
11:01ChousukeLicenser: Except they won't need to typehint anything
11:02mmarczykChousuke: people should be expected to know enough about what they're doing
11:02ChousukeLicenser: they'll just need to use bigint literals.
11:02Licenserbut finding out that there are two versions of +
11:02mmarczykthe smaller "enough" is, the better
11:02Licensereven worst o.O
11:02mmarczykfor the parts of the spectrum everyone touches upon
11:02mmarczykhigh performance math is not really something everyone touches upon
11:02LicenserI guess very little people do
11:02mmarczykin particular, cemerick's State of Clojure has 53% of Clojurians do web apps
11:03mmarczykin which way is having fast math relevant to building a web app?
11:03Licenserand just to make sure people don't get it wrong, I do need fast math but I'd rather go the extra length to write +! where I know I can do it then having to write +n or whatever when I'm in doubt
11:03mmarczyknow not having exceptions because of maliciously formed numerals or whatever
11:03mmarczykmight actually be relevant I guess
11:03mmarczykLicenser: an (inc) to that too
11:04cemerickmmarczyk: FWIW, maths are #2 in that list :-)
11:04ChousukeI'm not convinced that this would be a problem.
11:04Licenseryes #2 :P
11:04mmarczykcemerick: yup, I remember :-)
11:04Licenserthere is nothing worth more then 'it just works'
11:04mmarczykcemerick: with what, around 1/3 of the community declaring an interest?
11:04cemerick39%
11:04mmarczyksome of those guys might be Konrad Hinsen-types :-)
11:04mmarczykI mean, they want it slower :-P
11:05mmarczyksee clojure.contrib.generic
11:05LicenseriPods are the most sold music players, Ruby went hugely up in the last years, apple computers in general did. And all of them because 'they just work'
11:05ChousukeLicenser: except when it doesn't, and you end up getting weird behaviour because some of your numbers are bigints and some aren't :P
11:05cemerickLicenser: all of which have nothing to do with a design decision in a programming language
11:06Licenserof cause
11:06mmarczykthe present state of arithmetic in Clojure does mostly "just work" though
11:06mmarczyk
11:06ChousukeLicenser: Ruby still had broken strings in 1.8; how does that count as "just working" ;P
11:06Licenserat least ruby, last time I checked was a programming language, but let me fire up IRB and see if it starts to play songs but I think it will still be a programming language
11:07LicenserChousuke: it was ruby's goal and in a lot of cases it did, now we, when going for performance over promotion, are moving knowingly and willingly away from a it just works
11:07Licensercemerick: nope not playing songs, still a programming language
11:08Licenserbut that aside, yes all of them are totally relevant. In the end if a programming language 'does not sell' it is not worth squat
11:08ChousukeLicenser: Except it'll still just work in the vast majority of use cases :/
11:09Licenserwell I think we won't know in how many cases it will not just work.
11:10Licenserpoint is, when people get a odd exception (and sadly clojures are not very expressive) they'll be confused like hell
11:10technomancythat was 39% of "data analysis / math"
11:10ChousukeLicenser: an Integer Overflow exception is not very odd
11:10LicenserChousuke: when you don't delcare types it is :P
11:11Licenserif it is statically typed it would be obviouse
11:14Chousukefor the record, I think ! would be a horrible suffix for the faster functions :P
11:14Chousukeit's as if you were mutating the numbers
11:15Licenserwell that depends on how you definate !
11:15mmarczykfor the record, I'd still be fine with prim-add despite liking +! just fine ;-)
11:16LicenserLet me tell you a tale
11:16ChousukeI don't think prim-add is that good either. It works with bigints too doesn't it?
11:16Licenserback when I was at the university I decided to learn some programming languaegs - odd enoguh I know
11:16mmarczykChousuke: ah, fast-add than
11:16mmarczyksomething modelled on unchecked-add anyway
11:16Licenserthe first and most important one I learned well started, was Smaltalk - a I think utterly dead and not used language
11:17ChousukeI don't think Smalltalk is dead, it's just hiding well :P
11:17Chousukekinda like common lisp
11:17LicenserNot because I liked the concept, or the syntax or the ideas, back then I didn't cared. But because it had nice easy arithmetics. I could just implement RAS without importing classes for BigInt, BigNum or any other library specially for big numbers
11:18Licensernow I did not learn Java, even so I could have done the same, or other languages, I found Smaltalk did that and weeeh I was happy
11:18Licenserand I kind of want people to have the same happy feeling when they start clojure, that things just work when they write simple code and let experts worry for performance if it matters
11:18rhickeythere are also people forced out of using languages they love because they aren't fast enough, and end up using C/Java
11:19Licenserbut seriousely we need the fresh blood and everything that icks them is a bad move in my eyes, they should be given cookies, petted on the head and cared for, not scared off with people prim-add
11:19Chousukeso if we went with non-fast math by default, then what exactly would it require to be fast?
11:19mmarczykrhickey: if there is an actual possibility of having a set of fast-add etc. operators, this shouldn't be the case here even without + defaulting to the new math behaviour, right...?
11:20Licenserrhickey: don't get me wrong, I don't say lets be slow but as I understand the tradeoff is 'it just works' vs 'it is just fast' right? In both cases everything is possible if 'it just works' we still can make things exactly as fast as 'it is just fast' just with extra effort for that code, and if we go for 'it is just fast' we still can write the tings that not just work any more just again with extra effort on that code right?
11:21mmarczykanyway, I guess if + does default to fast, but there is a very clear path to safe, I'd just use the latter when unsure and be perfectly happy...
11:21clojurebotadd-classpath is Fraught with Peril!
11:21rhickeymmarczyk: well, it's a case of how much work is it to be fast. If it is too much work, or too difficult to get right enough to be actually fast, then it won't be perceived as fast
11:21LicenserAs I understand the question is not simple or fast but what should be the 'default' behaviour
11:22Licenserwhat about a (fast) macro
11:22rhickeyLicenser: there are many many programs that will 'just work' without ever creating a BigInteger
11:22mmarczykrhickey: but if it is too much work or too difficult to avoid funky exceptions, than I have a feeling it won't be perceived as "safe", even if it technically is
11:22Licenserit is crazy but you could write (fast (defn bla [x y] (+ a b))
11:22cemerickyeouch
11:22Licenserrhickey: I know many many will but some will not, and 'just works' is a thing that either is or not 'it just works somethimes' is not 'it just works'
11:23rhickeymmarczyk: yes far less safe things, like Java will be used instead
11:23cemerickLicenser: for some, being fast is their version of "just works"
11:23lpetitI was wrong in my ml post. Having clojure throw an exception when there is an overflow will still preserve my data. So I'm OK with the suggestions. Java, in the other hand, will silently corrupt my data, giving me a false sense of security ( System.out.println(2 * Integer.MAX_VALUE) returns -2, for the record )
11:23rhickeycemerick: true also, performance as part of the acceptance criteria
11:23Licenserso what is about the deal with a fast macro - that would just work in both cases
11:24Chousukeand with the fast functions, you'd still be able to have "just works" math by using biginteger literals, right?
11:24Chousukeso (+ n 10N) will "just work"?
11:24rhickeyfast macro etc definitely not going to happen
11:24Chousukeno matter what n is
11:24Licenserokay was just an idea
11:24mmarczykrhickey: actually that's possible (though ridiculous), another possibility is, say, Ruby
11:24Chousukeand functions that do (+ n m) will just work as long as either n or m is a bigint
11:25mmarczyknot trying to sound like I understand the implications of all this better than I actually do, by the way, just trying to share what I'm worried about
11:25qbgWith regards to the bigint issue, why not have a piece of metadata that you can put on a function definition that will enable aggressive use of primitives?
11:25Licenserqbg: I think that is the same as the fast macro
11:26mmarczykI'll be happy to be put at my ease by an excellent story (a new one or possibly the current one at a new level of my comprehension)
11:26Licensermmarczyk: one upon a time there was a cookie, this cookie was laying and the desc and then, oh horror a human came and eat it untill it was eaten.
11:27Chousuke:P
11:27lpetitLicenser: ^^^^ (that is, it works in both cases, if you consider the goal of data integrity)
11:27mmarczykLicenser: I love the style, though I honestly can't figure out what you mean by that ;-)
11:27Licensermmarczyk: I'm hungry
11:29Licenserhmm rhickey don't get me wrong I'm all for fast, but I think it might annoy people who are new if they have to learn an extra layer of functions if they want to make things always work.
11:30AWizzArdLet's say I have a (defrecord Foo [a b c]). Now I have the Symbol 'Foo and the vec [10 20 30]. I would like to create a Foo instance out of those two objects. What is the right approach to do so without using eval? (apply (reolve 'Foo) [10 20 30]) won't work.
11:30AWizzArdreolve ==> resolve
11:30mmarczykdo I understand correctly that (fn fact [n] (if (zero? n) 1 (* n (fact (dec n))))) is broken in prim/num ?
11:31qbgFor definitions of "broken"
11:31mmarczykif so, how does one write a function which computes the n! where the status of n as a primitive is left up to the caller to decide?
11:31qbgThe writer coerces n to a bigint?
11:31mmarczyk(trying to understand exactly what is happening...)
11:32rhickeymmarczyk: with that definition:
11:32rhickeyuser=> (fact 20)
11:32rhickey2432902008176640000
11:32rhickeyuser=> (fact 42)
11:32rhickeyjava.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:73)
11:32rhickeyuser=> (fact 42N)
11:32rhickey1405006117752879898543142606244511569936384000000000N
11:32rhickeyuser=> (fact 42.0)
11:32rhickey1.4050061177528798E51
11:32mmarczykhm, I see
11:32Licenserrhickey: so how if I make a clculater that gets a number from a input field
11:33Licenserdo the user has to type 42N in there or how do I handle it?
11:33lpetitAWizzArd: I guess you'll have to use reflection, but also to have the fully qualified named of the class ('Foo just gives you the class name, not the package)
11:33rhickey(bigint x)
11:34Licenserbut then I'm back at where we started or even worst since it always is a bignum
11:34Licenserso I lost speed, and added complexity which is in my eyes a loose loose situation
11:34AWizzArdapply does not work on new
11:34qbgnew is a special form
11:34AWizzArdyes
11:34rhickeyLicenser: everyone else lost speed to make you happy in the first place
11:35lpetitAWizzArd: of course. You have to use java API reflection. Maybe there's something in contrib masking it, hmm
11:35ChousukeAWizzArd: Use .newInstance on the class object to create objects dynamically
11:35AWizzArdLicenser: for a calculator bignums are the right objects, better not static longs.
11:36hugoddo rationals work with primitives?
11:36Licenserrhickey: my point was there, if the inputs are not entirely controlable chances are good we will resort to casting everything to bignum in the first place - just to be sure
11:36AWizzArd.newInstance sounds good.. (apply #(.newInstance (resolve 'Foo) %&) [10 20 30]) ?
11:36Licenserthat is whenever user input happens
11:36rhickeyLicenser: and yet another trumped up theoretical example. Your calculator will be whole numbers only? If not, you were out of the integer space already
11:37ChousukeAWizzArd: I think it takes an array of objects as the constructor argument though.
11:37ChousukeAWizzArd: check the docs
11:38Licenserrhickey: it was an example to demonstrate a problem I see, I know it is not the perfect solution but working with inputed (may it be read from a file, database, or whatever) integers and then there will be the question
11:38lpetit,(#(.newInstance (resolve 'String) %&) ["hello"])
11:38clojurebotjava.lang.IllegalArgumentException: No matching method found: newInstance for class java.lang.Class
11:38ChousukeI suppose a calculator would use BigDecimal
11:39Chousukelpetit: an array, not a vector
11:39Licenserokay another question how, when we don't force primitives would we have to adjust fact up there to make it use promitevs?
11:39Chousukelpetit: annnoying, isn't it :(
11:39Licenser(fn ^:static fact ^long [^long n] (if (zero? n) (long 1) (* n (fact (dec n))))) like that?
11:41qbgWhat about boxing a long as a FastBigint (or something similar) when passing a primitive long to an IFn?
11:43mmarczykrhickey: tbh, asking for elaborate examples of code which breaks/benefits significantly is a bit much at this stage...
11:43AWizzArdSeems that .newInstances takes no args at all.
11:43lpetitChousuke: more annoying is that you must first get the list of constructors and find the good one, also ...
11:45cemerickrhickey: there's that island dynamic playing out in real time http://www.haskell.org/pipermail/haskell-cafe/2010-June/079044.html
11:45AWizzArdrhickey: would it make sense to teach apply to do (apply SomeClass [10 20 30]) ==> (SomeClass. 10 20 30) ?
11:46mmarczykcemerick: amazing link
11:46lpetitAWizzArd: clojure.lang.Reflector to the rescue: ,(clojure.lang.Reflector/invokeConstructor (resolve 'String) (to-array ["lolo"]))
11:46lpetit,(clojure.lang.Reflector/invokeConstructor (resolve 'String) (to-array ["lolo"]))
11:46clojurebot"lolo"
11:46mmarczykhttp://www.xent.com/pipermail/fork/Week-of-Mon-20070219/044101.html
11:46mmarczyk^ reminds me of this one
11:48cemerickmmarczyk: yours is a helluva lot stranger in the first 4 lines! :-P
11:48AWizzArdThat works, but it is very inefficient.
11:50mmarczykcemerick: yeah, it's fantastic :-)
11:50rhickeyseriously though, I'm looking for appendable suffixes for either promoting or throwing ops
11:51mmarczykmaybe a sigil of some sort? +&, +: ?
11:51qbgWhat about %?
11:51qbg(For throwing ops)
11:52mmarczyk+_ for add which stays on the level it starts at...
11:52qbg(probably best as a prefix?)
11:53LicenserI think pre/suffixing both would be the worst to do, leave one as the default and the other as a suffix
11:53mmarczykincidentally, what happens when the call goes through the Var?
11:53rhickeymmarczyk: which call?
11:54mmarczyk#'+ could be an unpleasant way of saying "slow down, mate"
11:54mmarczykrhickey: (#'+ 1 2)
11:54rhickeyno, same semantics
11:54mmarczykah, I see
11:54rhickeynot fast, but same operation, will throw on overflow or promote whatever wins as the default
11:55Licenseragain what would be the extra effort to make things fast if we'd stay with promoting by default, I'm not entirely sure how the syntax had to look for that :(
11:55mmarczykhm, I'm reading into the proposal more and more and sort of beginning to see the wisdom of the 'fast' side... not totally sold on it yet, but this goes to show the amount of trust Clojure's design has accumulated with me thus far -- I actually expect to be wrong when feeling uneasy :-)
11:56Licenserand at what level is it decided, argument level function level or return value level? or all of them
11:57qbgmmarczyk: Same here; I like the idea of the num branch, it just feels like I'm losing an old friend...
11:57mmarczykqbg: fortunately the friend is a phoenix and his new plumage might be even more splendid :-)
11:57Licensereven I do like it I'm just not sure if it's worth it entirely and if there isn't a better way
11:58mmarczykp+ / +p for "promoting +" ?
11:58arkhjava interop question - this works '(.. (Thread. fnname) start)' but how do I do the equivalent of this (.. (Thread. fnname arg1) start) ?
11:58Licenser+^ ?
11:59mmarczyk,(read-string "+^")
11:59clojurebot+
11:59mmarczykLicenser: so no go...
11:59Licenseryuck why that?
11:59cemerickarkh: not entirely sure what you're trying to do, but perhaps (Thread. (partial fnname arg1)) will do.
11:59mmarczykI guess the symbol ends before ^, which is not a symbol char
11:59cemerickarkh: you really want to be using a future or agent though...creating threads is usually unnecessary.
12:00mmarczykarkh: (-> arg1 fnname Thread. .start) or sth?
12:00Licenserbut I'd still like to see what the verbosity trade of of making a function fast would be when using promoting by default
12:00mmarczykLicenser: me too, absolutely
12:01arkhcemerick: I was scolded for using agents and futures in ways they weren't meant to be used ; ) I have a function I want to kick off in another thread but don't care about it's return value
12:01mmarczyk,(macroexpand '(-> arg1 fname Thread. .start))
12:01clojurebot(. (clojure.core/-> (clojure.core/-> arg1 fname) Thread.) start)
12:02cemerickarkh: I abuse futures for that :-)
12:02mmarczykah, won't work of course... try it with macroexpand-all (from contrib) maybe at your repl
12:02Licenser(doc send-off)
12:02clojurebot"([a f & args]); Dispatch a potentially blocking action to an agent. Returns the agent immediately. Subsequently, in a separate thread, the state of the agent will be set to the value of: (apply action-fn state-of-agent args)"
12:02hoeckarkh: (.start (Thread. #(fnname arg1 ... argn)))
12:02rhickeywhat about +' dec' *' ?
12:02arkhmmarczyk: looking into that ... otherwise I'll abuse futures
12:03AWizzArdSounds like Ocaml...
12:03Licenserrhickey: that doesn't look bad
12:03arkhhoeck: I had tried that but thought it didn't work ... maybe it was my code : (
12:03rhickeyAWizzArd: what does?
12:03qbgrhickey: That looks good
12:03mmarczykrhickey: +' looks good to me
12:03AWizzArdDifferent operators that basically do the same thing on diferent types.
12:03mmarczykrhickey: which variant would you use it for?
12:04AWizzArdBut that seems to be the price for very fast execution.
12:04LicenserAWizzArd: it is not about doing different things but using some different logic for the same types
12:04rhickeycemerick: where's the syntax expansion?
12:04hoeckrhickey: please not, how should this be distinguished from a plus and a real quote?
12:05cemerickrhickey: ok, right, just another idiom
12:05mmarczykrhickey: btw, there's no possibility of doing the equivalent of Haskell's (Num a) => a -> ..., is there...?
12:05Licensera missing space?
12:05rhickeyhoeck: no spaces
12:05rhickey' would be allowed as a constituent character
12:05AWizzArdmaybe add/plus/mul/multiply
12:05mmarczykhm, wait, that definitely needs rephrasing :-P
12:06rhickey'fred's => fred's , on my machine
12:06cemerickStill, more otherwise-meaningless chars for core functionality.
12:06Licenser,(type 'fred's)
12:06clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$type
12:06rhickeycemerick: it's not anything more than allowing those chars in names, not special, you can use it yourself
12:06AWizzArd['fred's]
12:07Licenserwow is clojurebot slow today?
12:07Licenser$eval 'fred's
12:07sexpbot=> fred
12:07AWizzArd,['fred's]
12:07clojurebot[fred s]
12:07Licenseror is it me that is slow
12:07cemerickrhickey: I get it. I guess I'd just rather have the language have a settled default than trying to satisfy all constituencies maximally.
12:08mmarczykI'm used to ' -- "prime" -- signifying alternative semantics when used at top level...
12:08rhickeycemerick: there will be a default. These functions will still need to exist, and have names, and be easy to change code written in terms of the default into these names
12:08LicenserI think allowing ' is cool since you can do nice mathematical notation with that f f' f'' ...
12:09hoeck' is such a ubiquitious character in lisp code
12:09rhickeymmarczyk: alternate semantics at top level in which lang?
12:09mmarczykrhickey: Haskell, e.g. foldl'
12:09rhickeyhoeck: not in non-macro clojure code
12:09mmarczykwhich is strict, vs. the lazy foldl
12:09AWizzArd+2 *2
12:10qbgIf +' was for throwing +, then + -> +' would be like assoc -> assoc! for transients
12:11mmarczyk...which sort of brings us back to +!, which is a no-go only if ! is to be reserved for mutation
12:11rhickeycemerick: else, e.g. people will be catching the exception from + as part of normal program flow of control, or coercing to bigint possibly needlessly
12:11hugodis putting the alternate semantics in different namespaces a non-starter?
12:12mmarczykthe idea with suffixed names for one class of arithmetic ops leaves open the possibility of reversing the choice -- as with #^ vs. ^ -- possibly with an intermediate stage with a third set of names...
12:12rhickeyhugod: I think so - what does this code do? (+ x y) ... change ns declaration ... and this: (+ x y) ?
12:12mmarczykmight be useful if "most frequent usage" turns out to be something different to whatever 1.2 will bet on
12:12cemerickrhickey: I'm butting out for now, I don't grok all the issues yet. The presence of multiple mathematical fns seems mildly frustrating on spec though, and "mere mortals" will absolutely flip.
12:12Licenserwe could do a (promoting ) macro :P
12:13Licensercemerick: ylou ment you promoted yourself above mere mortals?
12:13cemericksame thing?
12:13qbgWhy wouldn't a fast macro work, rhickey?
12:13mmarczykcemerick: that might be a reason to have suffixed functions for the elevated numeric crowd and not for those who aren't concerned :-)
12:14rhickeyqbg: no
12:14arkhcemerick: I'm a mere mortal. You can use me as a litmus test ; )
12:14rhickeyqbg: oh, why
12:14liebkerhickey: I cleaned up the numeric types in Incanter's tests, and argos with the prim branch seems happy (although the latest version of clojure.contrib.jmx seems to have a bad test). Let me know if you need me to fix anything else.
12:14cemerickarkh: *no one* in #clojure is a mere mortal, by definition
12:14rhickeyqbg: because it is too contexty, and what does it mean?
12:14rhickeyliebke: what bad test, did you pull contrib?
12:14arkhcemerick: if that were only true! I won't delude myself :D
12:15cemerickThe guy who needs to calculate interest and shove it back into a DB via hibernate is the one I'm thinking of.
12:15Licensercemerick: depends on what * function you used the promoting one or the non promoting one, if you used the non promoting one you might get a Human Overflow Exception
12:15rhickeyqbg: I don't want the compiler to have math modes, these are just ordinary function calls
12:15hugodrhickey: I think if you are writing code that you want to rely on one behaviour or the other, then being able to decide that at the namespace level, rather than checking every use of every operator, is a win
12:15liebkeI did pull contrib. the test for jmx/guess-attribute-typename is calling (Long/valueOf 10) instead of (Long/valueOf "10")
12:17Licenserhugod: I'd say on function or expression level not on namespace level otherwise this will mean you'll get often 2 namespaces
12:17rhickeyliebke: should be (Long/valueOf (long 10)), my bad
12:17rhickeyliebke: only tested with num
12:17liebkerhickey: ah cool
12:17rhickeywhere that works
12:17Licenserhttp://gist.github.com/442044 <- the second version, would that be what it would take to make a function fast in a otherwise promoting environment?
12:18hugodLicenser: get 2 namespaces?
12:18qbgrhickey: In my idea of a fast macro, code inside its lexical scope would have contagious primitive math, but fair enough
12:18Licenserhugod: yes one for functions that require promoting and one for functions that do not
12:19dnolenIf people leave over lacking autopromotion of BigInt they weren't that invested anyway.
12:19cemerickdnolen: that's my intuition as well
12:19mmarczykdnolen: you could turn that around, you know
12:20mmarczyk"if people leave over having to write a lil' macro to add hints" etc.
12:20rhickeyliebke: fixed
12:20dnolenmmarcyzk: not true, we're meeting in the middle
12:20mmarczykdnolen: hopefully
12:20dnolenmarczyk: BigInt folk are conceding a tiny amount of ground.
12:20liebkerhickey: great, I'm re-testing
12:20mmarczykdnolen: the present discussion would be about where the middle is and how useful it is
12:20hugodLicenser: so you are worried about my-lib-promoting/some-fn vs my-lib-nonpromoting/some-fn?
12:20Licenserhugod: yap
12:21dnolenmmarczyk: while bring fast math people to the party.
12:21LicenserI would understand if you have a promoting-fn and a nonpromoting-fn
12:21mmarczykdnolen: I wonder if that is the case.
12:21Licenserperhaps with a idomatic syntax
12:21Licenserthe same that +, -, * ... shoud use
12:22dnolenmmarczyk: I'm not going anywhere if this stuff doesn't make it in, but it does seem to me future work in pure Clojure suffers.
12:23Licenserdnolen: I think noone wants fast math to not be implemented, I think the discussion going on is which mode should be default and which one explict
12:23dnolenLicenser: no modes
12:24mmarczykdnolen: so you'd rather there were no auto-promoting ops at all? whoever might conceivably bump into bigint space should stay on that side all the time?
12:24Licenserdnolen: with default mode I mean, what will happen without extra effort and what will happen only with extra effort
12:24qbgIf one really wants to, they could in theory write a (promoting ...) macro if bigints all the time don't work for thme.
12:24qbg*them
12:25hugodLicenser: I wouldn't expect too many cases where a lib would provide promoting and non-promoting versions - and you could still qualify the symbols to provide promoting-fn and non-promoting-fn
12:25Licenserhugod: no but I can see many cases where some functions are promoting and others are not
12:25dnolenLicenser: the current system creates a lot of incidental complexity. modes just move it somewhere else.
12:26dnolenmmarczyk: people working with BigInts are working with BigInts. people working with primitive math, working with primitive math. num works seems to address that just fine.
12:26rhickey+#, -#, dec# ? the # seems to dominate the op a bit
12:26Licenserdnolen: again you missunderstood me, with modes I mean, what is the behaviour you get 'for free' and what is the behavior you have to add some extra code
12:26LicenserI don't mean modes as in switching
12:26mmarczykdnolen: they (modes) might also make it smaller if instead of adding a pile of hints all over the place you can just pick your operators wisely
12:26Licenserrhickey: dominating isn't bad if the thing is important to notice and to know about
12:26rhickeyLicenser: it is if you can;t see the algorithm through the #s
12:27mmarczykrhickey: might conflict with # = autogensym
12:27qbgIf integer literals could be either longs or bigints based on what is the right thing at the time (no suffixes needed), then the current approach in num could be nice
12:27Licenserrhickey: true
12:27mmarczykthough "no autogensyms for +" is of course an option
12:27mmarczykrhickey: agreed
12:27rhickeymmarczyk: yes, would have to work that out
12:27rhickeymmarczyk: without special rules like that :)
12:28mmarczyk:-)
12:28Chousukepeople'll look at ' and think it's a quote though
12:28LicenserI don't think if it s in the end
12:29rhickeyChousuke: really? - (+' (fib (dec' n)) (fib (-' n 2)))
12:29ChousukeI suppose it's just me.
12:29Licenser(+! (fib (dec! n)) (fib (-! n 2)))
12:29Chousukeand allowing ' in symbols would be nice anyway.
12:30mmarczyk(+_ (fib (dec_ n)) (fib (-_ n 2))) <- just testing... is this too ugly?
12:30mmarczykbut +' is nice
12:30qbg(%+ (fib (%dec n)) (fib (%- n 2)))
12:30rhickeyor +`, -`, dec` etc
12:30Licenser% is guly it looks too much like #
12:30mmarczykfits in with math practice etc.
12:30Licensernah ` is to hard to type
12:30Licenserit makes horrible things in german keyboards :(
12:30rhickeyLicenser: ah
12:31mmarczyk%+ isn't bad to my eye
12:31Licenserit wants to do something to the next character
12:31mmarczykI've wanted to write a -%> macro a couple of times, would be nice to see this work
12:31LicenserI wanted to write @-->--- functions
12:31qbgI'm just use to %primitive-function style from CL
12:32mmarczykLicenser: ah, but you can do that already ;-)
12:32LicenserI know
12:32LicenserI also wrote a <3 function
12:42Licenserso where are we at
12:45qbgLong literals have been ruled out?
12:46rhickeystay tuned
12:47qbgnum branch + long literals + fast bigints by default would be more than sufficient for me
13:43mmarczykhttp://disclojure.org/ has some rather amusing entries this time round :-)
13:43mmarczyk"Every time you mention Scala and Haskell in the same sentence, a Java developer thumbs through a Clojure book at Borders."
13:58nickikWhats the best way to go from here {:a 1 :b 2} to here {:a 1 :b 3}. Cant find the right function.
13:59hoeck,(update-in {:a 1 :b 2} [:b] inc)
13:59clojurebot{:a 1, :b 3}
14:40raekI have made a patch that fixes the broken clojure.java.io/output-stream implementation for java.net.Socket...
14:40raekhttp://github.com/raek/clojure/commit/797d2ff22cd8a52707d52efb6a680d5ee0a788f1
14:41raekthe bug was probably just a typo or something
14:41raekwhat can I do with this now?
14:44TeXnomancyraek: you need to sign a contributor's agreement; see http://clojure.org/contributing
14:46raekdone that today :)
14:46raekbut the mail takes some time
14:46TeXnomancygotta wait then. =\
14:47MrHusMrHus: reak: http://github.com/guides/pull-requests you could try this.
14:47TeXnomancyyou can create a ticket, but patches won't get applied till it's in.
14:47TeXnomancyMrHus: rich doesn't like pull requests.
14:48MrHusI can imagine when getting about a 1000 a day.
16:25rhickeyhttp://github.com/richhickey/clojure/commit/c79d28775e06b196ae1426f6c1446d00b621d2e1
16:45Licenserrhickey: nice :)
16:48LicenserI like the ' syntax
16:48rhickeyUpdated: https://www.assembla.com/wiki/show/b4-TTcvBSr3RAZeJe5aVNr/Enhanced_Primitive_Support
16:53Licenserrhickey: is there a branch that combines the changes described in the link?
16:53rhickeyhttp://github.com/richhickey/clojure/commit/c79d28775e06b196ae1426f6c1446d00b621d2e1
16:53Licenserah okay that one combines things :)
16:54hoeckLicenser_: now we can use v, v' and v'' in our big physics simulations :P
16:54islonis there a simplified sintatic sugar to (def #^{:private true} x 1} in clojure 1.2?
16:55hoeckand that trailing ' is not that bad
16:55Licenserhoeck: yay!
16:56hoeckislon: (def ^:private x 1)
16:56dnolenrhickey: nice! even looks like there a perf boost for primitive long arithmetic with those changes?
16:56hoeckislon: at least in that branch that rhickey just posted
16:56rhickeydnolen: everything is better
16:57dnolenrhickey: good stuff.
16:57islonthanks, i'll try
16:58rhickeydnolen: and if escape analysis ever arrives, it could get better still
16:58rhickeyfor the casual cases
17:08Licenserokay I feel stupid I fail to clone http://github.com/richhickey/clojure/commit/c79d28775e06b196ae1426f6c1446d00b621d2e1 :(
17:09Licenserdnolen: silly question since you seem to have managed, how did you fetch the right version of clojure? :(
17:09hoeckLicenser: its in the equal branch
17:10Licenser:D
17:10Licenserhoeck: you are my hero!
17:11hoeck:/
17:11Licenseryuck
17:32mmarczykrhickey: the new equal looks fantastic, hurray! :-)
17:45mmarczykI'll be doing the same in a minute :-)
17:45LicenserI think there is a regression in the commit:
17:45Licenseruser=> ((fn [x] (*' x x)) 2)
17:45Licenserjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Number (NO_SOURCE_FILE:0)
17:46mmarczykouch, this would mean that *' x is read as * 'x
17:46mmarczykas it used to be
17:46Licenseryap it is
17:46Licenserthat is badish
17:47Licenseruser=> (macroexpand '(*' 1 1))
17:47Licenser(* (quote 1) 1)
17:47rhickeyLicenser: seems like you have a bad build, that's 4 here
17:47Licenserhmm
17:48rhickeyLicenser: you building with ant?
17:48Licenserrhickey: yap I suck :P sorry
17:48LicenserI forgot to checkout equal as branch
17:49serp_are there any working guides for how to use emacs with slime, swank and clojure?
17:52tcrayfordI think there's a guide around for lein
17:52tcrayfordwhich is what you should be using anyway
17:52dnolenserp_: some tips on assembla
17:53lancepantzserp_: yeah, assembla has a guide i believe
17:53Licenserah now it works nice!
17:53tcrayfordassembla's guide doesn't cover slime iirc
17:54dnolentcrayford: it does
17:54tcrayfordmy bad then
17:54serp_http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Emacs <- this one?
17:55alpheusThis worked for me: http://github.com/jochu/swank-clojure
17:55dnolenserp_: yup
17:56serp_I'll give it a try, thanks
18:01mmarczykargh... anybody else having swank woes after moving to equal?
18:03dnolenmmarczyk: swank has a bug that prim triggers
18:03mmarczykdnolen: oh bother :-(
18:03dnolenmmarczyk: swank-clojure HEAD is patched
18:03dnolenmmarczyk: do you use lein?
18:03mmarczykdnolen: I see, thanks, will pull now
18:03mmarczyknot for setting up repls
18:04mmarczykbut I normally use HEAD of swank, just haven't bothered pulling in a while now
18:07mmarczykalso, (defn fact [n] (loop [n n r 1] (if (zero? n) 1 (recur (dec n) (* r n))))) throws on (fact 40) -- that's with *, not *'
18:07KirinDave[n n ?
18:07mmarczykKirinDave: ?
18:08Licensermmarczyk: not for me
18:08LicenserI just tested that
18:08Licensercould do (fact 42)
18:08mmarczykLicenser: really? let me check again
18:08KirinDavemmarczyk: Why two n's?
18:08Licenserwait not exactly for that code
18:09dnolenKirinDave: he's playing around with the new numerics stuff
18:09mmarczykKirinDave: left one is the local name, right one is the initial value (taken from the parameter to fact called n)
18:09KirinDaveAh
18:09Licenseryou're right it trhows here too - very dod
18:10Licensermmarczyk: but I can't find where it comes from
18:10mmarczykLicenser: I wonder if loop/recur needs to know ahead-of-time whether it's going to be dealing with primitives or objects
18:10Licenserhmmm
18:10mmarczykthat would be the case with a local variable in Java, right?
18:11Licensermmarczyk: but oddly enoguh for the simple version of fact it works
18:11SirNickwhat's the best way to set the character encoding with Ring or Compojure?
18:11mmarczykincidentally, (fact 40N) doesn't work here either
18:11mmarczykLicenser: well the simple version has the function call boundary
18:11mmarczykwhich might present an opportunity for boxing
18:11rhickeymmarczyk: that's a broken definition, always returns one
18:12Licenser$((fn fact [n] (loop [n n r 1] (if (zero? n) 1 (recur (dec n) (* r n))))) 42)
18:12mmarczykrhickey: ah, the middle 1 should be r
18:12Licenser,((fn fact [n] (loop [n n r 1] (if (zero? n) 1 (recur (dec n) (* r n))))) 42)
18:12clojurebot1
18:12rhickeythe throw is because you have a primitive accumulator r
18:12Licenseryuck
18:12Licenserthat's bad
18:12mmarczykrhickey: the 'old' arithmetic had no problem with it, but I suppose the r would have been a big-I Integer initially, right?
18:13rhickeymmarczyk: no, was boxed, now primitive
18:13rhickeyturn on *warn-on-reflection*
18:13mmarczykthat's what I meant, I think
18:13rhickey"recur arg for primitive local: r must be matching primitive, had: java.lang.Number, needed: long"
18:13mmarczykboxed on master, primitive on equal
18:14mmarczykright
18:14rhickeyyou can get boxed accumulator by doing (num 1)
18:14mmarczykjust tried hinting with ^Object which doesn't work...
18:14briancarperSirNick: On responses? Add a header to the response, {:headers {"Content-Type" "text/html;charset=UTF-8"}}
18:14Licenserhmm hmm is there a way to make it just work?
18:15rhickey(defn fact [n] (loop [n n r (num 1)] (if (zero? n) r (recur (dec n) (* r n)))))
18:15SirNickbriancarper: Can I set that up to be default?
18:15mmarczykrhickey: ah, great, thanks!
18:15LicenserI wonder why * does not work correctly BigInt * int should become a bigint shouldn't it?
18:16briancarperSirNick: Yeah, wrap all of your routes with middleware that adds the headers. I think that's the standard way to do it.
18:16mmarczyknot sure if I prefer primitive as default, but I can see myself being perfectly happy with (num ...)
18:17LicenserDo I have to go back to my rant about how confusing this will be to newcomers?
18:17SirNickbriancarper: Alright, so how do I handle requests? Or will that work by default by setting the response encoding?
18:17LicenserI mean even mmarczyk was confused
18:18Licenserand why does (* 1 1000000000000000000N) work but not in the loop?
18:18Licenserah because r grows too big?
18:18mmarczykyeah
18:19mmarczykthanks for your highly flattering use of 'even'
18:19Licenserthe problem is not that * overflows but that the loop call gets confused with gettinga BigInteger Number
18:19Licensermmarczyk: don't take it personal I was about to write even I was confused but I figured that my usual arrogance won't help my case to get this changed :P
18:20Licenser;)
18:20mmarczyk:-)
18:20briancarperSirNick: Honestly not sure how it's handled in requests. I've never done anything special to set anything up.
18:21mmarczykbriancarper: I've been meaning to ask -- how's your RPG project coming along?
18:21Licenseris there any way in the world that the compiler can 'know' what we mean?
18:21LicenserI mean the 1 part, when we mean a primitive and when we mean no primitive?
18:21mmarczykLicenser: we can tell it :-)
18:21briancarperSirNick: One other potential place to set enoding is in the JVM opts, -Dfile.encoding=UTF8
18:22Licensermmarczyk: yes but I opt again for 'it just works' as opposed to 'it works fasts if it does and throws odd and totally confusing exceptions if it does not'
18:22mmarczykLicenser: apparently Rich has reversed the current situation with loop/recur... you need to hint to get boxing
18:22Licenserava.lang.IllegalArgumentException: Value out of range for long: 158905670470170624000 does not exactly tell you 'you were using primitves you ape' but rather 'OMFG YOU'RE GOING TO DIE'
18:23Licenserthis is kind of a chrossorad and we need to decide which path to follow and I really hope we concider this very very carefully
18:24briancarpermmarczyk: My RPG has been on hold until Clojure 1.2 is released, I was too distracted porting a bunch of other code. But I plan to pick it up again very soon.
18:24mmarczykbriancarper: cool, I really enjoyed that post and the pixel art is cute :-)
18:24Licensermmarczyk: for all bindings it seems
18:24Licenserlet does the same
18:25Licenserokay now a very crazy suggestion how about adding let' and loop'?
18:25LicenserI know I get shot for this sugestion but it would be, as crazy as it is, a logical way to go
18:25Chousukenooooooooo
18:25Licenserwhenever we have non NumberStack behavior we have a ' at the end
18:25tomojbang
18:26briancarpermmarczyk: Thanks :)
18:26Licenserhow about '' a quote that does primitves?
18:26Licenserbut seriousely this is evil, it will confuse the hell out of everyone but 5 people
18:27Licenserwell 7 since rhickey just told mmarczyk and me
18:27Licenserwe could make loop create overloaded jump points for different kinds of objects? longs and Numbers?
18:28Licensernot sure if that is technically possible
18:28mmarczykLicenser: ...3 of whom are the three-headed dragon who is a thousand years old and lately amuses him/herself by writing Clojure instead of casting spells
18:28Licenserwell wizard spells get boring after you memorized all 9th level ones you know?
18:28mmarczykLicenser: exactly! :-)
18:28Licenserand the other two are rhickey and his shadow I guess
18:29mmarczyk(whew, safer waters again ;-))
18:29defnhey all
18:32Licenserhi defn
18:32Licenserjoin the fun of talking about clojure math
18:33dnolenmmm, colocated Mac Mini 4gb RAM running 1.2 equals branch makes a sweet 2010 64bit Lisp Machine
18:34mmarczykLicenser: rhickey: took the liberty of posting about the primitive-by-default loop locals to the ggroup thread
18:34mmarczykdefn: hi :-)
18:35Licensermmarczyk: oi, as I did
18:35Licenserbut I added 5 lines speach to it :P
18:35mmarczykLicenser: aye, just noticed :-)
18:35Licenserbut you were a minute faster :P
18:35LicenserI think rhickey wil hate us soon
18:36SirNickbriancarper: Alright I'll see how that goes, thanks for the help
18:43AWizzArdrhickey: would it be possible to add some more branches to build.clojure.org?
19:06mmarczykhttp://gist.github.com/444341
19:07mmarczyk^ how come the first (non-static, non-hinted) version seems to be faster than the second (static, hinted) version?
19:09Licensermmarczyk: found another problem, floats
19:10mmarczykLicenser: oh? how come?
19:10Licenserhttp://gist.github.com/444344
19:10Licenserprimitives don't change from one type to another :P
19:12mmarczykoh, that looks buggish
19:13Licensermmarczyk: it makes sense in the way it is implemented but it is horrible
19:13mmarczykyeah, I guess I mean bug-inducing (or sth close)
19:14Licenser*nods*
19:15mmarczykactually in this case the compiler could conceivably discover that the primitive participates in an arithmetic op with a floating-point literal as the other argument
19:15mmarczykalthough if the flonum came from another parameter to the function or a closed-over Var, that wouldn't help
19:17mmarczykrhickey: any chance of having a (num ...) hint, a (prim ...) hint (boxed vs. unboxed) and defaulting to prim in loop when the compiler can prove that that's alright (because of type hints on the enclosing function's parameters etc., say) and boxed otherwise?
19:19mmarczyk(the etc. encompasses hints on the return type, :tag metadata on Vars participating in arithmetic ops inside the loop's body and whatever else I didn't think of)
19:25riddochcI'm curious, what's an appropriate use for the 'reductions' function? I'm sure it *is* useful, but aside from debugging the use of 'reduce', I'm not sure what sorts of problems I'd apply it to.
19:26tcrayford"ls ~/Projects/clojure | wc -l" => 24
19:27riddochctcrayford: It's in the ballpark of my count, too... are you any better at finishing yours than I am? (wouldn't be too hard)
19:29mmarczykriddochc: for one thing, reductions is lazy
19:30mmarczyk(take 5 (reductions + (range)))
19:30tcrayfordriddochc: I don't think *any* of those are anything like finished
19:31riddochcmmarczyk: I suppose reduce can't be lazy, by definition.
19:32tcrayfordman lazytest is hella cool
19:32mmarczykriddochc: Clojure's reduce is a left fold, so it can't be usefully lazy
19:32mmarczykriddochc: a right fold can be lazy in a lazier language (see Haskell) -- then it can work with infinite sequences
19:33RaynesRight folding in Haskell is insane.
19:33RaynesInsane, I say. Insane.
19:34mmarczykactually I suppose Clojure might be lazy enough to do some of the lazy foldr stuff, with a little extra effort expended here and there perhaps
19:34mmarczykRaynes: :-)
19:34tcrayfordits funny how many core functions in haskell can be described usefully using fold and foldr
19:35RaynesI've done so much with foldr that I looked for it for a day straight in Clojure until I realized that reduce was the closest thing I could get.
19:35AWizzArdtcrayford: why do you find it funny/surprising?
19:35mmarczykRaynes: got a good example of an interesting function using scanl? I can't think of one and I know I've seen some... would answer the question about reductions
19:35RaynesThat was ages ago.
19:35AWizzArdreduce = fold
19:35RaynesI've never used scanl. I don't even know what it is.
19:35RaynesAWizzArd: I know.
19:35mmarczykAWizzArd: reduce = left fold
19:35tcrayfordAWizzard: just a nice example of how powerful reduce is
19:35RaynesBut not a right fold.
19:35Licenserwell night people
19:35AWizzArdAnd reduce is the most basic looping construct.
19:36AWizzArdmap and filter are special cases
19:36Licensermmarczyk: keep the fight up! ;)
19:36mmarczykLicenser: good night
19:36mmarczykLicenser: heh :-)
19:36AWizzArdit would be as saying that you find it funny that for-loops are of such big use in C programs
19:36RaynesNight Heinzy.
19:36LicenserNight Raynes
19:36tcrayfordI find reduce somewhat annoying to figure out still
19:36mmarczykLicenser: I know you'll be back here with a flaming sword soon enough :-)
19:36AWizzArdtcrayford: what about for-loops in Java?
19:37Licensermmarczyk: I'm not here tomorrow so you'll have to take the lead for the day
19:37tcrayfordfor loops in java are painful as well :(
19:37tcrayfordtoo verbose
19:37AWizzArdah ok
19:37mmarczykLicenser: I'm no replacement for you, but I'll stay vigilant ;-)
19:37Licenserwe should stop looping of every kind and just write iteratively
19:37AWizzArdWell, just think of reduce (or fold) as a very general looping construct
19:37Licenserheh
19:37Licenseryea few people can be as annoing as I am :P
19:38mmarczyktcrayford: www.cs.nott.ac.uk/~gmh/fold.ps
19:38tcrayfordmmarczyk: already read, and translated into clojure
19:39mmarczykLicenser: 'passionate' is not really 'annoying' :-)
19:39AWizzArdfoldr you can get from (reduce f (rseq coll))
19:40mmarczyktcrayford: well I guess that's mostly on foldr... foldl is equivalent for associative ops though
19:40tcrayfordyeah, its interesting stuff
19:40mmarczykAWizzArd: not really, that wouldn't work with infinite seqs, say
19:40AWizzArdwhat is the "right side" or last element of an infinite seq?
19:41mmarczykAWizzArd: that's irrelevant to foldr
19:41mmarczykAWizzArd: the definition is
19:41mmarczykfoldr f v xs = f (head xs) (foldr f v (rest xs))
19:42mmarczykfoldr f v [] = v, of course
19:42mmarczykso if f can return something useful based on (head xs) alone without caring too much about (foldr f v (rest xs))
19:42AWizzArdDo you have a practical example for such a case?
19:42mmarczykyou've got a result, even though xs might be an infinite sequence (in Haskell, most likely a list)
19:43mmarczykmap ?
19:44AWizzArdmaybe I am confused, but why does this definition of foldr take (head xs)?
19:44AWizzArdshould it not be (last xs)?
19:44mmarczykAWizzArd: nope
19:45AWizzArdso, what does the r then mean?
19:45riddochcIt's about the order of function application.
19:45AWizzArdwhen it goes from the left side through xs’s right side?
19:45mmarczykAWizzArd: if you expand this for an example list of xs, the parens will be in all the right places
19:45mmarczykAWizzArd: (f x1 (f x2 (f x3 v)))
19:46AWizzArdvs?
19:46clojurebotuse vs require is (:use [lib :only [a b c]) or (:require [lib :as alias]) -- (:use lib) is only for playing around
19:46mmarczykAWizzArd: as opposed to (f (f (f v x1) x2) x3) for a left fold
19:47AWizzArdah ok
19:48riddochcSo, I think I had some scheme... (defun foldr (step zero x) (if (null x) zero (step (car x) (foldr step zero (cdr x)))
19:48riddochcEr, define. Sorry.
19:49riddochcAnd (define foldl (step zero x) (if (null x) zero (foldl step (step zero (car x)) (cdr x))))
19:49rbarraud,
19:49clojurebotEOF while reading
19:51riddochcOh, now this is interesting. I hadn't run across it before: http://hyperpolyglot.wikidot.com/lisp
19:51mmarczykAWizzArd: as for the map via foldr, map f xs = foldr (\x v -> (f x):v) [] xs
19:51AWizzArdyes
19:54mmarczykriddochc: keywords are a PLT Scheme thing, though, r5rs doesn't have them
19:55mmarczykriddochc: plus this doesn't make clear the difference between the various vector literals
19:55mmarczyka nice list nonetheless, thanks for the link
19:55briancarperThat site seems to have a lot of inaccuracies in the Clojure column. Defines "atom" as (not (list? x))
19:56mmarczykbriancarper: hm, indeed
19:56mmarczykactually, I'd be hard pressed to come up with a useful definition of atom in Clojure
19:56riddochcYeah, I was noticing their "not possible" thing for "making a standalone executable" in clojure.
19:57mmarczykI think there's "seqable?" is contrib
19:57mmarczyk^in... I wonder if it covers all the cases
19:59riddochcI thought there was some JIT stuff for java that'll actually make a standalone executable, unless I'm mistaken. I've never used it.
19:59briancarpermmarczyk: It couldn't cover all cases, could it? You can define your own seqable things by implementing the right interfaces.
19:59mmarczykbriancarper: there's instance? for that
19:59briancarperAh, right.
19:59briancarperYeah, I just looked at the implementation of seqable?, it's not pretty.
20:00mmarczykbut then you have to decide if Enumerations and Iterators are seqable?
20:00mmarczykI guess enumeration-seq and iterator-seq don't count
20:00mmarczykso probably they're not
20:00mmarczykthen again, because of e.-seq and i.-seq, they're not "atomic" in the traditional sense...
20:01riddochcI can't remember wanting to test for "atomness".
20:01briancarperMe neither, I'm happy to leave it undefined.
20:02mmarczykme neither, and in fact the only way I might lose sleep over this is due to a purely academic desire to come up with an appropriate test :-P
20:02mmarczykgo away!, go away! (the purely academic desire, I mean)
20:14navandreshi
20:15navandresI'm a dummy and I have a question for you
20:15navandrescan I ask?
20:17DarthShrinenavandres: Go ahead
20:17navandresI'm trying to make a simple recursive function
20:17navandresand something is wrong
20:17navandres(defn sumatory [n] (+ (sumatory (dec n)) n) )
20:18mmarczyknavandres: you need a terminating condition
20:18navandresIt suppose to sum from n to 0
20:18navandresyes
20:18navandresI try this also
20:18navandreswithout luck
20:19navandreslet me check that again
20:19mmarczyknavandres: a terminating condition as in (if (zero? n) (return-something) (+ ...recursive call happens here...))
20:20navandresmmm
20:20mmarczykor use (defn s [n] (/ (* n (inc n)) 2)) :-)
20:20navandresI was trying that
20:20navandres(defn sumatory [n] (if (== n 0) 0) (+ (sumatory (dec n)) n) )
20:20navandresthat is wrong?
20:20mmarczykwrong paren placement
20:21mmarczyk(if (zero? n) 0 ...no paren here... (+ ...)...)
20:21mmarczykwhere the final ...) means "close all parens"
20:21navandresok
20:22navandresI'm a little confuse
20:22navandresbut I will try that
20:22navandresthanks
20:22mmarczyknp
20:27tomojrecursion :(
20:28navandreshave no luck
20:29navandres(defn s [n] (/ (* n (inc n)) 2))
20:30navandreswith this function
20:30navandress 5
20:30navandresWhat should I expect ?
20:30tomoj,(+ 1 2 3 4 5)
20:30clojurebot15
20:31mmarczyk,((fn [n] (/ (* n (inc n)) 2)) 5)
20:31clojurebot15
20:31navandresmmm
20:31navandresI'm getting this
20:31navandres#<user$s__4 user$s__4@739e8329>
20:31navandres5
20:31tomojare you actually typing "s 5" to call it?
20:31mmarczyk((fn sum-down-to-zero [n] (if (zero? n) 0 (+ n (sum-down-to-zero (dec n))))) 5)
20:32navandresyes
20:32mmarczyk,((fn sum-down-to-zero [n] (if (zero? n) 0 (+ n (sum-down-to-zero (dec n))))) 5)
20:32clojurebot15
20:32navandres:(
20:32tomojtype (s 5) instead
20:32mmarczykincidentally, the latter idea is not efficient at all
20:32navandresohhhh
20:32navandresI'm soooooo silly
20:32mmarczykloop/recur would be ok... but that's besides the point, I guess
20:33navandresthanks
20:33navandres(s 5)
20:33navandresworks
20:35mmarczyk^beside :-/
20:35navandresall those definitions works now
20:35navandresthanks
20:36navandresis there a way of executing clojure that can load a file also
20:37navandresbecause I'm have to do the load-file every time
20:44vIkSiThmm, what would be the best way of reading a file till EOF in some code like this : http://paste.lisp.org/display/111521 ?
20:47mmarczykvIkSiT: http://stackoverflow.com/questions/2961493/treating-a-file-of-java-floats-as-a-lazy-clojure-sequence/2963984#2963984
20:47mmarczyk(some code by cgrand which does what you want, I think)
20:47vIkSiTmmarczyk, ooh good pointer, thanks
20:48mmarczyknavandres: using load-file is very unusual
20:48mmarczyknavandres: maybe have a look at http://www.assembla.com/wiki/show/clojure/Getting_Started
20:49navandreshehe
20:49navandresyes
20:49navandresI know
20:49navandresthank you
20:50navandresI have to install the eclipse plugin
21:37rhickeyhttp://groups.google.com/group/clojure/browse_frm/thread/c8c850595c91cc11
21:56qbgIf you have to ask for bigints, asking for a non-primitive in recur fits
21:56rhickeyqbg: right, that mismatch was a remnant, it will match the default
21:59AWizzArdin my Clojure version when I have a (loop [x (long 1)] (recur (* x 0.5))) I get ==> java.lang.IllegalArgumentException: recur arg for primitive local: x must be matching primitive
22:00AWizzArdThat's a good solution too.
22:01vIkSiThmm, whats a good way to serialize a protocol?
22:02rhickeyAWizzArd: it isn't because there are plenty of times where the recur args is an object that could init the loop local just fine (loop [x 1] ... (recur (:foo bar)) - if (:foo bar) is an integer (even in a box) that will be fast and correct
22:02qbgvIkSiT: Why do you want to serialize a protocol?
22:02vIkSiTerk. I meant a *record*
22:02vIkSiTok stepping back a bit.
22:03vIkSiTI've got a record that contains a list/vector/map of other records.
22:03AWizzArdrhickey: if the compiler can not prove that (:foo bar) returns a long it could warn, and so one could (recur (long (:foo bar))
22:03vIkSiTAnd I'd like to be able to serialize and store it on disk
22:03vIkSiTqbg, ^ ..
22:03AWizzArdbut another solution could be that x in [x 1] is a number
22:04AWizzArda general one, bigint
22:04AWizzArd(num 1)
22:04AWizzArdit would be confusing if (+ 1 0.1) ==> 1.1 but inside a loop then ==> 1
22:07rhickeyAWizzArd: anf then you learn that loop locals take on the type of their initializer, and you are doing floating point so use a floating point init
22:08AWizzArdThis may not be discovered always, people forget it, don't write test, don't use Coverage tools, etc.
22:09rhickeyAWizzArd: And I should orient Clojure for those people?
22:09AWizzArdIn my opinion the two best solutions would be: 1) using fast primitives but then also static type checking which will emit warnings or erros during compilation when type correctness can't be proven, or 2) having the boxed numbers as default where no errors could sneak in
22:10rhickeyAWizzArd: static type checking is not going to happen any time soon
22:10AWizzArdWell, it is just more complex rule, if (+ 1 0.1) ==> 1.1 outside of loops, but inside loops just 1.
22:10remleduffMy problem with making the loop initializer so magical is java interop. You basically would never feel save initializing a loop variable with an interop form unless you make sure to double-check every time what type the java code returns.
22:11rhickeybut it could go back to being an error, causing more work for some correct code
22:11AWizzArdan error or at least warning would be nice imo
22:11AWizzArd(recur (+ x 0.1)) ==> warning
22:12AWizzArd(recur (my-static-add-that-returns-longs x 0.1)) ==> fine
22:12AWizzArdI don't know if + is the version that returns long or +'
22:13rhickeyAWizzArd: It's the same rule:
22:13rhickey(defrecord Foo [^long x])
22:13rhickey(:x (Foo. 4.2)) => 4
22:13AWizzArdWhen I explicitly specified long I expect that.
22:13rhickeyAWizzArd: it prints warning right now on any mismatch
22:14AWizzArdwarnings/errors are fine, I will be informed as early as possible, which is a good thing
22:14rhickeyuser=> (defn foo [] (loop [x 42] (recur 4.2)))
22:14rhickeyNO_SOURCE_FILE:2 recur arg for primitive local: x is not matching primitive, had: double, needed: long
22:14rhickey#'user/foo
22:15AWizzArdyes, this is good behaviour
22:16AWizzArdI just remember that in the equal branch that Licenser tested some hours ago we discovered that for (defn foo [n] (loop [n n r 1] (if (zero? n) r (recur (dec n) (* r 0.2))))) (foo 3) ==> 0 without that warning
22:17AWizzArdin my (1+ month old) Clojure it returns 0.008
22:18AWizzArdbut when I specified r (long 1) then I got this useful warning
22:41rhickeyAWizzArd: yes, the warnings used to go on with *warn-on-reflection*, now always on
22:44remleduffIs it a technical limitation that makes statics unable to be closures?
22:45rhickeyremleduff: where would their closed-overs go?
22:49remleduffOh, I was picturing them sitting there in the same generated Fn class and using the same closed-overs, but they wouldn't be accessible to static method. :)
22:53remleduffI was wondering why all functions couldn't be implemented in terms of a var wrapping a static method call and then use VirtualMachine.html#redefineClasses to allow dynamicism.