, 2015 at 10:00:59 AM UTC-4, Sarkis Karayan wrote:
>
>
> Why doesn't this work?
> user=> (meta ^{:some-meta 123} 'n)
> nil
>
> While this works:
> user=> (meta ^{:some-meta 123} (fn [n] n))
> {:some-meta 123}
>
> And this works too:
> user=> (
ta ^{:some-meta 123} (fn [n] n))
> {:some-meta 123}
>
> And this works too:
> user=> (meta (with-meta 'n {:some-meta 123}))
> {:some-meta 123}
>
>
> Is this intended behavior? If so, what's the reasoning?
>
> Thanks,
> Sarkis
>
>
--
Y
Why doesn't this work?
user=> (meta ^{:some-meta 123} 'n)
nil
While this works:
user=> (meta ^{:some-meta 123} (fn [n] n))
{:some-meta 123}
And this works too:
user=> (meta (with-meta 'n {:some-meta 123}))
{:some-meta 123}
Is this intended behavior? If so, what&
The with-meta in (fn ^:static with-meta ...) is just the name the
function created by the fn form will know itself by. It will also be
used as the final segment of the name of the class of this function
object. It's not being evaluated in this position, and in fact it
could be replaced with
You are right, i noticed "it calls withMeta", but in the expression,
actually use with-meta to define with-meta, it's very strange, thank you
very much!
(def with-meta (fn ^:static with-meta [^clojure.lang.IObj x m]
(. x (withMeta m
On Saturday, Septe
Actually with-meta's definition does not refer to with-meta. Rather,
it calls withMeta, a method in the clojure.lang.IObj interface which
the first argument to with-meta is supposed to implement.
Cheers,
Michał
On 21 September 2013 09:01, wrote:
> Hi,
> I read the source abou
Hi,
I read the source about with-meta, and find def with-meta using
with-meta, can it? someone give a explain?
user=> (source with-meta)
(def
^{:arglists '([^clojure.lang.IObj obj m])
:doc "Returns an object of the same type and value as obj, with
map m as its metadat
Karsten Schmidt writes:
> Sinc the prefix map is built iteratively as part of the parsing I was
> hoping to attach it as meta data to the returned lazy-seq, since I
> can't see any other way of returning this map apart from attaching to
> every single triple in the seq (which seems like overkill)
below works for short seqs, but causes a stack
> overflow for large ones, which obviously means the lazy-seq mechanism is
> altered/broken if wrapped with `with-meta`. So I guess there must be another
> way...
>
> (defn meta-test
> [i]
> (with-meta
> (lazy-seq
>
Hello, what is the correct way (assuming there is one) to create a lazy-seq
with metadata attached? The below works for short seqs, but causes a stack
overflow for large ones, which obviously means the lazy-seq mechanism is
altered/broken if wrapped with `with-meta`. So I guess there must be
When you compare functions, it only checks if it is the same function
object (not if the function "behaves" the same way).
For example:
(= (fn []) (fn []))
;=> false
The reason you get false in your case is because with-meta returns a new
object every time you call it.
We need a
Hi,
only for persistent data structures (with a few caveats) [1]. For other
objects, such as function objects, equality check falls back to .equals().
Since with-meta returns a new object instance of an anonymous class,
.equals will always be false.
[1]
https://github.com/clojure/clojure/blob
I have unexplained behavior for with-meta.
As far as I understand with-meta should not alter object identity. E.g. if
we have the (= a b) => true for some a and b then
(= (with-meta a ma) (with-meta b mb)) => true should also hold for any ma
and mb.
So why do I get the following behav
> Hope that helps.
It did. Thanks a lot ! Your explanation made it perfectly clear,
what I was missing.
I didn't know that I was able to do something like
(def ^{:m 1} ^:dynamic *x* ^{:m 1} ^{:n 1} [])
That is useful to me.
And thank you for pointing out the relevant part of the LispReader
to m
Hi,
Am Samstag, 28. Januar 2012 19:48:23 UTC+1 schrieb raschedh:
Maybe the meta info is attached to (quote a) and not to the symbol, because
> that is "the next form read" ?
>
Exactly.
When I say
> (def z1 (with-meta [] {}))
> and
> (def z2 ^{} [])
> again,
Hi,
I've got two questions regarding meta information.
Question 1:
I can say
(def x1 (with-meta [] {:m 1}))
or
(def x2 ^{:m 1} [])
and will get my map back with either
(meta x1)
or
(meta x2).
But when I do
(def y1 (with-meta 'a {:m 1}))
(def y2 ^{:m 1} 'a)
only
(meta y1) spits
The main use I've had for with-meta is in macros, to attach e.g. type
hints to a symbol that's going into the macro expansion. There, the ^
reader macro adds the metadata too early rather than with-meta adding
it too late: ^ hints some symbol in the macro body and the compiler
will appl
2010/11/22 Mike K
> In "Programming Clojure" Stuart Halloway says:
>
> It is important to note that the metadata reader macro is not the same
> as with-meta. The metadata reader macro adds metadata for the
> compiler, and with-meta adds metadata for your own data:
>
I think it is due to the fact that [1 2 3] is self-evaluating.
If you were to write
(defn f [x] ^{:order :ascending} x)
(f [1 2 3])
the data would be on x in the compiler but never on [1 2 3]
with-meta would do the right thing.
On Mon, Nov 22, 2010 at 3:57 PM, Mike K wrote:
>
In "Programming Clojure" Stuart Halloway says:
It is important to note that the metadata reader macro is not the same
as with-meta. The metadata reader macro adds metadata for the
compiler, and with-meta adds metadata for your own data:
(def ^{:testdata true} foo (with-meta [1 2
On May 18, 2010, at 14:38 , gL wrote:
> Yes, (count mat8x8) is the appropriate method
>
> Using meta was my mistake to avoid passing the matrix dimension over
> and over again.
well you can make a function matrix-dim that memorizes the return values :)
--
You received this message because you
Yes, (count mat8x8) is the appropriate method
Using meta was my mistake to avoid passing the matrix dimension over
and over again.
On May 18, 2:23 pm, "Heinz N. Gies" wrote:
> On May 18, 2010, at 14:13 , gL wrote:
>
>
>
> > Hi
>
> > is it good coding sty
On May 18, 2010, at 14:13 , gL wrote:
> Hi
>
> is it good coding style to
>
> (def mat8x8
> (with-meta
> [[0 0 0 0 0 0 0 0]
...
> [0 0 0 0 0 0 0 0]]
> {:dim 8}))
>
> and later on to retrieve the matrix dimension with "(:dim (meta
&
Hi
is it good coding style to
(def mat8x8
(with-meta
[[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0]]
{:dim 8}))
and later
Meikel,
Thanks for the quick answer.
So I was only one step away from a solution !
I had :
user=> (let [arg (with-meta 's {:tag String}) arglist [arg] body (list
'.length arg)] (eval (list 'fn arglist body)))
Reflection warning, NO_SOURCE_PATH:52 - reference to field length
Hi,
On Feb 24, 12:50 pm, Jules wrote:
> user=> (let [arg (with-meta 's {:tag String}) arglist [arg] body (list
> '.length arg)] (eval (list 'fn arglist body)))
> Reflection warning, NO_SOURCE_PATH:40 - reference to field length
> can't be resolved.
> #
-side metadata, where both the method name and arg
type are parameterised.
I've spent some time messing around with eval and defmacro and then
found that I was being defeated by the #^ reader macro at every turn,
so I tried switching to using with-meta, but I cannot figure out how
to place metad
Excellent; this is perfect. I wonder why I didn't find it when I
searched the docs...thanks a lot, though.
On Oct 25, 3:16 pm, Phil Hagelberg wrote:
> samppi writes:
> > with-meta's behavior is annoying for me. I often have something like
> > this:
>
> > (de
samppi writes:
> with-meta's behavior is annoying for me. I often have something like
> this:
>
> (defn a [blah] (with-meta blah {:type ::incredible}))
> (defn b [foo] (with-meta (a foo) {::b 2}))
>
> I'd like ^(b []) to be {:type ::incredible, ::b 2}.
with-meta's behavior is annoying for me. I often have something like
this:
(defn a [blah] (with-meta blah {:type ::incredible}))
(defn b [foo] (with-meta (a foo) {::b 2}))
I'd like ^(b []) to be {:type ::incredible, ::b 2}. But with-meta
overwrites the metadata from a completely.
On Feb 23, 4:21 am, Christophe Grand wrote:
> Chouser a écrit :
>
>
>
> > On Sun, Feb 22, 2009 at 4:07 PM, jim wrote:
>
> >> In some old code, I did something like:
>
> >> (with-meta (concat [1 3] [8 4])
> >>{:tail true
Chouser a écrit :
> On Sun, Feb 22, 2009 at 4:07 PM, jim wrote:
>
>> In some old code, I did something like:
>>
>> (with-meta (concat [1 3] [8 4])
>>{:tail true}))
>>
>> which now fails. I believe it's because the re
t; exists. However, Seq's still accept meta-data, so:
>
> (with-meta (seq (concat [1 3] [8 4]))
> {:tail true})
>
> --Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure&
On Sun, Feb 22, 2009 at 4:07 PM, jim wrote:
>
> In some old code, I did something like:
>
> (with-meta (concat [1 3] [8 4])
>{:tail true}))
>
> which now fails. I believe it's because the result of concat is now
> some kind of reference.
>
&g
In some old code, I did something like:
(with-meta (concat [1 3] [8 4])
{:tail true}))
which now fails. I believe it's because the result of concat is now
some kind of reference.
Does anyone have any advice on a workaround?
On Thu, Jan 8, 2009 at 9:34 AM, Tomasz wrote:
>
> Hi.
>
> I'm just wondering wether it's a feature or a bug:
>
> (if (= (meta (with-meta [] {:test-key true}))
> (meta #^{:test-key true} []))
> "same"
> "not same")
>
> =&g
Hi.
I'm just wondering wether it's a feature or a bug:
(if (= (meta (with-meta [] {:test-key true}))
(meta #^{:test-key true} []))
"same"
"not same")
=>
"not same"
This behaviour is repeatable for empty lists, vectors and maps. Is
thi
Thanks Meikel!
That makes it clearer...
Regards,
Apurva
- Original Message -
From: "Meikel Brandmeyer" <[EMAIL PROTECTED]>
To: clojure@googlegroups.com
Sent: Sunday, August 31, 2008 8:46:01 PM GMT +05:30 Chennai, Kolkata, Mumbai,
New Delhi
Subject: Re: with-meta us
Hello,
I was wondering why the first scenario didn't work but couldn't find
details on this. Can someone please explain?
I also stumbled over this issue. Please read this sentence from the
"Metadata" section on clojure.org (http://clojure.org/metadata)
"Symbols and collections support metadat
Hi Clojure experts,
I am newbie to Clojure and was exploring metadata.
The following didn't work:
user=> (def v 10)
#'user/v
user=> (with-meta v {:info 1})
java.lang.IncompatibleClassChangeError
java.lang.IncompatibleClassChangeError
at clojure.with_meta__47.inv
40 matches
Mail list logo