examples of using protocols for extending functionality of existing classes?

2011-11-24 Thread ru
Can anybody point out good (idiomatic) examples of using protocols for extending functionality of existing classes? Thanks in advance. Sincerely, Ru -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: [core.logic] Incorporating a database as a source of facts

2011-11-24 Thread Tassilo Horn
Mark markaddle...@gmail.com writes: Hi Mark, Let's take a specific example: Suppose I have a Person table with id, name and gender columns. Then, I have a Parent-Child table that contains two id columns, both of which are foreign keys back into the Person table. I'd could use the logic

Re: examples of using protocols for extending functionality of existing classes?

2011-11-24 Thread Tassilo Horn
ru soro...@oogis.ru writes: Can anybody point out good (idiomatic) examples of using protocols for extending functionality of existing classes? Here's one that I have in my code: --8---cut here---start-8--- (defprotocol VSeq Protocol for types supporting

Re: deprecating butlast?

2011-11-24 Thread Daniel Janus
On Wednesday, November 23, 2011 10:42:13 PM UTC, Nils Bertschinger wrote: It solves a common problem, namely to drop the last element of a sequence and reads better in this case than the equivalent idiom using drop-last. I don't quite get it. How does (butlast x) read better than

Re: examples of using protocols for extending functionality of existing classes?

2011-11-24 Thread Meikel Brandmeyer (kotarak)
Hi, here is a nice example of a small DSL example, which also uses existing data structures to denote different things in the DSL. It uses a protocol under the hood, which is extended to the existing types. https://github.com/cgrand/regex Sincerely Meikel -- You received this message

Re: ANN: j18n 1.0.0 – taming ResourceBundles

2011-11-24 Thread Stuart Campbell
Hi Meikel, Thanks for this library. I noticed that each bundle's keyset is cached via memoization. I believe this prevents adding more bundle properties at runtime (e.g. during interactive development). Is there a way to reset a resource bundle? Is this something that you might consider in a

Re: ANN: j18n 1.0.0 – taming ResourceBundles

2011-11-24 Thread Meikel Brandmeyer (kotarak)
Hi, the ResourceBundles themselves are memoized by the Java runtime. You can reset this cache with ResourceBundle/clearCache. Then the underlying ResourceBundle will be retrieved again on the next access. Then the memoization does not trigger. But the memoization itself is probably premature

Howto override toString of defrecord instances in ClojureScript?

2011-11-24 Thread r0man
Hello, what's the preferred way to override the toString method of a ClojureScript record? I could use set! to change the toString fn of a record after it has been initialized like this: (defrecord MyRecord [name]) (let [record (MyRecord. Hello World)] (set! record.toString (fn [] (:name (js*

Re: Howto override toString of defrecord instances in ClojureScript?

2011-11-24 Thread Baishampayan Ghose
what's the preferred way to override the toString method of a ClojureScript record? I could use set! to change the toString fn of a record after it has been initialized like this: (defrecord MyRecord [name]) (let [record (MyRecord. Hello World)]   (set! record.toString (fn [] (:name (js*

Re: Literate Programming in Emacs?

2011-11-24 Thread ck
I did not encounter that particular problem. But to compare, my project file is ... :dependencies [[org.clojure/clojure 1.3.0]] :dev-dependencies [[jline 0.9.94] [swank-clojure 1.3.0 :exclusions [org.clojure/ clojure]]] ... and my current ~/.emacs.d/elpha folder

Re: Howto override toString of defrecord instances in ClojureScript?

2011-11-24 Thread r0man
Thank you, Baishampayan. That's exactly what I was looking for ... -- 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

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

2011-11-24 Thread Wilkes Joiner
I'm seeing the same behavior. The browser-repl script works fine from the command line, but it hangs when run in emacs. Were you able to resolve this? Mine was working fine, but quit working a few weeks ago. I'm not sure what changed. - Wilkes -- You received this message because you are

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

