Re: Teaching Clojure to students (how ?)

2013-10-05 Thread Takahiro Hozumi
motivation, all interesting knowledge will vaporize. Immutable? It must be something great! but I don't care. Cheers, Takahiro 2013/10/6 bernardH un.compte.pour.tes...@gmail.com Hi all, I intend to (ab)use my authority as a teacher to enlighten unsuspecting students about Clojure. On the plus

Re: [ANN] 美味しいClojure

2013-10-03 Thread Takahiro SAWADA
of the meet-up. The language spoken there is Japanese. Unfortunately here in Tokyo we have not formed a tight community while the number of Clojurians is obviously increasing. I am looking for some good ways to set-up a core of the community here. Cheers, Takahiro SAWADA 2013年10月3日木曜日 16時07分55秒

Re: Can we please deprecate the :use directive ?

2013-08-03 Thread Takahiro Hozumi
is there for. Takahiro On Sunday, August 4, 2013 11:25:34 AM UTC+9, Ye He wrote: Yesterday, I spent hours trying to figure out why some code didn't work. The code is like so: (defn replace-symbol-in-ast-node [old new ast] (tree-replace (symbol old) (symbol new) ast)) I use tree-replace

Re: Does this abstraction have any existing name?

2013-07-26 Thread Takahiro Hozumi
I think clojure.walk is suited to this purpose. https://github.com/clojure/clojure/blob/master/src/clj/clojure/walk.clj See keywordize-keys as an example. On Saturday, July 27, 2013 2:31:21 AM UTC+9, Yoshinori Kohyama wrote: Thank you Gary. There's no reason why this need to be a macro. It

Re: Can we please deprecate the :use directive ?

2013-07-24 Thread Takahiro Hozumi
I hate it mainly in blogs, where they explain some new API. They :use like 3 namespaces and you have to guess which fn is from which ns :) Agree. Code is read much more often than it is written, so omitting a few character is not effective time-saving. I also don't like :refer :all. I think it

Re: [ANN] http-kit 2.1.1. Bug fix release, please upgrade if using the WebSocket

2013-05-06 Thread Takahiro Hozumi
Shen, Thank you for your announcement. 2013/5/6 Shen, Feng shen...@gmail.com Hi, It's a bug fix release. *If using the WebSocket support, please upgrade. All older version has this bug.* The bug is Large websocket requests get corrupted. Detail:

Re: Prismatic Plumbing and Graph Open-Source Release

2013-02-09 Thread Takahiro Hozumi
Thanks for amazing work! I want to know how typical CRUD application is implemented. Do you use single gigantic graph with lazy-compile or separated graph for each operation? How do you handle validation and error? Will almost all x-y function disappear? On Jan 30, 3:46 am, Aria Haghighi

Re: Efficient idioms to handle large lists?

2013-02-01 Thread Takahiro Hozumi
Hi Bruce, Try `into` instead of `concat`. Applying concat to growing data is like Schlemiel the Painter's algorithm. Cheers. On 2月1日, 午後4:19, bruce li leilmy...@gmail.com wrote: Hello, everyone. I'm experience some performance issue when using clojure. The scenario is as follows: I have a

*read-eval* vulnerability

2013-01-29 Thread Takahiro Hozumi
As more and more projects are using edn format for config, communication and etc, I think that default value of *read-eval*, which is true, is source of vulnerability such as recently reported ring issue [1]. And I don't understand why read-string depends on *read-eval* instead of argument. I

Re: Where did the idea of metadata come from?

2012-11-14 Thread Takahiro Hozumi
Paul, Raoul, David, Mimmo, JvJ, Thanks for use cases. I have better understanding now. Cheers, - Takahiro On Nov 14, 12:56 am, Paul deGrandis paul.degran...@gmail.com wrote: Here's one use case: Let's say you want to develop a library that monitors system behavior and resources while

Re: Where did the idea of metadata come from?

2012-11-12 Thread Takahiro Hozumi
is also good enough for the purpose. [1] https://github.com/drewr/postal Cheers, -Takahiro On Nov 13, 6:01 am, JvJ kfjwhee...@gmail.com wrote: Metadata is a really useful feature, and it's been helping me a lot.  It seems like a flash of genius on the part of Mr. Hickey.  I'm wondering

