#clojure log - Jan 01 2011

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:00 Crowbar7: Happy New Year!

0:00 qbg: Still an hour to go here

0:00 Raynes: Happy new year for those in the eastern time zone.

0:00 qbg: Likewise.

0:01 programble: stupid non-easterners

0:10 auser: okay... so um... I have a LazySeq... can I transform it into a non lazy sequence?

0:11 qbg: ,(doc doall)

0:11 clojurebot: "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."

0:11 qbg: ^ Likely what you want

0:12 auser: I see... can you do a filter inside of a doall?

0:12 qbg: ,(doall (filter odd? (range 10)))

0:12 clojurebot: (1 3 5 7 9)

0:13 qbg: doall works on any seq

0:14 Raynes: &(apply str (reverse (map #(.toUpperCase (str %)) (interleave [\r \e \space \e \space \p \a] [\a \y \w \n \y \p \h]))))

0:14 sexpbot: ⟹ "HAPPY NEW YEAR"

0:15 auser: nm, it worked

0:15 thanks

0:17 qbg: Tasty new year goodness: https://github.com/qbg/syntax-rules/wiki/defn-implementation

0:18 cemerick: qbg: looks like you've got something serious cooking over there :-)

0:19 qbg: git log --oneline | wc -l reports 42 commits so far...

0:20 Templates are terrible; I need to create more powerful ones sometime later

0:21 I also need to get it supporting lexical scope in +code templates

0:21 And fix the progress implementation

0:21 etc. *sigh*

0:24 The pattern matcher could be cleaned up too; its currently 471 lines in a single file

0:25 Should do an alpha release either tomorrow or the day after

0:28 cemerick: qbg: the defn walkthrough helps me see things dimly :-)

0:29 Some side-by-side syntax-quote vs. syntax-rules macros would likely be a good addition.

0:29 qbg: Yeah, it needs to be improved before I make a release

0:30 syntax-quote annoys me so much right now; I'm basically reimplementing it in the templates

0:30 I want to snarf parts of it, but its implemented in the reader...

0:32 cemerick: I've reimplemented a few macros from core in src/qbg/syntax-rules/examples.clj

0:32 https://github.com/qbg/syntax-rules/blob/master/src/qbg/syntax_rules/examples.clj

0:39 I also need to change the name; its actually syntax-rules + syntax-case, with many of the advanced patterns from syntax-parse also being supported

0:41 cemerick: I guess I'll finally have to buckle down and learn them finally :-)

0:44 qbg: syntax-rules and syntax-case are easy enough

0:45 syntax-parse is quite new (it has been in Racket for about a year)

0:46 It adds more powerful patterns and a focus on good error messages

0:46 Who can resist good error messages for free after all?

0:58 Happy New Years from CST

1:02 Raynes: qbg: Happy New Years! :>

1:02 qbg: :D

1:03 I wonder what will happen in the next year of Clojure

1:03 About this time last year 1.1 was released; so much has happened since then

1:03 Raynes: qbg: At least two books will come out sometime in the early months of 2011. Another Conj conference in October. Rich Hickey's hair will become more curly. All sorts of awesome stuff.

1:04 qbg: (read: Clojure development has _NOT_ stalled)

1:11 ivey: Raynes: happy new year

1:11 'bama time

2:05 Gigaroby: happy new year everyone

6:44 ejackson: Happy 2011 #Clojure.

6:44 kumarshantanu: ejackson: +1

6:46 xenyl: 1 year to go for 2012, cool :)

6:50 ejackson: although today is 1/1/11 which is worth celebrating, if only for the fact that the US and rest of the world can agree on how to write it. :)

6:52 kumarshantanu: ejackson: more debatable date of th year -- 11/11/11

6:55 ejackson: that's more fun

6:55 kumarshantanu: Japan probably writes yyyy-mm-dd, so I guess 11/11/11 will get them too ;-)

6:56 Adamant: kumarshantanu: I don't think anyone does that unless they do ISO dates

6:56 that's kinda why they chose it

6:56 less to bitch about while being unambiguous

6:57 ejackson: love the Japanese

6:58 kumarshantanu: Adamant: ISO dates are such a spoilsport *grin*

6:59 Adamant: :P

6:59 trolling, trolling, to keep those lines scrolling

6:59 I almost lost control and, replied!

7:02 fliebel: good morning, and happy new year!