2011-11-24 Thread David Nolen
/path/to/repl/script/browser-repl NOT /path/to/repl/script/repljs I just tried browser-repl and it works just fine for me. What do you mean by hangs? Do you see the REPL prompt? David On Thu, Nov 24, 2011 at 10:13 AM, Wilkes Joiner wilkesjoi...@gmail.comwrote: I'm seeing the same

Re: [core.logic] Incorporating a database as a source of facts

2011-11-24 Thread Mark
I can't speak to the duplicates issue, though I know it's common in logic-based solutions. In specific cases, I suspect the problem could be solved (or ameliorated) by tabling but I'm just getting into logic programming so I'm not too sure about that. Overall, your use case sounds very

Re: [core.logic] Incorporating a database as a source of facts

2011-11-24 Thread Tassilo Horn
Mark markaddle...@gmail.com writes: I can't speak to the duplicates issue, though I know it's common in logic-based solutions. In specific cases, I suspect the problem could be solved (or ameliorated) by tabling but I'm just getting into logic programming so I'm not too sure about that.

Re: examples of using protocols for extending functionality of existing classes?

2011-11-24 Thread ru
Thank you very much, Meikel! Excelent example! On 24 ноя, 14:27, Meikel Brandmeyer (kotarak) m...@kotka.de wrote: Hi, here is a nice example of a small DSL example, which also uses existing data structures to denote different things in the DSL. It uses a protocol under the hood, which is

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

2011-11-24 Thread Baishampayan Ghose
On Thu, Nov 24, 2011 at 9:23 PM, David Nolen dnolen.li...@gmail.com wrote:  /path/to/repl/script/browser-repl NOT  /path/to/repl/script/repljs I just tried browser-repl and it works just fine for me. What do you mean by hangs? Do you see the REPL prompt? It's hanging for me as well right

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

2011-11-24 Thread Wilkes Joiner
The server appears to start up fine as the inferior-lisp process, but when I enter an expression it is never evaluated. Looking in the web inspector, there is one request to localhost:9000 that sits in a pending state. When I run browser-repl from the command line, I see a series of request

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

2011-11-24 Thread Baishampayan Ghose
On Thu, Nov 24, 2011 at 10:15 PM, Wilkes Joiner wilkesjoi...@gmail.com wrote: The server appears to start up fine as the inferior-lisp process, but when I enter an expression it is never evaluated.  Looking in the web inspector, there is one request to localhost:9000 that sits in a pending

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

2011-11-24 Thread David Nolen
On Thu, Nov 24, 2011 at 11:49 AM, Baishampayan Ghose b.gh...@gmail.comwrote: On Thu, Nov 24, 2011 at 10:15 PM, Wilkes Joiner wilkesjoi...@gmail.com wrote: The server appears to start up fine as the inferior-lisp process, but when I enter an expression it is never evaluated. Looking in the

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

2011-11-24 Thread Wilkes Joiner
No dice on the browser refresh. I'm wondering if it something with my emacs config. I'm going to strip it down to the simplest set up I can manage and see if it resolves the issue. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

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

2011-11-24 Thread David Nolen
You said the REPL hangs, do you don't see a prompt? David On Thu, Nov 24, 2011 at 12:12 PM, Wilkes Joiner wilkesjoi...@gmail.comwrote: No dice on the browser refresh. I'm wondering if it something with my emacs config. I'm going to strip it down to the simplest set up I can manage and see

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

2011-11-24 Thread Wilkes Joiner
I see a prompt. It just never evaluates an expression. -- Wilkes Joiner On Thursday, November 24, 2011 at 11:38 AM, David Nolen wrote: You said the REPL hangs, do you don't see a prompt? David On Thu, Nov 24, 2011 at 12:12 PM, Wilkes Joiner wilkesjoi...@gmail.com

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

2011-11-24 Thread Baishampayan Ghose
On Thu, Nov 24, 2011 at 11:08 PM, David Nolen dnolen.li...@gmail.com wrote: You said the REPL hangs, do you don't see a prompt? I was absolutely affected by the lack of prompt hanging for a while, but it's working now. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- You received

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