Re: Coding Standard - ns usage

2012-11-08 Thread Takahiro Hozumi
:require :as is always good and generally preferred over :refer or :use :only. I think we all agree with this, but in reality :use with/without :only is very widely used in a number of real project I've seen on github. :use (especially without :only) makes code reading painful and usually

Re: Clojure : a good start for non-programmers?

2012-09-26 Thread Takahiro Hozumi
have some preference. Cheers, - Takahiro On Monday, September 24, 2012 3:11:23 PM UTC+9, Gregorius R. wrote: Hello Clojurists! I'm a person in middle age (you know, too old to rock'n'roll, to young to die) and would like to programm but starting with functional programming. Regarding

[ANN] Ducttape.cljs 0.1.0: A ClojureScript micro MVC framework

2012-09-19 Thread Takahiro Hozumi
, - Takahiro -- 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 unsubscribe from this group, send

Re: ClojureScript and development workflow

2012-09-11 Thread Takahiro Hozumi
in a short time interval. - same problem with multimethods as JVM Clojure ? Sorry, I don't understand what this means. Anyway I don't recommend using multimethods in cljs because it is not fast. Cheers, - Takahiro On Sep 11, 4:52 pm, Laurent PETIT laurent.pe...@gmail.com wrote: 2012/9/10

Re: Immutant 0.3.0 released

2012-09-11 Thread Takahiro Hozumi
, - Takahiro On Sep 12, 4:30 am, Jim Crossley jcrossl...@gmail.com wrote: We released our third official version of Immutant today! With this release we now publish the Immutant namespaces to Clojars. They are of limited use when run outside of Immutant, of course, but they'll at least compile so you can

Re: Immutant 0.3.0 released

2012-09-11 Thread Takahiro Hozumi
Hi Jim, Thank you for comprehensible explanation. I understand. Thanks, - Takahiro On Sep 12, 10:45 am, Jim Crossley jcrossl...@gmail.com wrote: Hi Takahiro, When considering a specific library in isolation, e.g. HornetQ, there is little difference between using it within or without an app

Re: ClojureScript and development workflow

2012-09-10 Thread Takahiro Hozumi
change you make, you're doing it wrong. What is this, 2009? I think this is somewhat exaggeration. REPL isn't good enough to push the all changes into browser. Cheers, - Takahiro On Tuesday, September 11, 2012 1:28:44 AM UTC+9, lpetit wrote: Hello, A ClojureScript workflow newbie question

Pattern of Succinctness