7:07 kumarshantanu: fliebel: happy new year (oh.. what's the IRC mechanism of RT?)

7:07 fliebel: $sed -kumarshantanu s///

7:07 sexpbot: fliebel: Format is sed [-<user name>] s/<regexp>/<replacement>/ Try <prefix>help sed

7:07 kumarshantanu: RT as in Re-Tweet

7:08 fliebel: I was trying to trick sexpbot into repeating your message :

7:08 :)

7:10 kumarshantanu: $sed -fliebel s/x/x/

7:12 can anybody talk about how are dynamic vars distinguished from static ones in Clojure 1.3 ?

7:13 what is the syntax?

7:13 do I still get to earmuff them etc?

7:17 fliebel: kumarshantanu: I don't know much about them, but it seems rather quiet in here, so I'll just try my best.

7:17 kumarshantanu: fliebel: sure, please go ahead

7:18 fliebel: From what I understand, vars are static by default in 1.3, so you can't change them at all.

7:18 An optimization of some sort.

7:18 Then you can add ^:dynamic metadata to them, and they work like vars work currently.

7:19 earmuffs are still a good convention for marking dynamic vars, but it just that, a convention.

7:20 kumarshantanu: fliebel: is it like (def ^{:dynamic true} *dyn* "ha ha, dynamic") ?

7:21 fliebel: kumarshantanu: I never use metadata much, but if that is the syntax, yes.

7:22 kumarshantanu: fliebel: Okay...in fact I am writing some code using 1.2 that I might adjust to support 1.3

7:23 fliebel: thanks!

7:23 fliebel: kumarshantanu: I'm sure though there was a shorthand for the dynamic.

7:26 kumarshantanu: You might want to try this: (def ^:dynamic *test* "hoi")

7:27 kumarshantanu: okay..need to setup 1.3 JARs *lazy* :)

7:28 ejackson: my first 2011 New Years resolution is to step up to 1.3

7:31 fliebel: What is the latest 1.3 alpha?

7:33 (and is Cake already working with that?)

7:40 kumarshantanu: alpha4 I guess, not sure about Cake

8:07 fliebel: I tested with alpha-4 -- that works, and so does ^{:dynamic true :doc "Some documentation abt the var"}

8:08 fliebel: kumarshantanu: Good.

8:10 Does anyone in here understand Gloss? Because I don't… I'm trying to read some weird binary format.

9:35 How can I possibly figure out Gloss? Unless I figure out the whole thing at once, I can't even toy with it: java.lang.Exception: Bytes left over after decoding frame.

9:40 mids: what are you trying to do? pastebin?

9:40 fliebel: mids: Pastebin a binary file? Strange sense of humor ;)

9:41 I'm doing http://www.minecraft.net/docs/NBT.txt with https://github.com/ztellman/gloss/wiki/Introduction and I got this: (defcodec nbt (ordered-map :type (enum :byte :end :byte :short :int :long :float :double :bytes :string :list :compound) :name (finite-frame :byte (string :utf-8))))

9:43 mids: getting 404s on their test .nbt files

9:44 fliebel: Me to… Try this: http://dl.dropbox.com/u/10094764/World2.zip

9:44 Is there an easy way to look at binary files to study the actual data?

9:45 mids: on unix; hexdump

9:46 kumarshantanu: fliebel: maybe you should develop functions to output/parse binary files vs "od -x filename.bin" first for pastebin ;-)

9:48 fliebel: kumarshantanu: I don't think I get you…

9:48 mids: fliebel: are you gunzipping the data before decoding?

9:48 kumarshantanu: pastebin won't take binary files, so why not paste the output of this -- $ od -x filename.bin

9:49 fliebel: mids: No, I'm putting them through GZIPInputStream ;)

9:51 http://pastebin.com/0CW1KRDK

9:51 What are all the null bytes?

9:53 What is supposed to be there I think is 0a 0a and then 10 bytes of text.

9:54 kumarshantanu: generally ZIP uses symbols to pack data...null bytes may be the filler for every block

9:54 fliebel: kumarshantanu: But this is not zipped data anymore, right?

9:55 kumarshantanu: fliebel: oh, didn't notice that..okay

9:58 fliebel: So, the strange thing is that there are more bytes then I expected reading the spec.

11:05 ruhe: Hi folks. I'm trying to pass sequence to function which accepts an "&" argument. But without any success yet. Is this possible? Example: < (struct mystruct (map fn collection)) >

11:05 fliebel: ruhe: apply?

11:06 ruhe: fliebel: could you please provide an example?

11:06 raek: &(max 1 2 3)