2011-11-24 Thread David Nolen
And you don't see a JS error in the browser JS console? On Thu, Nov 24, 2011 at 12:39 PM, Wilkes Joiner wilkesjoi...@gmail.comwrote: I see a prompt. It just never evaluates an expression. -- Wilkes Joiner On Thursday, November 24, 2011 at 11:38 AM, David Nolen wrote: You said the REPL

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

2011-11-24 Thread David Nolen
Another thing, it's important to delete the .repl folder that gets created in your project, this may be stale especially if CLJS has changed. David On Thu, Nov 24, 2011 at 12:39 PM, Wilkes Joiner wilkesjoi...@gmail.comwrote: I see a prompt. It just never evaluates an expression. -- Wilkes

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

2011-11-24 Thread Wilkes Joiner
The browser repl in the samples directory works fine for me in emacs. I'm guessing it has something to do with my app. I'll keep poking around. Thanks for your help. If I figure it out, I'll post a follow up here. -- Wilkes Joiner On Thursday, November 24, 2011 at 11:50 AM, David Nolen

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: ClojureScript Repl -- Swank-like workflow with Emacs?

2011-11-24 Thread Wilkes Joiner
I got it working, sort of. If I launch inferior-lisp from the $CLOJURESCRIPT_HOME/samples/repl/src/repl/test.cljs, then I can pull up my apps page that calls repl/connect and everything works fine from there on out. If I launch inferior-lisp from the cljs in my project, the repl appears to

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

2011-11-24 Thread David Nolen
Did you remember to include utf-8 meta tag in your html page? On Thu, Nov 24, 2011 at 3:00 PM, Wilkes Joiner wilkesjoi...@gmail.comwrote: I got it working, sort of. If I launch inferior-lisp from the $CLOJURESCRIPT_HOME/samples/repl/src/repl/test.cljs, then I can pull up my apps page that

[ANN] Drift 1.4.0 released.

2011-11-24 Thread Matt
Drift is a Rails like migration library for Clojure. I've recently released version 1.4.0 of Drift which includes: A new Java interface. You can now run Drift migrations, find out the database version, or determine the highest migration number from java. User generated migration numbers and

[ANN] Drift DB

2011-11-24 Thread Matt
Drift DB is a clojure database library focused on migration functions. With Drift DB you can create tables, drop tables, add columns to tables, remove columns from tables, query tables, and, though it is not the focus of Drift DB, you can insert, update, delete and select rows from tables. The

Re: ANN: j18n 1.0.0 – taming ResourceBundles

2011-11-24 Thread Stuart Campbell
Ah, I see. Thanks. On 24 November 2011 23:06, Meikel Brandmeyer (kotarak) m...@kotka.de wrote: Hi, the ResourceBundles themselves are memoized by the Java runtime. You can reset this cache with ResourceBundle/clearCache. Then the underlying ResourceBundle will be retrieved again on the next

Re: Lookup on a symbol?

2011-11-24 Thread jaime
But we still don't know why it behaves like this and for what reason. does (:a 1 2) returns 2 make any sense?? On Nov 24, 3:30 pm, Sean Corfield seancorfi...@gmail.com wrote: On Wed, Nov 23, 2011 at 9:48 PM, Alan Malloy a...@malloys.org wrote: Other way round. It behaves like a keyword,

contrib.duck-streams or contrib.io?

2011-11-24 Thread Daniel Glauser
Hello folks, I starting to do some simple file IO stuff with Clojure and was wondering which namespace was considered the best one to use, contrib.duck-streams on contrib.io? There seems to be a bit of overlap between the two and at least some of the functions with the same names have different

Re: Lookup on a symbol?

2011-11-24 Thread Meikel Brandmeyer (kotarak)
Hi, the usual argument is, that this statement itself is undefined. 1 is not a collection. So it is not in the domain of the keyword (seen as a function). Keywords could throw an exception, or behave as they behave. There is no right solution. Just different opinions. And Rich obviously

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