2012-08-12 Thread Takahiro Hozumi
Hi, I would like to know common technics that make code succinct. For example: (or (:b {:a 1}) 0) (:b {:a 1} 0) (if-not x 1 2) (if x 2 1) (filter #(not (nil? %)) coll) (filter identity coll) ;; nearly equal Please let me know any tips you found. Cheers, Takahiro. -- You received

Re: Pattern of Succinctness

2012-08-12 Thread Takahiro Hozumi
generally more readable? I think the following is clearer while still not having as much noise as the first filter example: (filter (partial not nil?) coll) On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi fat...@googlemail.comjavascript: wrote: Hi, I would like to know common technics

Re: Experiences developing a crowdfunding site for open source projects in Clojure (from a Python background)

2012-07-28 Thread Takahiro Hozumi
this is one key-stroke(M-.) task. Cheers, Takahiro. On Friday, July 27, 2012 4:59:46 AM UTC+9, Aaron Lebo wrote: Hello! Sometime around 2 and a half months ago, I started to work on a new project using Clojure. I've been using Python heavily for about 6 six years working for a small

Re: is their a Clojure framework for handling form validation?

2012-07-27 Thread Takahiro Hozumi
Instead of calling the ExceptionInfo ctor .getData directly, it's better to use ex-info ex-data instead. Baishampayan Thank you for the information. I agree with you. On Friday, July 27, 2012 6:39:29 PM UTC+9, Baishampayan Ghose wrote: On Thu, Jul 26, 2012 at 10:19 PM, Takahiro Hozumi fat

Re: is their a Clojure framework for handling form validation?

2012-07-26 Thread Takahiro Hozumi
If you build simple json API, combining validation function which return validation error as a map and clojure.lang.ExceptionInfo can reduce intermediate error handling code. (when-let [m (validate params)] (throw (clojure.lang.ExceptionInfo. validation error m))) (defn

Re: Any downside of record compared to map

2012-07-22 Thread Takahiro Hozumi
internally efficient tree data structure, but record is compiled into class with fields as something like POJO. I suspect efficiency of record when repeated assoc/dissoc. But I could be wrong. Regards, Takahiro. On Monday, July 23, 2012 12:54:03 PM UTC+9, Warren Lynn wrote: I don't think you're

Re: Any downside of record compared to map

2012-07-22 Thread Takahiro Hozumi
Baishampayan I didn't know `map-Foo`. Thank you for the infomation! On Monday, July 23, 2012 2:11:45 PM UTC+9, Baishampayan Ghose wrote: On Mon, Jul 23, 2012 at 10:37 AM, Takahiro Hozumi fat...@googlemail.com wrote: 2. The construction of record depends on an order of arguments

Re: Data vs API

2012-05-02 Thread Takahiro
I've read in some recent posts that Clorujians prefer data to APIs.  I'm not sure I understand what this means, in practice.  When I'm in the early stages of developing an application, the data structures undergo a great deal of change.  One of the ways, I isolate parts of the code from these

ClojureScript assoc performance

2012-02-15 Thread Takahiro Hozumi
Hi, I found that assoc can be slow in ClojureScript. This is my app profile. http://twitpic.com/8kbupv/full I think the cause is that entire clone happen when assoc is called. https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L2284 Is this design choice intended for

Re: ClojureScript assoc performance

2012-02-15 Thread Takahiro
Timothy It seems that HashMap also clones whole. https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L2371 David I see. I guessed that overhead of persistent data structure might be considered. Thanks. 2012/2/16 Timothy Baldridge tbaldri...@gmail.com: Is this design

Re: How to convert string into sequence with replacing matched text.

2012-02-13 Thread Takahiro
] ] Thanks. 2012/2/13 Tassilo Horn tass...@member.fsf.org: Takahiro Hozumi fat...@googlemail.com writes: Hi! I want to make a sequence from string as follows. input: hello 1 world 2 output: (hello [1] world [2]) What is efficient way to achieve this in ClojureScript? This is a JVM

How to convert string into sequence with replacing matched text.

2012-02-12 Thread Takahiro Hozumi
Hi, I want to make a sequence from string as follows. input: hello 1 world 2 output: (hello [1] world [2]) What is efficient way to achieve this in ClojureScript? Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: WebSockets with Clojure

2012-02-02 Thread Takahiro Hozumi
If you need scalability, two phase connect might be necessary. 1. Resolve a server name which client should be connected to. If a client need to be connected to specific resource (chat room etc) consistent hashing is useful. http://nakkaya.com/2010/05/05/consistent-hashing-with-clojure/ 2.

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

2012-01-25 Thread Takahiro
How about using (extend-type default ...) ? Is it safe to use it? Oops, extend-type with default does work and it seems to work well. This is what I am looking for! Thanks. 2012/1/26 David Nolen dnolen.li...@gmail.com: On Fri, Jan 13, 2012 at 1:32 PM, Jozef Wagner jozef.wag...@gmail.com

Re: Multimethods performance in ClojureScript.

2012-01-19 Thread Takahiro Hozumi
Thank you for your response. The reasons why I didn't use protocols are following. 1. Currently ClojureScript doesn't have `extend`, which makes inheritance easy. http://david-mcneil.com/post/1475458103/implementation-inheritance-in-clojure 2. I think an entity which is created by deftype or

::keyword are not resolved properly in ClojureScript.

