#clojure log - Apr 10 2013

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

17:08 tbaldrid_: these are reader issues, legal symbols can be anything.

20:10 neilmarcus: hello?

20:10 clojurebot: BUENOS DING DONG DIDDLY DIOS, fRaUline neilmarcus

20:25 ravster: whats the max that java.lang.Integer can go to? I'm trying to use the java.awt.Polygon class to find if a given latitude and longitude is part of a polygon, and I'm not sure by how many decimal places I can move a value (Egs: latitude 44.35745968346 -> 4435745968346 )

20:26 hiredman: ,Interger/MAX_VALUE

20:26 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: Interger, compiling:(NO_SOURCE_PATH:0:0)>

20:26 hiredman: ,Integer/MAX_VALUE

20:26 clojurebot: 2147483647

20:26 hiredman: ,Integer/MIN_VALUE

20:26 clojurebot: -2147483648

20:26 hiredman: ,Long/MAX_VALUE

20:26 clojurebot: 9223372036854775807

20:26 hiredman: ,Long/MIN_VALUE

20:26 clojurebot: -9223372036854775808

20:27 ravster: hiredman: oh, I wish I could use longs. But the Polygon class doesn't seem able to consume them.

20:27 hiredman: and thanks for the answer. :)

20:29 * ravster doesn't like arbitrary limits to argument values.

20:29 * ravster *grumble* *grumble*

20:38 noprompt: when using require is it possible to both refer and rename?

20:40 or is it ok to use use in that case?

20:42 oh, there it is.

20:46 bttf: brand new to clj ... just wrote some code in my core.clj, trying to run it in my 'lein repl' ... i do (in-ns 'testing-clj.core) to get into the namespace but it seems not able to see my symbols

20:49 https://gist.github.com/bttf/776f7389cd96b4743dd7

20:51 it seems that i'm entering that namespace but completely separate from what i have defined in src/testing_clj/core.clj

20:53 ivan: does it work without (:gen-class)? are you sure you're doing (in-ns 'testing-clj.core) and not (in-ns 'testing_clj.core)?

20:54 `hello` shouldn't even compile because `hi` is defined after it, though I don't know how AOT works with that

20:54 bttf: ivan: thanks for replying, i have since removed (:gen-class) since i am not using it ... when I do lein compile i get no output whatsoever .. i don't even know if lein see's the file

20:55 i mean, i just generated a new project ,wrote the code and did a 'lein compile'

20:55 ivan: you don't need to lein compile before lein repl

20:56 bttf: ok

20:57 and yes i'm sure i am doing (in-ns 'testing-clj.core)

20:58 i've rearranged the functions, same issue

20:58 * ivan tries

21:00 ivan: bttf: I'm probably missing something obvious, it's not working here either

21:01 bttf: ok ... does somehing need to be specified in the project.clj ? id assume that it should be set to go

21:03 ivan: bttf: maybe it's because your directory starts with "test"

21:04 lein might be ignoring those by default

21:04 bttf: weird, let me try

