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 checking a short string for a dot.
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 checking a short string for a dot.
Sincerely
Meikel
--
You received this message because yo
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.
> >
> > With the help of Google, I found the approa
On May 9, 1:49 pm, Alan wrote:
> On May 9, 9:50 am, Chris Perkins wrote:
>
> A mild gripe: we're in a language that doesn't make us use ugly names
> like klass and clazz. Some will disagree with me for sure, but I think
> it's more readable to simply use the symbol "class" when you're
> talking a
On May 9, 9:50 am, 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.
>
> > With the help of Google, I found the approach used in ne
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.
>
> With the help of Google, I found the approach used in new*
> below:
>
> (ns dynamic-new)
>
> (defn
Well, that's sort of wanting to eat the cake and have it.
It's impossible to resolve a symbol where it isn't known where it came from,
if any resolving is to take place, it must assume to be in the current
namespace.
So yes, you're right; syntax-quote would work best here.
Jonathan
On Mon, May
Have you considered factory functions and macros? Macros might suit
better if you are dealing with various records.
(defmacro instance
([^Class c]
`(new ~c))
([^Class c & more]
`(new ~c ~@more)))
Since macros are expanded, qualified vs unqualified issue will be
taken care of automatic
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
Never mind Q2, I didn't understand the question correctly.
Jonathan
On Mon, May 9, 2011 at 5:21 PM, Jonathan Fischer Friberg <
odysso...@gmail.com> wrote:
> Q1 This macro captures the correct namespace:
>
> (defmacro new* [type-name-as-symbol & args]
> `(clojure.lang.Reflector/invokeConstructo
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)))
Q2 Backquote ` is unnecessary for symbols, use standard quote '
Q3 Answer to 1 fixes this
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
12 matches
Mail list logo