Re: Is this a bug? extending protocol on js/Object

2012-01-13 Thread Dave Sann
Ok, I had assumed from this https://groups.google.com/d/topic/clojure/KQ6AM-nxlTQ/discussion that I could Is there anything else not safe to extend? Cheers D -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to c

Re: Is this a bug? extending protocol on js/Object

2012-01-13 Thread David Nolen
It could create interop problems with other JavaScript libraries (including Google Closure). extending Object modifies its prototype. The problem is that objects are used as maps in JavaScript and these new properties will appear if someone tries to iterate through the keys with for..in. It's unfo

replace-first bug in clojure.string ?

2012-01-13 Thread Eric Fong
Clojure> (require '(clojure [string :as string])) nil Clojure> (string/replace-first "a" #"b" "c") "a" Clojure> (string/replace-first "a" #"b" (comp str last)) nil when pass a pattern and a function to the replace-first function, and the pattern doesn't match the string (first argument), replace-f

ClojureScript One - "No such namespace" error when following "Getting Started" instructions

2012-01-13 Thread utel
The amount of effort that's gone into ClojureScript One initiative is very impressive! Just one question. I've tried following the instructions on the page: https://github.com/brentonashworth/one/wiki/Getting-started All goes well until the step where I evaluate the expression (js/alert "hello")

ClojureScriptOne HelloWorld problem

2012-01-13 Thread Huft
Hi, New to Clojure, excited to take a peek at ClojureScriptOne. Installed it, now running script/run; repl appears, application visible at localhost:8080, clicked 'Development'. Now trying to enter forms at the repl, as per https://github.com/brentonashworth/one/wiki/Getting-started However if

Re: 4Clojure exersice question

2012-01-13 Thread markus
Computers don't accuse, they process data. And they are not (yet?) capable of reading a user's intentions. On 11 Jan., 19:02, Cedric Greevey wrote: > It seems dubious to me that it accuses users of cheating when they > clearly had no intent to cheat. Is this intended behavior of 4Clojure > or a b

Re: [ANN] ClojureScript One - Getting Started with ClojureScript

2012-01-13 Thread Ott Värimäe
Thank you very much! This is earthshaking stuff. And me too hope to contribute soon :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - ple

Re: replace-first bug in clojure.string ?

2012-01-13 Thread Stuart Sierra
Known bug, fix forthcoming. http://dev.clojure.org/jira/browse/CLJ-753 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient wit

Re: Literate Programming in Emacs?

2012-01-13 Thread Stuart Sierra
I was able to get org-babel evaluation working with Clojure. Requires latest versions of Clojure mode, Org mode, and Lein. Check out my dotfiles repo for examples. https://github.com/stuartsierra/dotfiles -S -- You received this message because you are subscribed to the Google Groups "Clojure"

Clojurescript One: (def fiv 5) compiles to ".fiv = 5;\n" ?

2012-01-13 Thread László Török
Hi, first of thank you putting this together. As I'm working my way through the documentation, I'm experiencing a strange error. I have a Clojurescript REPL up and running in Emacs (tested with (js/alert "..")) and I try ClojureScript:one.sample.view> (def fiv 5) I get this: (def fiv 5) "Error

Re: ClojureScriptOne HelloWorld problem

2012-01-13 Thread László Török
Hi, you're probably still in the Clojure REPL, read "Manually starting a ClojureScript REPL" and then refresh the development view in your browser and you're all set. L 2012/1/12 Huft > Hi, > > New to Clojure, excited to take a peek at ClojureScriptOne. Installed > it, now running script/run;

ANN: Clojure 1.4.0-alpha4 release

2012-01-13 Thread Stuart Sierra
Clojure relase 1.4.0-alpha4 has been uploaded to oss.sonatype.org and should be on Maven Central within 24 hours. Patches included in this alpha release: - CLJ-890: tagged reader literals (early draft) - toString caching - Only capture a shallow copy of the current Frame in binding-conveyor-fn

Re: ClojureScriptOne HelloWorld problem

2012-01-13 Thread Huft
Oops! Need to refresh the browser. Works - thanks. On Jan 13, 2:41 pm, László Török wrote: > Hi, > > you're probably still in the Clojure REPL, read "Manually starting a > ClojureScript REPL" > > and then refresh the development view in your browser and you're all set. > > L > > 2012/1/12 Huft >

Re: ClojureScriptOne HelloWorld problem

2012-01-13 Thread Huft
Ah - RTFM - difference between Clojure- and Clojurescript- REPLs - thanks So now I have the Clojurescript REPL running; but entering '(js/alert "hello")' just causes the REPL to hang [doesn't return] On Jan 13, 2:41 pm, László Török wrote: > Hi, > > you're probably still in the Clojure REPL, rea

Re: ClojureScript One - "No such namespace" error when following "Getting Started" instructions

2012-01-13 Thread Brenton
You are trying to evaluate ClojureScript in a Clojure REPL. The easiest way to get a ClojureScript REPL is to run: script/cljs-repl If you start a ClojureScript REPL manually then you always need to load/reload the development page afterwords to establish the connection. On Jan 12, 5:07 pm, ute

Re: ClojureScriptOne HelloWorld problem

2012-01-13 Thread Brenton
The ClojureScript REPL will hang if it is not connected to the browser. Make sure you are on the development page of ClojureScript One, which is the only page that will allow a REPL connection. If you are already there then just refresh the page. The best way to start a ClojureScript REPL is descr

Re: Clojurescript One: (def fiv 5) compiles to ".fiv = 5;\n" ?

2012-01-13 Thread Brenton
I can't reproduce this problem. What you are showing here should work. The following steps work for me: script/cljs-repl ClojureScript:cljs.user> (in-ns 'one.sample.view) ClojureScript:one.sample.view> (def fiv 5) (def fiv 5) 5 On Jan 13, 9:36 am, László Török wrote: > Hi, > > first of thank yo

Help! Migrating to 1.3.0

2012-01-13 Thread labwork07
I have a few issues. What do the following warnings mean and what should I do about them? user=> (require 'mypackage) Warning: *default-encoding* not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic *default-encoding*

clojure.data diff question

2012-01-13 Thread vitalyper
Clojure> (use 'clojure.data) nil Clojure> (doc diff) - clojure.data/diff ([a b]) Recursively compares a and b, returning a tuple of [things-only-in-a things-only-in-b things-in-both]. Comparison rules: * For equal a and b, return [nil nil a]. * Maps are subdiffed where key

Re: Help! Migrating to 1.3.0

2012-01-13 Thread vitalyper
Have seen this as well. For efficiency sake 1.3.0 requires :dynamic meta for convention based ear-muffed vars (intended for rebinding). The warning actually is quite descriptive if you think about it. See more in-depth discussion at http://blog.japila.pl/2011/03/cant-dynamically-bind-non-dynamic-va

Re: Help! Migrating to 1.3.0

2012-01-13 Thread Ben Smith-Mannschott
On Fri, Jan 13, 2012 at 17:47, wrote: > I have a few issues. What do the following warnings mean and what should I > do about them? Did you read them? "*default-encoding* not declared dynamic and thus is not dynamically rebindable" ;; wont' work: (binding [*default-encoding* some-value] (do-

Re: Clojurescript One: (def fiv 5) compiles to ".fiv = 5;\n" ?

2012-01-13 Thread László Török
funny, if I start the cljs repl via script/cljs-repl it works I will look into it, maybe it's Emacs thx 2012/1/13 Brenton > I can't reproduce this problem. What you are showing here should work. > > The following steps work for me: > > script/cljs-repl > ClojureScript:cljs.user> (in-ns 'one.sa

Re: Clojurescript One: (def fiv 5) compiles to ".fiv = 5;\n" ?

2012-01-13 Thread David Nolen
On Fri, Jan 13, 2012 at 12:16 PM, László Török wrote: > funny, if I start the cljs repl via script/cljs-repl it works > > I will look into it, maybe it's Emacs > > thx > Out of curiosity, how were you starting it before? David -- You received this message because you are subscribed to the Goo

Re: ClojureScriptOne HelloWorld problem

2012-01-13 Thread mmwaikar
Right. I had several tabs open, and I was reading the Clojure One tutorial and the same thing happened. Then I switched to the tab with the Development page and then when I ran alert, I saw it there and it returns. -- You received this message because you are subscribed to the Google Groups "Cl

ANN: ClojureScript property access syntax

2012-01-13 Thread Fogus
I've just merged to ClojureScript master the new property lookup syntax as outlined in the ticket http://dev.clojure.org/jira/browse/CLJS-89 and the design page at http://dev.clojure.org/display/design/Unified+ClojureScript+and+Clojure+field+access+syntax. This is a potentially *breaking* change t

Re: Is this a bug? extending protocol on js/Object

2012-01-13 Thread Jozef Wagner
How about using (extend-type default ...) ? Is it safe to use it? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with you

Re: Literate Programming in Emacs?

2012-01-13 Thread Phil Hagelberg
Andrew writes: > Eric asks: The only function ob-clojure uses from swank-clojure is > swank:interactive-eval-region' (used with `slime-eval') in the > org-babel-execute:clojure' function. Which function would now be used > to evaluate a region of clojure code? Would `slime-eval-region' > suffice?

Re: Is this a bug? extending protocol on js/Object

2012-01-13 Thread David Nolen
On Fri, Jan 13, 2012 at 1:32 PM, Jozef Wagner wrote: > How about using (extend-type default ...) ? Is it safe to use it? The question is how to implement that efficiently. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: 4Clojure exersice question

2012-01-13 Thread Cedric Greevey
On Thu, Jan 12, 2012 at 3:31 AM, markus wrote: > Computers don't accuse, they process data. And they are not (yet?) > capable of reading a user's intentions. Technically no, but it's doubtful that a user using a macro like "for" intends to "cheat", so from the *programmer's* standpoint it's not c

clojure clr files ?????

2012-01-13 Thread jayvandal
I have installed clr in a folder called "clr" and have net installed. I can click on main exe and get the clr to give me a repl . When I get ready to create the ui. file in the example where am i storing files In leiningen i create a folder for the project all the files are stored in the project

Map/Reduce Performance Question

2012-01-13 Thread tmountain
I'm playing around with a basic map/reduce pattern with the following code: (ns read-lines.core (:gen-class) (:use [clojure.java.io :only (reader)])) (defn -main [& args] (with-open [rdr (reader "/tmp/mydata.txt")] (let [file-handle (line-seq rdr)] (println (reduce (fn [m x] (inc

Re: Map/Reduce Performance Question

2012-01-13 Thread tmountain
Wow, just by changing pmap to map, the same code runs to completion in 1 minute 35 seconds. I'm guessing this means that context switching caused a huge performance penalty in this case since the "work" being executed was so miniscule? -- You received this message because you are subscribed to th

Re: Map/Reduce Performance Question

2012-01-13 Thread Andy Fingerhut
If I am reading your example correctly, that pmap is simply being used to iterate over the characters of a line read into a string, then yes, you are using pmap in a very inefficient way. pmap creates a future for every element of the sequence you give it, and that is significantly more computatio

Re: Map/Reduce Performance Question

2012-01-13 Thread tmountain
> pmap creates a future for every > element of the sequence you give it, and that is significantly more > computation work (allocating, initializing, and invoking future objects) > than your function that simply returns 1 regardless of the value of its > argument. Makes perfect sense. Thanks for c

`extends?`, `class` and `type` on ClojureScript

2012-01-13 Thread Shantanu Kumar
Hi, I noticed that `extends?`, `class` and `type` are not implemented on ClojureScript (yet) – will they eventually be implemented? Is there a way beside these to determine if a reified object implements a certain protocol? Shantanu -- You received this message because you are subscribed to the

Re: `extends?`, `class` and `type` on ClojureScript

2012-01-13 Thread David Nolen
On Fri, Jan 13, 2012 at 3:36 PM, Shantanu Kumar wrote: > Hi, > > I noticed that `extends?`, `class` and `type` are not implemented on > ClojureScript (yet) – will they eventually be implemented? Is there a > way beside these to determine if a reified object implements a certain > protocol? > > Sha

Re: ANN: ClojureScript property access syntax

2012-01-13 Thread Fogus
Notes from the trenches. I successfully migrated both ClojureScript One and Domina to the new syntax in about ~35 minutes (including tests). I had an unfair advantage having worked on the ClojureScript change, but for your own purposes the following techniques for migration should help: - length

Re: ANN: ClojureScript property access syntax

2012-01-13 Thread Fogus
FYI: You can see my changes to ClojureScript One at https://github.com/brentonashworth/one/tree/props and those to Domina at https://github.com/fogus/domina/commit/cc2ee723b28fd3de6023156cab23b86daaa72210 -- You received this message because you are subscribed to the Google Groups "Clojure" gro

Re: Clojurescript One: (def fiv 5) compiles to ".fiv = 5;\n" ?

2012-01-13 Thread László Török
I have Emacs 24 with and clojure-mode, etc. packages from marmelade under Mac OS 10.6.8. I followed the instructions for Emacs: https://github.com/brentonashworth/one/wiki/Emacs ("For this example, we will start the Clojure REPL ...") When I get to the point, where I have both a Clojure and a C

Re: clojure clr files ?????

2012-01-13 Thread Jeff Dik
On Fri, Jan 13, 2012 at 2:21 PM, jayvandal wrote: > I have installed clr in a folder called "clr" and have net installed. > I can click on main exe and get the clr to give me a repl . When I get > ready to create the ui. file in the example where am  i storing files > In leiningen i create a folde

Re: Help! Migrating to 1.3.0

2012-01-13 Thread Softaddicts
Add meta data in your definitions as in (def ^{:dynamic true} *earmuff* Luc > I have a few issues. What do the following warnings mean and what should I > do about them? > > user=> (require 'mypackage) > Warning: *default-encoding* not declared dynamic and thus is not > dynamically re

Re: Struggling in making a sub-process work in an interactive way

2012-01-13 Thread Denis Labaye
I replied a bit too fast, I didn't realized you wanted to such an advanced thing It is probably more a JVM question than a Clojure question then. On Fri, Jan 13, 2012 at 3:42 AM, jaime wrote: > Well actually I also tried commons-exec but it's the same as > clojure.java.shell - they run system c

Re: Is this a bug? extending protocol on js/Object

2012-01-13 Thread Dave Sann
Now I understand...that makes sense - thanks, D -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To

Re: clojure clr files ?????

2012-01-13 Thread sixs
When I run leiningen , I can execute lein within any folder. For instance I have a folder c:\projects, i run lein new abc. I then have a folder "abc" that is created ,and all the projects files are stored within folder "abc". I installed clojure clr in a folder "clr". I can run clojure.main.exe

Re: 4Clojure exersice question

2012-01-13 Thread Anthony Grimes
Clojail errs on the side of safety and not on the side of "Oh, well maybe he wasn't trying to break the sandbox. Let's allow it anyway.". Treating macros as opaque is just another hole in what is already difficult sandboxing. Macros are not even remotely close to functions. They *create* code.

Re: [ANN] ClojureScript One - Getting Started with ClojureScript

2012-01-13 Thread Dimitre Liotev
Brenton writes: > Today we are releasing ClojureScript One. A project to help you get > started writing single-page applications in ClojureScript. The "script/run" script does not work on cygwin. Here is a patch to fix it. -- Dimitre Liotev -- You received this message because you are subscr

Re: 4Clojure exersice question

2012-01-13 Thread Cedric Greevey
On Fri, Jan 13, 2012 at 6:47 PM, Anthony Grimes wrote: > Clojail errs on the side of safety and not on the side of "Oh, well maybe he > wasn't trying to break the sandbox. Let's allow it anyway.". Treating macros > as opaque is just another hole in what is already difficult sandboxing. > Macros ar

destructing a map with a vector of keys?

2012-01-13 Thread Andrew Xue
trying do something like this (def my-keys [a b c]) (defn my-func [m] (let [{:keys my-keys} m] (prn a b c))) (my-func {:a 1 :b 2 :c 3}) tried '[a b c], ['a 'b 'c], and ["a" "b" "c"] for my-keys but they all give a Don't know how to create ISeq from: clojure.lang.Symbol error thanks andy --

Re: 4Clojure exersice question

2012-01-13 Thread Jack Moffitt
An alternative solution to trying to make macros opaque is just to disallow the macros which depend on disallowed functions. It should be a relatively simple matter to generate this list programmatically from clojure.core source. So instead of just saying "You can't use count." It would say "You c

Re: destructing a map with a vector of keys?

2012-01-13 Thread Cedric Greevey
On Fri, Jan 13, 2012 at 7:49 PM, Andrew Xue wrote: > trying do something like this > > (def my-keys [a b c]) > > (defn my-func [m] (let [{:keys my-keys} m] (prn a b c))) > > (my-func {:a 1 :b 2 :c 3}) > > > tried '[a b c], ['a 'b 'c], and ["a" "b" "c"] for my-keys but they all > give a Don't know

Re: 4Clojure exersice question

2012-01-13 Thread Charlie Griefer
On Jan 13, 2012, at 4:47 PM, Anthony Grimes wrote: > Clojail errs on the side of safety and not on the side of "Oh, well maybe he > wasn't trying to break the sandbox. Let's allow it anyway.". Treating macros > as opaque is just another hole in what is already difficult sandboxing. > Macros ar

Re: Help! Migrating to 1.3.0

2012-01-13 Thread Stephen Compall
On Fri, Jan 13, 2012 at 11:47 AM, wrote: > Warning: *default-encoding* not declared dynamic and thus is not dynamically > rebindable, but its name suggests otherwise. Please either indicate More indirectly, stop using clojure-contrib and move to http://dev.clojure.org/display/design/Where+Did+Cl

Re: clojure.data diff question

2012-01-13 Thread Stephen Compall
On Fri, 2012-01-13 at 09:03 -0800, vitalyper wrote: > Clojure> (diff ["a" "b" "c"] ["c" "d"]) > [["a" "b" "c"] ["c" "d"] nil] > > Looks like the result doesn't match documentation: > "Recursively compares a and b, returning a tuple of > [things-only-in-a things-only-in-b things-in-both]." It does

Re: 4Clojure exersice question

2012-01-13 Thread Anthony Grimes
I responded to this earlier, but I accidentally hit the 'reply to author' button instead of 'reply to post', and thus it went directly to Cedric rather than to the group. I'll respond here and quote the previous emails: On Fri, Jan 13, 2012 at 8:57 PM, Anthony Grimes wrote: > 4Clojure uses cl

is there some way to extract the parameter list from a function

2012-01-13 Thread Andrew Xue
given something like (defn my-func [a b c] (str a b c)) is there something like (extract-parameters my-func) which returns (a b c)? thanks, andy -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegrou

Re: is there some way to extract the parameter list from a function

2012-01-13 Thread Baishampayan Ghose
Something like (:arglists (meta #'my-func)) ? Regards, BG On Sat, Jan 14, 2012 at 12:01 PM, Andrew Xue wrote: > given something like > > (defn my-func [a b c] (str a b c)) > > is there something like (extract-parameters my-func) which returns (a > b c)? > > thanks, > andy > > -- > You received t

Emulating inheritance on protocols in ClojureScript.

2012-01-13 Thread Takahiro Hozumi
Hi, I want to set a default behavior on a protocol. The following article describes how to implement inheritance in Clojure by using `extend`, but `extend` doesn't exist in ClojureScript. Is there a way to set a default behavior on a protocol in ClojureScript? (david-mcneil.com :blog), Implementat

What is the idiomatic way to compare data structures with BigDecimal instances

2012-01-13 Thread blais
;; BigDecimal comparisons do not appear to work as I ;; would have expected them to: (= 2e+3M 2000M) ;; -> false ;; Looking at the definition of '=', I can see that ;; it defers to clojure.lang.Util/equiv, which ;; compares them as Object, by reference. Fine. ;; I thought I could use equals,