Re: Is this expected behavior with meta data?

2015-06-25 Thread Andy-
, 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=> (

Re: Is this expected behavior with meta data?

2015-06-25 Thread gianluca torta
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

Is this expected behavior with meta data?

2015-06-25 Thread Sarkis Karayan
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&

Re: About with-meta source, can explain it by itself?

2013-09-21 Thread Michał Marczyk
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

Re: About with-meta source, can explain it by itself?

2013-09-21 Thread ljcppunix
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

Re: About with-meta source, can explain it by itself?

2013-09-21 Thread Michał Marczyk
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

About with-meta source, can explain it by itself?

2013-09-21 Thread ljcppunix
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

Re: lazy-seq with meta

2013-07-14 Thread Tassilo Horn
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)

Re: lazy-seq with meta

2013-07-12 Thread Karsten Schmidt
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 >

lazy-seq with meta

2013-07-12 Thread Karsten Schmidt
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

Re: Object identity and with-meta

2012-11-23 Thread Jonathan Fischer Friberg
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

Re: Object identity and with-meta

2012-11-23 Thread László Török
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

Object identity and with-meta

2012-11-23 Thread N8Dawgrr
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

Re: problems with meta

2012-01-31 Thread raschedh
> 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

Re: problems with meta

2012-01-29 Thread Meikel Brandmeyer (kotarak)
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,

problems with meta

2012-01-28 Thread raschedh
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

Re: with-meta vs ^{}

2010-11-22 Thread Ken Wesson
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

Re: with-meta vs ^{}

2010-11-22 Thread Laurent PETIT
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: >

Re: with-meta vs ^{}

2010-11-22 Thread nicolas.o...@gmail.com
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: >

with-meta vs ^{}

2010-11-22 Thread 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: (def ^{:testdata true} foo (with-meta [1 2

Re: with-meta

2010-05-18 Thread Heinz N. Gies
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

Re: with-meta

2010-05-18 Thread gL
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

Re: with-meta

2010-05-18 Thread Heinz N. Gies
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 &

with-meta

2010-05-18 Thread gL
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

Re: on-the-fly fn creation, arglist, with-meta, :tag

2010-02-24 Thread Jules
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

Re: on-the-fly fn creation, arglist, with-meta, :tag

2010-02-24 Thread Meikel Brandmeyer
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. > #

on-the-fly fn creation, arglist, with-meta, :tag

2010-02-24 Thread Jules
-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

Re: with-meta overwrites existing metadata; is there a way to just add

2009-10-25 Thread samppi
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

Re: with-meta overwrites existing metadata; is there a way to just add

2009-10-25 Thread Phil Hagelberg
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 overwrites existing metadata; is there a way to just add

2009-10-25 Thread samppi
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.

Re: with-meta and concat

2009-02-23 Thread Rich Hickey
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

Re: with-meta and concat

2009-02-23 Thread Christophe Grand
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

Re: with-meta and concat

2009-02-22 Thread jim
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&

Re: with-meta and concat

2009-02-22 Thread Chouser
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

with-meta and concat

2009-02-22 Thread jim
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?

Re: Reader metadata syntax vs. (with-meta ...)

2009-01-09 Thread Chouser
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

Reader metadata syntax vs. (with-meta ...)

2009-01-08 Thread Tomasz
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

Re: with-meta usage

2008-09-01 Thread Apurva Sharan
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

Re: with-meta usage

2008-08-31 Thread Meikel Brandmeyer
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

with-meta usage

2008-08-31 Thread Apurva
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