Johannes writes:
Hi Johannes,
> I am trying to build an alternative record building macro. For example
>
> (define-record point [x y])
> should define
> - a new type point
> - a constructor make-point
(defrecord Point [x y]) generates also a constructor function (->Point x
y).
> - a type chec
Am Dienstag, 13. November 2012 12:15:17 UTC+1 schrieb thorwil:
>
> On 11/13/2012 11:06 AM, Johannes wrote:
> > I define a record
> > (defrecord point [x y])
> >
> > and the following macro:
> >
> > (defmacro drg
> >[typename components]
> >`(def ~(symbol (str typename "-" (str (fi
Am Dienstag, 13. November 2012 12:09:39 UTC+1 schrieb Jim foo.bar:
>
> You can't convert to keyword simply by (str ":" (str (first
> components))...you need the (keyword (first components))
in the meantime I learned this from Christophe
> ...also why is
> your argument (symbol "obj")? I'd pr
Am Dienstag, 13. November 2012 12:06:10 UTC+1 schrieb Christophe Grand:
>
> (symbol (str ":" (str (first components should be (keyword (first
> components))
> In your expansion, :x is not a keyword but a symbol starting by a colon --
> the symbol fn performs no validation on its input.
> Wh
On 11/13/2012 11:06 AM, Johannes wrote:
I define a record
(defrecord point [x y])
and the following macro:
(defmacro drg
[typename components]
`(def ~(symbol (str typename "-" (str (first components
(fn [~(symbol "obj")] (get ~(symbol "obj") ~(symbol (str ":" (str
(first compone
You can't convert to keyword simply by (str ":" (str (first
components))...you need the (keyword (first components))...also why is
your argument (symbol "obj")? I'd prefer obj# or (gensym obj)...
Jim
On 13/11/12 10:06, Johannes wrote:
Hi,
I define a record
(defrecord point [x y])
and the fo
(symbol (str ":" (str (first components should be (keyword (first
components))
In your expansion, :x is not a keyword but a symbol starting by a colon --
the symbol fn performs no validation on its input.
When you copied/pasted it for evaluation it was then read as a keyword.
Btw I'm a little
Hi,
I define a record
(defrecord point [x y])
and the following macro:
(defmacro drg
[typename components]
`(def ~(symbol (str typename "-" (str (first components
(fn [~(symbol "obj")] (get ~(symbol "obj") ~(symbol (str ":" (str
(first components
the call
user> (macroexpa