2012-01-18 Thread Takahiro Hozumi
Hi, I found that ::keyword doesn't have correct namespace in ClojureScript. If this is not only my environemnt problem, I will create an issue. (.log js/console ::mykeyword) Evaluate this in file, not repl. Thanks. -- You received this message because you are subscribed to the Google Groups

Multimethods performance in ClojureScript.

2012-01-18 Thread Takahiro Hozumi
I've experienced rewriting my ClojureScript code into multimethods base. I'd share my results. Initially I implemented polymorphism behavior as simple hashmap like this: (def parent {:foo (fn [x] ...) :bar (fn [x] ...)}) (def child (merge parent {:foo (fn [x] ...)})) For some

Cannot access variables without namespace in ClojureScript repl.

2012-01-15 Thread Takahiro Hozumi
Hi, In my browser repl, which follows the ClojureScript wiki[1], I must specify variables with namespace even if `in-ns` is used, but I noticed that I don't have to do in the repl of ClojureScript One[2]. Am I the only one who cannot access variables without namespace? What makes the diffirence?

Re: Cannot access variables without namespace in ClojureScript repl.

2012-01-15 Thread Takahiro
namespaces. We found a couple of problems with the ClojureScript REPL while working on One and will address them soon. If you confirm that this is the problem, please let us know. Also, feel free to add an issue to JIRA with the steps to reproduce. Thanks, Brenton On Jan 15, 6:57 am, Takahiro

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),

Re: My implementation of ISeqable for NodeList doesn't work on Opera.

2012-01-10 Thread Takahiro Hozumi
I've created an issue about this. http://dev.clojure.org/jira/browse/CLJS-120 Thanks. On Jan 10, 5:31 am, Stuart Sierra the.stuart.sie...@gmail.com wrote: I would like to have NodeList be seqable. Please file a ticket with a patch. Perhaps someone else can shed light on why Opera doesn't work.

[ClojureScript] My implementation of ISeqable for NodeList doesn't work on Opera.

2012-01-06 Thread Takahiro Hozumi
Hi, Following code cause an error, because NodeList doesn't extend ISeqable. (doseq [u (goog.dom/getElementsByClass myclass)] ...) Uncaught Error: No protocol method ISeqable.-seq defined for type object: [object NodeList] So I implemented ISeqable for NodeList. (extend-type js/NodeList

Re: [ClojureScript] Wrapping all def into a load event handler

2012-01-03 Thread Takahiro
Hi, Putting javascript at the bottom of body is nice idea. Thanks. 2012/1/2 Stuart Sierra the.stuart.sie...@gmail.com: Hi Takahiro, This will work. It's not 100% idiomatic Clojure, but it's an acceptable workaround to the DOM loading issue. If ClojureScript had `alter-var-root`, which

Re: Do you use Monads in your real clojure applications

2012-01-03 Thread Takahiro Hozumi
In MVC pattern, Model should take responsibility for business logic. Therefore I write validate function for creating in the model. If creating a instance of the model should be safe, I must validate a parameter in the create function. My problem is that a controller have to validate a parameter

Re: [ANN] swank-clojure 1.3.4 released

2012-01-03 Thread Takahiro
p...@hagelb.org: Takahiro fat...@googlemail.com writes: http://imgur.com/5NCEW Is any procedure needed? I've tried 1.3.4 with clojure 1.2.1/1.3.0 and Emacs 23.3. My .emacs.el includes only load-path and marmalade settings. including [ring 1.0.1] in my project.clj, which uses clj-stacktrace

Re: [ANN] swank-clojure 1.3.4 released

2011-12-28 Thread Takahiro
Hi, I don't get colored stacktrace. http://imgur.com/5NCEW Is any procedure needed? I've tried 1.3.4 with clojure 1.2.1/1.3.0 and Emacs 23.3. My .emacs.el includes only load-path and marmalade settings. including [ring 1.0.1] in my project.clj, which uses clj-stacktrace 0.2.2 instead of 0.2.4.

Re: [ANN] swank-clojure 1.3.4 released