11:06 sexpbot: ⟹ 3

11:07 raek: &(apply max [1 2 3])

11:07 sexpbot: ⟹ 3

11:07 ruhe: ok, got it

11:07 thanks guys

11:07 raek: also (apply f a b c [d e f]) is the same as (apply f [a b c d e f])

11:08 so you can add some arguments in front of the ones from the collection

11:18 BobFunk: anyone here using got the clojure bundle for TextMate to work with rvm?

11:37 currentB: `(reduce #(into [] %) [1 2 3 4 5])

11:38 &(reduce #(into [] %) [1 2 3 4 5])

11:38 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: sandbox6382$eval8585$fn

11:39 raek: &(reduce conj [] [1 2 3 4 5])

11:39 sexpbot: ⟹ [1 2 3 4 5]

11:39 currentB: thanks :)

11:39 raek: into is defined using reduce and conj

11:40 &(into [] [1 2 3 4 5])

11:40 sexpbot: ⟹ [1 2 3 4 5]

13:55 fliebel: Can anyone help me with reading some binary data with Gloss? Gloss: https://github.com/ztellman/gloss/wiki/Introduction Data: https://github.com/preble/InsideJob/raw/master/test.nbt Spec: http://www.minecraft.net/docs/NBT.txt Code: http://pastebin.com/M4KA6am1

14:22 Null-A: My job uses clojure, starting in a few days :)

14:22 need to learn it

14:23 I really liked "How to write a scheme interpreter in haskell" is there anything similar for clojure?

14:28 qbg: People have done exercises from SICP in Clojure

14:36 Null-A: qbg: interesting, hadn't heard of SICP

14:36 qbg: It is a classic book

14:36 Uses Scheme, but is more about programming than Scheme

14:36 Null-A: have you read joy of clojure?

14:37 qbg: I've looked through it

14:37 Programming Clojure is another good book

14:37 Null-A: what do you think is the best starting point between the two?

14:37 or the three

14:37 I know some haskell, and lots of C++

14:37 Raynes: Programming Clojure is fairly outdated, and will be even more outdated when 1.3 comes out.

14:38 Practical Clojure is probably the next logical step after Programming Clojure.

14:38 The Joy of Clojure is a fantastic book.

14:38 Null-A: *nods*

14:38 maybe start there..

14:39 qbg: It's hard for me to evaluate The Joy of Clojure because I already knew a lot of Clojure by the time I read it

14:39 Seems like it should be a good book

14:43 Null-A: scip first chapter is already pretty enlightening

14:43 sicp*

14:44 qbg: The video lectures that follow the first edition are also amazing

14:44 Raynes: Remember that Scheme and Clojure are two very different languages, albeit Lisp languages.

14:45 Null-A: Raynes: I'm reading sicpinclojure.com that should help

14:46 Raynes: :)

14:48 MayDaniel: Null-A: sicpinclojure.com is (I think) just SICP at the moment, with no Clojure.

14:48 Null-A: oh ok

14:48 Raynes: MayDaniel: It is? Darn, I presumed that at least /some/ progress had been made.

14:49 s/presumed/assumed/

14:49 sexpbot: <Raynes> MayDaniel: It is? Darn, I assumed that at least /some/ progress had been made.

14:49 MayDaniel: I thought they'd adapted a little to Clojure, but checking the "Current Status" page, apparently not.

14:50 Null-A: Raynes: heh, that's a subtle distinction between the two terms

14:51 Raynes: $seen cemerick

14:51 sexpbot: cemerick was last seen quitting 3 hours and 5 minutes ago.

14:51 LauJensen: I saw a website with quite a few SICP lessions translated to Clojure a year or so ago

15:23 qbg: Now better explained: https://github.com/qbg/syntax-rules/wiki/defn-implementation

15:59 serp__: I have something bound to the variable x. how do I check if it's a sequence?

16:00 fliebel: serp__: ##(seq? (list 1 2 3))

16:00 sexpbot: ⟹ true

16:00 Raynes: &(seq? '(1 2 3))

16:00 sexpbot: ⟹ true

16:00 Raynes: &(seq? [1 2 3])

16:00 sexpbot: ⟹ false

16:00 serp__: oh..

16:00 fliebel: &(coll? [1 2 3])

16:00 sexpbot: ⟹ true

16:00 opqdonut_: &(not (nil? (seq [1 2 3])))

16:00 sexpbot: ⟹ true

16:00 opqdonut_: that's what I use...

16:01 Raynes: opqdonut_: A vector isn't a sequence, so your example is actually incorrect.

16:01 It is, however, sequential: ##(sequential? [1 2 3])

16:01 sexpbot: ⟹ true

16:02 opqdonut_: (.class '(1 2 3))

16:02 gah

16:02 &(.class '(1 2 3))

16:02 sexpbot: java.lang.IllegalArgumentException: No matching field found: class for class clojure.lang.PersistentList

16:02 qbg: ,(class '(1 2 3))

16:02 clojurebot: clojure.lang.PersistentList

16:02 opqdonut_: there

16:02 qbg: ,(class (seq [1 2 3]))

16:02 clojurebot: clojure.lang.PersistentVector$ChunkedSeq

16:02 Raynes: PersistentList implements the seq API directly, so it is an actual seq.

16:03 opqdonut_: anyway, I find it kinda weird that a list is a sequence according to... oh

16:03 okay

16:03 qbg: Don't use list? to check for seqs

16:03 fliebel: serp__: As you see, it completely depends on what you want to know and consider a sequence.

16:04 opqdonut_: indeed

16:04 Raynes: &(parents clojure.lang.PersistentList)

16:04 sexpbot: ⟹ #{clojure.lang.ASeq java.util.List clojure.lang.IReduce clojure.lang.IPersistentList clojure.lang.Counted}

16:06 fliebel: &(ancestors clojure.lang.PersistentList)

16:06 sexpbot: ⟹ #{clojure.lang.IPersistentStack clojure.lang.Sequential clojure.lang.IPersistentCollection clojure.lang.ASeq java.lang.Object java.io.Serializable clojure.lang.IObj java.util.List clojure.lang.IMeta java.lang.Iterable clojure.lang.IReduce java.util.Collection clojure... http://gist.github.com/762007

16:20 dsop: hmm is there a way to define a private method in a deftype?

16:21 qbg: dsop: Why would you want such a thing?

16:21 dsop: qbg: to encapsulate helper methods

16:22 qbg: Any reason why your helper methods can't be regular functions?

16:22 dsop: no, they can, just asking myself if there is a way

16:22 qbg: protocols = interfaces

16:23 So no

16:35 fliebel: dsop: Put only in the interface what belongs to the api, helper functions are an implementation details, so don't put them in a protocol.

17:15 BobFunk: trying to get https://github.com/gcv/appengine-magic to work - but can't start the app from the repl

17:16 works fine when running appengine-prepare and then dev_appserver.sh

17:16 but when trying (ae/start my-app) - I just get: java.lang.Exception: No such var: ae/start (NO_SOURCE_FILE:3)

17:31 hmm, why would I get "java.lang.Exception: Unable to resolve symbol: compile in this context" from the lein repl ?

17:34 tonyl: is ae imported/required/used before being used?

17:34 I don't know about appendine-magic, but that might be a problem

17:37 leafw: hi all. 'd apreciate help on figuring out why a loop gets number boxing warnings, when it shouldn't: http://clojure.pastebin.com/9uLZqGhy

17:37 BobFunk: managed to advance a bit by including swank in the dev dependencies

17:38 leafw: the loop is defined as (loop [l (int left) r (int right)], and then only dec and inc are used on such numbers.

17:41 BobFunk: now I'm just getting a java.lang.NullPointerException when trying to start the app

17:44 any hints on how to get some more info on the error from the repl?

17:46 qbg: (.printStackTrace *e)

17:46 BobFunk: thanks

17:54 raek: hrm, did 'num' have something to do with this?

18:32 rak85: hi

18:34 auser: hola

18:34 op later

19:51 is there a way to pause a thread?

20:01 or wait()

20:02 pdk: (Thread/sleep) ?

20:03 auser: no... that just sleeps

20:03 basically I have a reference that holds a boolean. I want to be able to pause/resume the thread based on the value of the (ref)

20:05 doesn't seem like it should be difficul

20:05 t

20:06 right?

20:12 pdk: hmm

20:12 this'll probably sound dumb but have you read up on the promises/futures features in clojure

20:19 auser: yeah, guess so

20:48 bendlas: (contains? (transient {:x 1}) :x)

20:48 ,(contains? (transient {:x 1}) :x)

20:48 clojurebot: false

20:48 bendlas: ,(clojure-version)

20:48 clojurebot: "1.2.0"

20:48 bendlas: &(clojure-version)

20:48 sexpbot: ⟹ "1.2.0"

Logging service provided by n01se.net