Re: Teaching Clojure to students (how ?)

2013-10-05 Thread Takahiro Hozumi
Hi, If I were a programming teacher, I would have students re-realize what one can achieve with programing in general at the start because people's action always come from their inner motivation. To enumerate concrete benefits and success story like TV shopping may be effective. Without motivation

Re: Can we please deprecate the :use directive ?

2013-08-03 Thread Takahiro Hozumi
Hi Ye, > or at least *Do Not Use *those standard names*.* The following guide suggests the opposite. http://dev.clojure.org/display/community/Library+Coding+Standards > Use good names, and don't be afraid to collide with names in other namespaces. That's what the flexible namespace support is t

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 > 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: > https://github.com/http-kit/http-kit/issues/47. And

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 wrote:

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 wrote: > Hello, everyone. I'm experience some performance issue when using clojure. > The scenario is as follows: > > I have a huge list of xls

*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 belie

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 wrote: > Here's one use case: > > Let's say you want to develop a library that monitors system behavior and > resources while functions are executed (or w

Re: Where did the idea of metadata come from?

2012-11-12 Thread Takahiro Hozumi
> Metadata is a really useful feature, and it's been helping me a lot. Could you show me concrete example? I still don't understand the value of metadata and rarely use it except type hint. I saw active using metadata on some project(e.g. postal[1]), but I think regular hashmap instead of metadata

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 read

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

2012-09-26 Thread Takahiro Hozumi
Hi Gregorius, I recommend for you to watch "Brian Will" channel on youtube. http://www.youtube.com/user/briantwill/videos?flow=grid&view=1 There are several introduction of programming language: Clojure, Java, Python, JavaScript, C etc.. After watching all part.1 of each introduction, then you m

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

2012-09-19 Thread Takahiro Hozumi
Hi, Ducttape.cljs is a ClojureScript micro MVC framework/library. https://github.com/hozumi/ducttape.cljs Here's a list of benefits: * Clear structure * Super thin * No original event system * Use functions and atoms as building blocks * Don't force to use specific library Check it ou

Re: Immutant 0.3.0 released

2012-09-11 Thread Takahiro Hozumi
emcached, RabbitMQ, or cron, for example. And for > others, I would recommend an app server. > > As always, it depends on the requirements of the application and the > capabilities of the organization to support it. > > Thanks, > Jim > > > > > > > > On Tu

Re: Immutant 0.3.0 released

2012-09-11 Thread Takahiro Hozumi
Hi, Forgive my ignorance, although I think the project must be useful, but I still don't understand what is the benefit of using application server. What is the difference between using a particular library(e.g. HornetQ) with JBoss AS7 and using the same one without JBoss AS7? Cheers, - Takahiro

Re: ClojureScript and development workflow

2012-09-11 Thread Takahiro Hozumi
owser-repl frequently because I refresh the browser 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:

Re: ClojureScript and development workflow

2012-09-10 Thread Takahiro Hozumi
Hi, I refresh browser every time I change cljs files. > "Using the REPL as the main way to deliver code to the browser means never having to refresh the page. One could theoretically build an entire application without a single page refresh. If you find yourself refreshing the page after every

Re: Pattern of Succinctness

2012-08-12 Thread Takahiro Hozumi
one considered 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 > > > wrote: > >> Hi, >>

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 this message

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

2012-07-28 Thread Takahiro Hozumi
Hi Aaron, Thank you for the interesting post. I guess we all here have quite similar experience as code size shrink. > I found myself digging around in github repos to actual read code instead of documentation a lot more than I ever did with Python. Agreed. In fact, for emacs/swank-clojure users

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:

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 wrap-validation-ex

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 > wrote: > > 2. The construction of record depends on an order of arguments.

Re: Any downside of record compared to map

2012-07-22 Thread Takahiro Hozumi
I think defrecord has 5 downsides compared to regular map. 1. The literal of regular map is eye-friendly and portable. However I still don't know how helpful instant literals added in clojure 1.4 is for records. 2. The construction of record depends on an order of arguments. Sometimes, I feel th

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 som

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 t

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. Connect.

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 defr

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 reason

::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 "Cl

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?

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

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 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. > -S -- You received th

[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 DOM-manipulation library?

2012-01-06 Thread Takahiro Hozumi
> ($ (css ))> > could wire an atom to a css (or > other) dom attribute, by placing a> watcher on the atom and automatically > updating the dom on change.Interesting idea! On 1月7日, 午前5:02, kovas boguta wrote: > Great, looking forward to see what Chris has come up with. I'm not > enough of a JS

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 tw

[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, a

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 subscribe

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 bec

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 transla

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. https:

Re: Should destructure emit not nthnext, but nthrest?

2011-03-23 Thread Takahiro Hozumi
o > determine whether the sequence is empty you would have to call seq on > it. > > On Mar 23, 6:23 pm, Takahiro Hozumi wrote: > > > > > > > > > Hi, > > I think destructure should not produce nthnext, because it realize an > > element of sequence mor

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: clojure.string/replace-first return nil when not matched

2011-03-20 Thread Takahiro Hozumi
Hi, Please bump up my JIRA membership level to make edits and I will fix this bug. I have an account named Takahiro Hozumi on dev.clojure.org already. CA is also already sent. Thanks. On 3月11日, 午後10:55, Stuart Sierra wrote: > > (require '[clojure.string :as str]) > > (str/repla

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 m

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 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 when i compile

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 i

dosync style

2010-11-28 Thread Takahiro Hozumi
ter *counts* (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 becau

ANN: Hiccup-bridge: A converter between html and hiccup.

2010-10-30 Thread Hozumi
Hi All, I've released conversion tool for hiccup. http://github.com/hozumi/hiccup-bridge Hiccup-bridge is aims for collaboration between programmers and designers. You can easily use this through leiningen. % lein hicv 2html % lein hicv 2hic I welcome any comments or suggestions. T

Re: Isn't STM good at building an ant colony?

2010-09-21 Thread Hozumi
Hi Nicolas, That is a nice idea! Thanks. -- Takahiro Hozumi -- 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

Re: Displaying source of function typed into the REPL?

2010-09-19 Thread Hozumi
If you use emacs, incremental back search is handy. Typing "C-r defn", you may jump to the defnition of a function. Next time, you need to type only "C-r C-r". -- Takahiro Hozumi On 9月19日, 午前6:39, Sean Corfield wrote: > OK, this feels like a really dumb question... > &

Isn't STM good at building an ant colony?

2010-09-19 Thread Hozumi
in O(thread^2) means that refs should not be used to store the data that is aletered by too many threads like big ant colony map or newral network nodes. If modifying the data by too many threads is planned, instead of refs, are agents best way to store it? Any other solution? Thanks. Takahiro H

Re: Which do you prefer, expressing points in {:x 0, :y 0} or [0 0]?

2010-02-12 Thread Hozumi
g the > elements out in the right order. Mathematical vectors are orderful things > and should be represented in an orderful data structure. Clojure vectors are > ordered. Hashmaps are unordered. > > That's the conclusion I have come to, at any rate. > > Garth >

Which do you prefer, expressing points in {:x 0, :y 0} or [0 0]?

2010-02-12 Thread Hozumi
Hi,all Although there is no right answer, vector seem to be preferred in many cases. Which do you prefer map or vector? Thanks! -- 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 pos

Re: defn within defn

2010-02-10 Thread Hozumi
a function. clojure is not scheme. > clojure's def (which defn uses) is not lexical or scoped in anyway, it > always operates on global names. if you want lexical scope please use > one of clojure's lexical scoping constructs, let or letfn. > > > > > > On Wed, F

defn within defn

2010-02-10 Thread Hozumi
Hi all. Is it not recommended to use defn within defn? Normal function is faster than the function which has inner function which actually doesn't run. -- (defn aaa1 [] (defn bbb [] 1) 1) (defn aaa2 [] 1) user> (time