2011-12-28 Thread Takahiro
get the colorized stack-trace was to use M-x clojure-jack-in. I'm also using emacs 24 and clojure-mode 1.11.5. I switched emacs to 24 and get the same results. Thanks! 2011/12/29 Sean Corfield seancorfi...@gmail.com: On Wed, Dec 28, 2011 at 6:43 PM, Takahiro fat...@googlemail.com wrote: I think

[ClojureScript] Wrapping all def into a load event handler

2011-12-26 Thread Takahiro Hozumi
Hi, In order to manipulate dom, I often want to bind elements into variable through def, but we cannot manipulate it until load event. So I wrapped all def into a load event handler in the following way. https://gist.github.com/1521051 I don't use let, because many elements cause deep nested let,

core.match feature request: supporting java.util.HashMap

2011-12-12 Thread Takahiro Hozumi
Hi, I'd like to use core.match with java.util.HashMap without converting into {}. The core.match doesn't support it as below. (let [m (java.util.HashMap. {a 1})] (match m {a 1} true)) ;= nil Is it difficult? Thanks. -- You received this message because you are subscribed to

Re: core.match feature request: supporting java.util.HashMap

2011-12-12 Thread Takahiro
David Thanks. Nice design! (extend-type java.util.HashMap ma/IMatchLookup (val-at* [this k not-found] (or (.get this k) not-found))) 2011/12/13 David Nolen dnolen.li...@gmail.com: You can extend-type to IMatchLookup. David On Mon, Dec 12, 2011 at 10:56 AM, Takahiro Hozumi

Re: ClojureScript Repl -- Swank-like workflow with Emacs?

2011-11-24 Thread Takahiro
In your html, a script tag seems to have to be in body tag, not head tag, when you use browser repl. If you use Chrome, look at a console in Developer Tools. Is there an xpc error? 2011/11/25 Wilkes Joiner wilkesjoi...@gmail.com: The browser repl in the samples directory works fine for me in

Re: ClojureScript Repl -- Swank-like workflow with Emacs?

2011-11-24 Thread Takahiro
Or you should hook load event. (ns foo (:require [clojure.browser.repl :as repl] [goog.events :as gevents])) (defn main [] (repl/connect http://localhost:9000/repl;) (gevents/listen js/window (aget gevents/EventType LOAD) main) 2011/11/25 Takahiro fat...@googlemail.com: In your

Re: contrib.duck-streams or contrib.io?

2011-11-24 Thread Takahiro
I think clojure.java.io is latest one. http://clojure.github.com/clojure/clojure.java.io-api.html Since clojure.java.io returns raw java object, you need to use java interop directly for write-lines etc. BTW clojure.java.io is beautiful example of protocol, I think. 2011/11/25 Daniel Glauser

Re: Must PersistentQueue be stored in ref not atom?

2011-11-10 Thread Takahiro
Hi, Meikel I didn't know there is a lower level operation. Thanks. !paws is a tony name :) However, my suspicion is, that you don't clearly divide the state handling from the program logic. The peek should happen in the update function you pass to swap!. If this is not side-effect free, it

Must PersistentQueue be stored in ref not atom?

2011-11-09 Thread Takahiro Hozumi
Hi, To avoid peeking same element of a queue, I think PersistentQueue must be stored in ref not atom. Is this correct? ;;Ref: safe (dosync (let [item (peek @r)] (alter r pop) item)) ;Atom: unsafe (let [item (peek @a)] (swap! a pop) item)) Thanks. -- You received this message

Re: Must PersistentQueue be stored in ref not atom?

2011-11-09 Thread Takahiro
)) ;; usage (let [queue (atom (into PersistentQueue/EMPTY [1 2 3]))]  (swap! queue process-item) ; prints 1  (swap! queue process-item) ; prints 2  (swap! queue process-item)) ; prints 3 Probably better examples but that's the basic idea. Allen On Wed, Nov 9, 2011 at 8:46 PM, Takahiro Hozumi fat

Re: Must PersistentQueue be stored in ref not atom?

2011-11-09 Thread Takahiro
 (swap! queue process-item) ; prints 2  (swap! queue process-item)) ; prints 3 Probably better examples but that's the basic idea. Allen On Wed, Nov 9, 2011 at 8:46 PM, Takahiro Hozumi fat...@googlemail.com wrote: Hi, To avoid peeking same element of a queue, I think PersistentQueue

