A chain of function vars

2013-05-26 Thread Simon Katz
If I define a chain of vars like this... (defn f1 [] 42) (def f2 #'f1) (def f3 #'f2) ...when I call f3 the chain of vars is followed: (f3) ; => 42 Out of curiosity, where is this following-the-chain defined? I looked at http://clojure.org/evaluation which simply says "The result of

Re: A chain of function vars

2013-05-26 Thread Simon Katz
invoke method and the casting > process. > > On Sunday, 26 May 2013 17:33:24 UTC-4, Simon Katz wrote: >> >> If I define a chain of vars like this... >> >> (defn f1 [] 42) >> >> (def f2 #'f1) >> >> (def f3 #'f2) >> >>

Re: A chain of function vars

2013-05-26 Thread Simon Katz
ve call. >>> >>> For example: >>> >>> f3 casts f2 to an IFn. >>> f2 casts f1 to an IFn. >>> f1 casts the function to an IFn (resulting in the function). >>> >>> So the "chaining together" is defined in the invoke met

twitter-api and streaming calls

2014-05-01 Thread Simon Katz
Hi, I'm playing with twitter-api (https://github.com/adamwynne/twitter-api) and streaming calls. I've also tried twitter-streaming-client (https://github.com/mccraigmccraig/twitter-streaming-client). With the examples each of those provide, I'm getting *EOFException: JSON error (end-of-file)*

Re: twitter-api and streaming calls

2014-05-02 Thread Simon Katz
.com/twitter/hbc >> >> >> On Thursday, May 1, 2014 6:59:04 PM UTC-4, Simon Katz wrote: >>> >>> Hi, >>> >>> I'm playing with twitter-api (https://github.com/adamwynne/twitter-api) >>> and streaming calls. I've also tried twitt

Using update-in to produce vectors from nothing

2013-04-05 Thread Simon Katz
Hi. Is there an idiomatic way to have update-in create a vector when the supplied keys do not already exist? (Or maybe I should use something other than update-in?) For example... This gives me a sequence of things in the reverse of the order I want: (update-in {} [:foo :bar] conj :a) ;; => {

Re: Using update-in to produce vectors from nothing

2013-04-05 Thread Simon Katz
Thanks Laurent and Jim — yes, fnil is what I was looking for. On Friday, 5 April 2013 12:25:17 UTC+1, Simon Katz wrote: > > Hi. > > Is there an idiomatic way to have update-in create a vector when the > supplied keys do not already exist? (Or maybe I should use something other &

defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
I'm wondering how two things fit together (and I suspect they don't). First, if I define a record type, e.g. (defrecord Foo [x y z]) I can access fields using keywords as functions: (:x (->Foo 1 2 3)) => 1 Second, Clojure supports namespace-qualified keywords, presumably because it's possibl

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
Replying to myself... Hmmm, of course, defining that function wouldn't solve the problem of clashes. On Wednesday, 10 April 2013 14:03:47 UTC+1, Simon Katz wrote: > > I'm wondering how two things fit together (and I suspect they don't). > > First, if I define a recor

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
On Wed, Apr 10, 2013 at 2:13 PM, Jim foo.bar wrote: > On 10/04/13 14:03, Simon Katz wrote: > >> Second, Clojure supports namespace-qualified keywords, presumably because >> it's possible that different libraries might want to use the same keyword >> for different p

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
se they keep overwriting each others' > preferences. > > > On Wed, Apr 10, 2013 at 9:13 AM, Jim foo.bar > > wrote: > >> On 10/04/13 14:03, Simon Katz wrote: >> >>> Second, Clojure supports namespace-qualified keywords, presumably >>> because

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
mandatory record fields). Those can still be > namespace-qualified: > > testchamber.core=> (defrecord Foo [a b]) > testchamber.core.Foo > > testchamber.core=> (Foo. 3 4) > {:a 3, :b 4} > > testchamber.core=> (assoc (Foo. 3 4) ::bar 42) > {:a 3, :b 4, :testcha

Re: defrecord and namespace-qualified symbols

2013-04-10 Thread Simon Katz
On Wednesday, 10 April 2013 21:08:22 UTC+1, Cedric Greevey wrote: > If a third-party library is storing things in your defrecord, it behooves > its author to know what that record's predefined keys are. > Um, I don't think I agree. The library might be doing something very generic and have no r

Re: defrecord and namespace-qualified symbols

2013-04-11 Thread Simon Katz
sed with > regard to keys outside of its own namespace. Non-caller-supplied keys > should be qualified. > > > > On Wed, Apr 10, 2013 at 4:24 PM, Simon Katz > > wrote: > >> On Wednesday, 10 April 2013 21:08:22 UTC+1, Cedric Greevey wrote: >> >>> If a third-p

Namespaces, APIs, protocols and records

2013-04-14 Thread Simon Katz
I'm in the process of trying to work out how I want to use namespaces when implementing libraries or subsystems. I'm aware of several approaches: - Use a single namespace, making only the API public (either with everything in a single file or breaking things into multiple files and us

Re: Namespaces, APIs, protocols and records

2013-04-14 Thread Simon Katz
Whoops — when I said "with an extra [namespace] for each protocol", I meant "with an extra [namespace] for each protocol implementation". On Sunday, 14 April 2013 18:21:19 UTC+1, Simon Katz wrote: > > I'm in the process of trying to work out how I want to use

Re: Namespaces, APIs, protocols and records

2013-04-15 Thread Simon Katz
ementations need the protocols, so these have to be in a separate > namespace > > Note how this structure has been driven to some extent by the problem of > circular dependencies. > > On Monday, 15 April 2013 01:21:19 UTC+8, Simon Katz wrote: >> >> I'm in the proc

Re: Namespaces, APIs, protocols and records

2013-04-15 Thread Simon Katz
work out in the wild > pretty well. YMMV, and I'm still not settled on this myself, but > hopefully that helps. > > Travis > > > > > > On Sun, Apr 14, 2013 at 2:16 PM, Simon Katz > > wrote: > > Whoops — when I said "with an extra [nam

Re: Namespaces, APIs, protocols and records

2013-04-16 Thread Simon Katz
aries: > > http://clojurewerkz.org/ > > Travis > > On Mon, Apr 15, 2013 at 11:23 AM, Simon Katz > > wrote: > > I'm considering going this way. I definitely like that it keeps things > > simpler for me (the implementer), but clients have to know abou

Re: Namespaces, APIs, protocols and records

2013-04-16 Thread Simon Katz
Thanks for the pointer to tools.namespace — it looks really useful. And if I follow the advice there to "always create new instances of records after a refresh", it will simplify my decision on how to organise namespaces — there's no longer a need to

Resolution of in-ns in a namespace that does not refer clojure.core

2011-04-21 Thread Simon Katz
Hi. I'm learning Clojure, currently using Clojure 1.2. http://clojure.org/namespaces when talking about creating namespaces says: At the Repl it's best to use in-ns, in which case the new namespace will contain mappings only for the classnames in java.lang. In order to access the names from

Re: Resolution of in-ns in a namespace that does not refer clojure.core

2011-04-21 Thread Simon Katz
Hi Stu. Thanks. That makes sense. Is this special-casing documented somewhere, or is it something one can only discover by playing? More generally, I'm wondering whether I'm likely to come across other areas with little surprises as I learn more. An example: I've been exploring special symbols

Re: Resolution of in-ns in a namespace that does not refer clojure.core

2011-04-21 Thread Simon Katz
OK, thanks, will do. Simon On Thu, Apr 21, 2011 at 20:01, Stuart Halloway wrote: > Let's say that little surprises are not a design objective. :-) > > Please do follow up with additional questions as you have them. > > Stu > > Hi Stu. > > Thanks. That makes sense. > > Is this special-casing doc

Two types of special symbol

2011-04-21 Thread Simon Katz
Hi. (In case it makes a difference, I'm using Clojure 1.2.) If one creates a new namespace using in-ns, the new namespace does not refer to clojure.core, as explained at http://clojure.org/namespaces. I noticed one can use certain special forms in a namespace created using in-ns, but not others:

Re: Two types of special symbol

2011-04-23 Thread Simon Katz
t; this difference is kind of unfortunate, and the design notes on a > compiler rewrite mention changing things so the forms directly > supported by the compiler are also namespace qualified and live in > clojure.core > > On Thu, Apr 21, 2011 at 12:24 PM, Simon Katz wrote: > >

Re: Closures in macros

2011-05-04 Thread Simon Katz
> For example Common Lisp does support this. That's not true, or at least it's only partly true. Here's a translation of your example into Common Lisp (I added a use of a# in the macro to avoid compiler optimization making the problem go away): (defun f (x) (lambda () x)) (defparameter foo (

Re: Closures in macros

2011-05-04 Thread Simon Katz
On May 4, 11:31 pm, André Thieme wrote: > Am 04.05.2011 14:50, schrieb Simon Katz: > > >> For example Common Lisp does support this. > > > That's not true, or at least it's only partly true. > > > Here's a translation of your example into Common Lis

Creating instances of types not known at compile time

2011-05-09 Thread Simon Katz
I'm trying to implement a function similar to new, but where the type is not known at compile time -- so I want to evaluate the first argument. With the help of Google, I found the approach used in new* below: (ns dynamic-new) (defn new* [type-name-as-symbol & args] (clojure.lang.R

Re: Creating instances of types not known at compile time

2011-05-09 Thread Simon Katz
On Mon, May 9, 2011 at 16:21, Jonathan Fischer Friberg wrote: > Q1 This macro captures the correct namespace: > > (defmacro new* [type-name-as-symbol & args] > `(clojure.lang.Reflector/invokeConstructor > (ns-resolve ~*ns* ~type-name-as-symbol) > (to-array '~args))) > Unfortunately th

Re: Creating instances of types not known at compile time

2011-05-09 Thread Simon Katz
On Mon, May 9, 2011 at 17:50, Chris Perkins wrote: > On May 9, 8:00 am, Simon Katz wrote: > > I'm trying to implement a function similar to new, but where > > the type is not known at compile time -- so I want to evaluate > > the first argument. > > > >

Re: Creating instances of types not known at compile time

2011-05-10 Thread Simon Katz
On May 10, 8:27 am, Meikel Brandmeyer wrote: > Hi, > > Am 10.05.2011 um 01:49 schrieb Simon Katz: > > > Passing the class object does exactly what I want. > > Then passing a factory function will work, too—without reflection. Much more > performance impact then checki

Navigating to Clojure Source using Emacs' Find Source Command

2011-05-21 Thread Simon Katz
I'm having trouble using Emacs' Find Source command to navigate to Clojure source. I'm using Leiningen (1.4.2) and Emacs (23.2). I have a project.clj file with the following: (defproject sk-mini-project-1-2-0 "0.0.1-SNAPSHOT" :dependencies [[org.clojure/clojure "1.2.0"] [org.c

Re: Navigating to Clojure Source using Emacs' Find Source Command

2011-05-23 Thread Simon Katz
On Sun, May 22, 2011 at 03:35, Phil Hagelberg wrote: > On May 21, 1:28 pm, Simon Katz wrote: > > I'm having trouble using Emacs' Find Source command to navigate to > > Clojure source. > > > > I'm using Leiningen (1.4.2) and Emacs (23.2). > > >

Re: Navigating to Clojure Source using Emacs' Find Source Command

2011-05-23 Thread Simon Katz
On Mon, May 23, 2011 at 14:36, Simon Katz wrote: > On Sun, May 22, 2011 at 03:35, Phil Hagelberg wrote: > >> On May 21, 1:28 pm, Simon Katz wrote: >> > I'm having trouble using Emacs' Find Source command to navigate to >> > Clojure source. >> >

Re: Navigating to Clojure Source using Emacs' Find Source Command

2011-05-23 Thread Simon Katz
On Mon, May 23, 2011 at 15:11, Simon Katz wrote: > On Mon, May 23, 2011 at 14:36, Simon Katz wrote: > >> On Sun, May 22, 2011 at 03:35, Phil Hagelberg wrote: >> >>> On May 21, 1:28 pm, Simon Katz wrote: >>> > I'm having trouble using Emacs'

Re: Exception: Can't define method not in interfaces: fly

2011-09-20 Thread Simon Katz
Try using this for the defprotocol form: (defprotocol Fly (fly [this] [this x])) I don't know whether your defprotocol form is supposed to be allowed. Either way, better error message(s) would be good. -- You received this message because you are subscribed to the Google Groups