21:04 ivan: make sure you change the (ns too

21:06 bttf: heh, actually you need to (require 'testing-clj.core) first

21:06 (in-ns) does not seem to load things

21:06 dakrone: amalloy_: cool, will look when I can

21:07 bttf: ivan: ahh that works, thank you

21:09 mdeboard: brehaut: re: named groups https://gist.github.com/mattdeboard/5359853

21:10 I find it hard to believe this doesn't exist already

21:11 ivan: bttf: you can put :main testing-clj.core in project.clj to load and enter that namespace

21:13 bttf: ah cool thanks

21:14 jhawk28: can anyone give be some suggestions on creating a DSL?

21:14 I want to create a subset of the language that is mainly arithmetic/boolean with some specific functions

21:15 but I need to to be limited since the code is "dynamic" and can potentially be unsafe

21:16 is there a way to remove all functions from the dsl's namespace and only add in the specific ones I want?

21:16 or do I need to just read in the data as ebn and then execute it myself

21:17 ivan: I think I would use edn and a whitelist

21:17 mthvedt: jhawk28: you want to read in untrusted data that's a subset of clojure?

21:17 nightfly: clojail might be useful

21:17 jhawk28: yes, a subset

21:18 bttf: ivan: what about reloading a file in the repl? i'm trying (load-file) but its not cooperatng

21:19 mthvedt: you could walk the tree and throw out anything not on the whitelist

21:19 ivan: bttf: probably (require 'testing-clj.core :reload)

21:19 mthvedt: after reading it in as edn

21:19 ivan: there's also a :reload-all

21:20 also nrepl.el has many conveniences for sending new forms to the repl

21:20 bttf: nice, it works

21:21 ill check out nrepl.el

21:22 there isn't a vim equivalent is there? ;)

21:22 brehaut: mdeboard: cool; pity you have to double handle the group names :/

21:22 mdeboard: Yeah. Either that or uh

21:22 parse the patterns :P

21:22 nothx

21:22 jhawk28: thanks, I think the edn or the clojail may work

21:22 brehaut: (╯°□°)╯︵ ┻━┻

21:22 mdeboard: brehaut: I'm sure there's a much better way of handling that

21:22 ┬──┬◡ノ(° -°ノ) chill out bro

21:22 dat emacs macro

21:23 ivan: bttf: I hear people use https://github.com/tpope/vim-fireplace

21:23 mdeboard: never got to use it in the wild before

21:23 brehaut: ha

21:23 bttf: brehaut: are you flipping tables

21:23 brehaut: yes

21:23 bttf: awesome

21:23 brehaut: regexps bring out the worst in me

21:29 ,(re-pattern (str #"\w" #"\d")) ; mdeboard

21:29 clojurebot: #"\w\d"

21:29 brehaut: mdeboard: that'll save you having to escape all your slashes in your regexps

21:36 mdeboard: brehaut: Oh, didn't think that works, using the regex reader

21:37 as args to str

21:37 brehaut: mdeboard: str takes anything that has a toString method (ie, everything)

21:38 regex patterns happen to have a very useful toString

21:38 its perhaps not immediately obvious though; i learnt the trick from weavejester

21:42 mdeboard: brehaut: Cool, thanks for the pointer

21:56 mikepence: reading the joy of closure

21:56 <3 new stuff

22:05 bttf: anyone good with vim-fireplace in here ?

22:07 TimMc: Almost certainly. If you have a question, ask and find out!

22:10 joegallo: that was the question, he was just checkin' ;)

22:11 bttf: well, i'm moving my cursor to a namespace and trying 'gf' .. it's complaining about several things, the first one is that its unable to resolve a symbol that i've not implemented yet (this is the test)

22:11 and when i try :Eval ( ... ), whatever i try it gives me the same complaint of unable to resolve symbol

22:12 tpope: is your file requirable?

22:15 bttf: tpope: my apologies, the hopping stops here

22:16 in the repl i can require the file no problem

22:16 is there a fireplace command for require

22:17 tpope: there is, :Require

22:17 it also implicitly requires the current namespace if it's your first time evaluating code in it

22:18 which I assumed was what was failing, albeit with a pecular sounding error

22:18 can you refheap the error?

22:18 use :messages to see it again

22:19 bttf: i don't see the 'unable to resolve symbol' errors in messages

22:19 but i do see the others, dealing with 'Error detected while processing function <SNR>36_GF..fireplace#findfile..<SNR>36_eval'

22:20 tpope: what are you pressing gf on?

22:20 bttf: https://gist.github.com/bttf/808d402bea36784c1eb4

22:21 https://gist.github.com/bttf/4db2ea0d2bf7d3a31dbc line 3 is what i'm gf-ing

22:23 tpope: https://github.com/tpope/vim-fireplace/issues/44#issuecomment-16054922

22:23 is that your alterego? same error right down to the example

22:24 oh, because it's from the tutorial, herp derp

22:24 bttf: nope and yes, the tut

22:25 tpope: bttf: to be clear, you can require the *test* file, correct?

22:26 bttf: (clojure.core/require 'command-line-args.core-test :reload)

22:26 CompilerException java.lang.RuntimeException: Unable to resolve symbol: parse-args in this context, compiling:(command_line_args/c

22:26 nope

22:26 tpope: well, that's the root of the problem

22:26 the error is messier than it should be

22:27 bttf: messier or misleading?

22:27 tpope: it says couldn't require command-line-args.core-test plain is day

22:28 it's just surrounded by 5 lines of vim garbage

22:28 bttf: oh i see

22:29 but when I require the test, i only get the error i pasted just above

22:29 unless the other erros are hidden away somewhere

22:29 tpope: well it's one level of abstraction up. requiring the file tells you what went wrong. doing something that implicitly requires the file tells you the file couldn't be required

22:30 I just reproduced it. there's another error that happens at the top that tells you exactly what you're looking for

22:30 mthvedt: is there a macro that's like memoize, but for an inline chunk of code

22:31 to execute it exactly once

22:34 amalloy: mthvedt: delay

22:35 tpope: bttf: I just cleaned up the error on gf and ]d. let me know if you find others

22:35 bttf: alright, ill give it a try

22:36 mthvedt: amalloy: delay returns an object that can be derefed, i want to skip that intermediate step

22:36 amalloy: mthvedt: in that case, all code always, is executed exactly once :P

22:37 mthvedt: it would have made this one thing i'm writing more readable… but never mind

22:41 bttf: tpope: looks good so far

22:42 but cpR isn't doing anything for me.

22:42 and i've deleted my function definition from the code and the test isn't giving me the unresolved symbol error that it should, i believe

22:43 tpope: well it only requires once

22:43 after that it's up to you to reload

22:44 bttf: and cpr reloads, no ?

22:46 cpR should reload-all, but i don't see it happening. if i do cpr on each file, i dont see any errors

22:46 tpope: cemerick made me take away cpR :(

22:47 bttf: ooh

22:47 tpope: you can :Require! to reload-all

22:47 * bttf throws shoe at cemerick

22:47 bttf: ok

22:47 still no dice

22:49 tpope: well try :Eval (require ... :reload-all)

22:49 that's all :Require! is doing

22:50 bttf: i did :Eval (require 'command-line-args.core) :reload-all

22:50 then I did, :Eval (clojure.test/run-tests)

22:51 and im seeing errors from when my function existed

22:51 tpope: re-requiring a file doesn't delete the old namespace first

22:52 you can ns-unmap, or just restart your repl

22:52 bttf: interesting

22:52 but if i make changes to my source, shouldnt it automatically update namespace?

22:53 maybe im missing something here

22:53 tpope: ignoring your use of "automatically", it doesn't remove anything

22:54 if you defined a function, it's not automagically undefined just because you deleted it from the file

22:56 bttf: heh

22:56 i guess if the behavior of the function is changed that will be reflected when reloaded

22:57 but if its flat-out deleted? shouldn't that somehow be reflected the same way?

22:57 i guess the repl isn't made to work like that

23:08 thx for the help tpope

23:09 tpope: ta

23:44 dr_choc: Anyone here mess around with clojurescript? Specifically the browser repl?

23:46 brehaut: ~anyone

23:46 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

23:46 brehaut: (inc amalloy)

23:46 lazybot: ⇒ 49

23:52 dr_choc: Has anyone found the cljs browser repl to be finicky? I'm using the lein-cljsbuild plugin and running lein trampoline cljsbuild repl-listen to get a repl, but sometimes it works and sometimes it just hangs as if the browser never connected, but I can see in the network tab (chrome) that it does connect. Any ideas?

Logging service provided by n01se.net