Re: Thoughts on CUDA + Clojure

2011-09-10 Thread Takahiro Hozumi
C in S-expression approach might be helpful, if you just want to write C in Clojure syntax. The advantage of this pure translator approach is you can fully recognize what you do. Such implementation already exist in Scheme. http://practical-scheme.net/gauche/man/gauche-refe_76.html I think

Your favorite utility function or macro.

2011-03-25 Thread Takahiro Hozumi
Hi, I'm interested in useful utility which you create. Please show me your favorite utility. For example, _- is that for me. _- is like -, but it can insert expression in arbitrary place by marking underscore. (_- :a (assoc {} _ 1)) ;= {:a 1} Therefore It can unify - and - behavior.

Should destructure emit not nthnext, but nthrest?

2011-03-23 Thread Takahiro Hozumi
Hi, I think destructure should not produce nthnext, because it realize an element of sequence more than needed. For example: (defn inc-seq [i] (iterate #(let [x (inc %)] (println realize: x) x) i)) ;= #'user/inc-seq (take 1 (inc-seq 0)) ;= (0) (take 1 (let [[x xs] (inc-seq 0)] (cons x xs)))

Re: Should destructure emit not nthnext, but nthrest?

2011-03-23 Thread Takahiro Hozumi
, 6:23 pm, Takahiro Hozumi fat...@googlemail.com wrote: Hi, I think destructure should not produce nthnext, because it realize an element of sequence more than needed. For example: (defn inc-seq [i]   (iterate #(let [x (inc %)] (println realize: x) x) i)) ;= #'user/inc-seq

Re: Can this function be simpler?

2011-03-10 Thread Takahiro
Interesting. Here is my attempt. (defn enmap [args] (let [[fs res] (reverse args)] (reduce (fn [v k] (hash-map k v)) fs res))) (enmap [1 2 3 4 {5 6 7 8}]) = {1 {2 {3 {4 {5 6, 7 8} (let [[tail more] ((juxt last (comp reverse butlast)) [1 2 3 4 {5 6 7 8}])] (reduce #(hash-map %2 %1)

Re: Can this function be simpler?

2011-03-10 Thread Takahiro
more concise: (defn enmap [args] (reduce #(hash-map %2 %1) (reverse args))) 2011/3/11 Takahiro fat...@googlemail.com: Interesting. Here is my attempt. (defn enmap [args]  (let [[fs res] (reverse args)]    (reduce (fn [v k] (hash-map k v)) fs res))) (enmap [1 2 3 4 {5 6 7 8}]) = {1 {2

clojure.string/replace-first return nil when not matched

2011-03-10 Thread Takahiro Hozumi
Hi, I have two questions about clojure.string/replace-first. 1. Is this expected behavior of replace-first? (require '[clojure.string :as str]) (str/replace-first abc def #ghi (fn [a] (str a a))) = nil I don't think so, because string / string argument version returns original string when

Re: slime warn-on-reflection?

2011-02-25 Thread Takahiro Hozumi
I had same problem. Add following line in your project.cjj. :warn-on-reflection true On Feb 26, 9:11 am, Seth wbu...@gmail.com wrote: Has any gotten the warn-on-reflection to work in slime when compiling a buffer?  Warning occur when i paste a function into the repl, but no reflections occur

Re: http.async.client v0.2.2 released

2011-02-08 Thread Takahiro Hozumi
Hi, Thank you for the introduction. Here is my little feed back: 1. I want to see a example using callbacks. 2. Is RequestBuilderWrapper.java necessary? Why not simply use RequestBuilder? 3. I prefer reify or defrecord to proxy for performance reason, when implement interface. 4. I think hash-map

dosync style

2010-11-28 Thread Takahiro Hozumi
* (fn [m] (let [n (m key)] (if ( 1 n) (assoc m key (dec n)) (dissoc m key))) I think former style is normal, but latter is easy to replace ref with atom. Thanks. -- Takahiro Hozumi -- You received this message because you