Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-20 Thread Amith George
Wow. This is rather hard to believe. But the execution time is now 10s. :D

All of your suggestions were on the mark. I implemented them in 
stages/commits. The command to execute the file remains the same - `lein 
run -m rdp.214-intermediate-arr 1 true`

1. Replaced the coordinates vector with separate x and y. Added relevant 
type hints.

https://github.com/amithgeorge/reddit-dailyprogrammer-clojure/blob/0ba1992ff892928beb71400fb44cce471318d187/src/rdp/214_intermediate_arr.clj#L60

Best time - 110s. Can't believe that simply changing from `[[^long x ^long 
y]]` to `[^long x ^long y]` can reduce the execution time by half!! 

2. Replaced the reduce in visible-color-frequencies-arr to nested 
loop-recurs. 

https://github.com/amithgeorge/reddit-dailyprogrammer-clojure/blob/75db0f839b748a4ca313bc319c4970a9a0329fb6/src/rdp/214_intermediate_arr.clj#L86

Best time - 90s. I thought reduce was equivalent to a loop recur. Might 
have to create a separate bare-minimum code sample to investigate why 
reduce was slower.

3. Stored papers in a native array. The parsed input still contains the 
papers in a vector. Its only when the main function is called with array 
true, that we convert to an array and store as a local value.

https://github.com/amithgeorge/reddit-dailyprogrammer-clojure/blob/0f49b7979f9c2e0e7a522f5ad875de0807d4e2da/src/rdp/214_intermediate_arr.clj#L115

Best time - 10s. I really don't get why the `some` over a vector was so 
slow. I tried replacing the `some` with a loop-recur (one style using an 
incrementing index and `get papers index` and the other style using `rest 
papers`.) Surprisingly both styles were slower than using `some`.

Thanks a lot for figuring out the slow areas. You made me aware of two 
tools I could use to find bottlenecks. At the very least, I now know 
Clojure doesn't necessarily mean 10x slower. 

That said, I really wanna know why storing papers in a native array made 
such a difference. Ideally I shouldn't have to expose a mutable array to 
other functions. In this case, the functions that accept/use the mutable 
array are meant to be private and under my control, so I could have some 
measure of confidence that mutation wouldn't occur. 


On Tuesday, 19 May 2015 23:02:11 UTC+5:30, Steven Yi wrote:
>
> Hi Amith, 
>
> One last optimization yields a 4x increase over the last version, and 
> now 12x over the original: 
>
> "Elapsed time: 22848.384642 msecs" 
>
> Code here: 
>
> https://gist.github.com/kunstmusik/db6e14118e818abf3bb8 
>
> Changes from last version: 
>
> - parse-inputs - Put parsed Paper objects into an array instead of a 
> vector. 
> - visible-color iterates through the array of Paper objects using a 
> loop-recur 
>
> I spent a moment looking at this using JVisualVM and saw from the 
> previous version that there was a lot of time spent in sequence 
> related stuff and in the some function.  I realized from using some it 
> was going through the vector items pretty often, and since that list 
> of items is static, are read-only within the context of the code, and 
> the values aren't shared around a codebase, I went ahead and optimized 
> it to use a fixed array. 
>
> Hope this runs well on your side too! 
> steven 
>
>
> On Tue, May 19, 2015 at 12:49 PM, Steven Yi  > wrote: 
> > Hi Amith, 
> > 
> > Just got back from a trip and had a chance to look at this again.  I'm 
> > not sure why you didn't see a change there; I'm running the same 
> > version of Clojure and Java here. 
> > 
> > I did another change to move from using a reduce to nested 
> > loop-recurs.  That with a some additional type hints for ^Paper, and 
> > moving the retrieval of :height and :width outside of the loops got a 
> > performance increase of almost 3x from the original: 
> > 
> > "Elapsed time: 109335.307414 msecs" 
> > 
> > The modified code is here: 
> > 
> > https://gist.github.com/kunstmusik/e1081d417142a90d5cfa 
> > 
> > Some general notes: 
> > 
> > - covered? - type-hinted ^Paper 
> > - visible-color - switched to pass in ^long x and y, used fn form for 
> > passed-in function and type-hinted ^Paper argument 
> > - visible-color-frequencies - switched to nested loop-recur, moved out 
> > height and width to single call outside critical loop 
> > 
> > Could you try the version from the gist there to see if you get a 
> > similar speedup? 
> > 
> > Cheers! 
> > steven 
> > 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-20 Thread Amith George
Oh, a few more things I observed;

   - I figured out how to use *unchecked-math* and *warn-on-reflection* :)

Earlier, I was setting them within a binding, but that didn't seem to do 
anything. Seems the correct way is to set them at the very top of the file, 
the first 2 lines after the namespace declaration. 

https://github.com/amithgeorge/reddit-dailyprogrammer-clojure/blob/0f49b7979f9c2e0e7a522f5ad875de0807d4e2da/src/rdp/214_intermediate_arr.clj#L4-L5

   - With the warnings now being generated properly, I was able to figure 
out where the type hints needed to be added. For example, 

(defn- covered?
  [^long canvas-x ^long canvas-y ^Paper paper]
  (and (<= ^long (.x1 paper) canvas-x ) (<= canvas-x ^long (.x2 paper)) 
   (<= ^long (.y1 paper) canvas-y ) (<= canvas-y ^long (.y2 paper


 The `^long` type hint is not needed within the `<=` forms. As paper is 
typed to `Paper` and the various `x1, x2 etc` fields are of type long in 
the Paper definition. 

   - Also, 

(recur (unchecked-inc i))


can be 

(recur (inc i))


because `*unchecked-math*` is set to a truthy value. 

Please correct me if I misunderstood anything :)


On Tuesday, 19 May 2015 23:02:11 UTC+5:30, Steven Yi wrote:
>
> Hi Amith, 
>
> One last optimization yields a 4x increase over the last version, and 
> now 12x over the original: 
>
> "Elapsed time: 22848.384642 msecs" 
>
> Code here: 
>
> https://gist.github.com/kunstmusik/db6e14118e818abf3bb8 
>
> Changes from last version: 
>
> - parse-inputs - Put parsed Paper objects into an array instead of a 
> vector. 
> - visible-color iterates through the array of Paper objects using a 
> loop-recur 
>
> I spent a moment looking at this using JVisualVM and saw from the 
> previous version that there was a lot of time spent in sequence 
> related stuff and in the some function.  I realized from using some it 
> was going through the vector items pretty often, and since that list 
> of items is static, are read-only within the context of the code, and 
> the values aren't shared around a codebase, I went ahead and optimized 
> it to use a fixed array. 
>
> Hope this runs well on your side too! 
> steven 
>
>
> On Tue, May 19, 2015 at 12:49 PM, Steven Yi  > wrote: 
> > Hi Amith, 
> > 
> > Just got back from a trip and had a chance to look at this again.  I'm 
> > not sure why you didn't see a change there; I'm running the same 
> > version of Clojure and Java here. 
> > 
> > I did another change to move from using a reduce to nested 
> > loop-recurs.  That with a some additional type hints for ^Paper, and 
> > moving the retrieval of :height and :width outside of the loops got a 
> > performance increase of almost 3x from the original: 
> > 
> > "Elapsed time: 109335.307414 msecs" 
> > 
> > The modified code is here: 
> > 
> > https://gist.github.com/kunstmusik/e1081d417142a90d5cfa 
> > 
> > Some general notes: 
> > 
> > - covered? - type-hinted ^Paper 
> > - visible-color - switched to pass in ^long x and y, used fn form for 
> > passed-in function and type-hinted ^Paper argument 
> > - visible-color-frequencies - switched to nested loop-recur, moved out 
> > height and width to single call outside critical loop 
> > 
> > Could you try the version from the gist there to see if you get a 
> > similar speedup? 
> > 
> > Cheers! 
> > steven 
> > 
> > On Tue, May 19, 2015 at 4:38 AM, Amith George  > wrote: 
> >> Hi, 
> >> 
> >> Thanks for taking the time to profile the code. I implemented the two 
> >> suggestions (using the two argument arity of lte and using aset instead 
> of 
> >> aset-long). 
> >> 
> >> 
> https://github.com/amithgeorge/reddit-dailyprogrammer-clojure/blob/2655a83f7fcf51e4fedae164d7d17386a0c8854f/src/rdp/214_intermediate_arr.clj
>  
> >> 
> >> lein run -m rdp.214-intermediate-arr 1 true 
> >> ;; took around 250s. 
> >> 
> >> The changes didn't seem to make a difference. The before and after runs 
> all 
> >> take between 250 - 260s. I kept the reduce as-is. From your reply, it 
> looks 
> >> like these two changes reduced the execution time by almost 30s. Any 
> >> thoughts of why there isn't much of a difference for me? - I am using 
> >> Clojure 1.7.3-beta3 and Oracle Java 1.8.0_45 on OSX Mavericks. 
> >> 
> >> On Saturday, 16 May 2015 08:32:12 UTC+5:30, Steven Yi wrote: 
> >>> 
> >>> Ah, I see.  Well, I think then you can ignore the stuff about warming 
> >>> up, as this certainly takes a while to run here: 
> >>> 
> >>> "Elapsed time: 314763.93 msecs" 
> >>> 
> >>> I tried profiling with Yourkit and saw a couple of things to change: 
> >>> 
> >>> ;; I think lte with more than two args ends up being slower than 
> >>> unrolling out here 
> >>> ;; I also tried type-hinting values from paper to ^long to avoid lte 
> >>> calls with Number 
> >>> (defn- covered? 
> >>>   [[^long canvas-x ^long canvas-y] paper] 
> >>>   (and (<= ^long (:x1 paper) canvas-x ) (<= canvas-x ^long (:x2 
> paper)) 
> >>>(<= ^long (:y1 paper) canvas-y ) (<= canvas-y ^long (:y2 
>

Re: Adding JavaDocs for Interoperability with Java?

2015-05-20 Thread Timur Sungur
Thanks everyone for their helpful answers!

On Wed, May 20, 2015 at 6:22 AM 'wparke...@yahoo.com' via Clojure <
clojure@googlegroups.com> wrote:

> A few other thoughts here:
>
> - To elaborate on Colin's suggestion a bit, if you define Java interfaces
> in Java, it's easy to create a function that reifies those interfaces (this
> means that it returns an object that implements arbitrary interfaces).  In
> this case the only interop a consumer would need to worry about would be a
> call to a Clojure function that returns an instance of the relevant
> object.  Such a function would basically serve the role of a factory
> constructor.  Everything else would be plain Java from their point of view.
> https://clojuredocs.org/clojure.core/reify
> - Apologies if it's too obvious, but Clojure does have a docs tool.
> Obviously it wouldn't look the same as Javadocs, but it might fit your
> needs with a little elaboration in the docstrings on how to call them from
> Java. https://github.com/weavejester/codox
> - If you really need Javadoc (corporate compliance reasons?), you could
> create a Java class that uses the Clojure Java API to call the Clojure
> functions and expose that class.  I personally prefer using gen-class with
> static methods that call the relevant Clojure functions, since manually
> writing a Java wrapper for Clojure functions gets a little tedious, but it
> does allow complete hiding of the Clojure code behind a Java wrapper.
> http://clojure.github.io/clojure/javadoc/clojure/java/api/package-summary.html
>
> On Tuesday, May 19, 2015 at 4:41:29 AM UTC-5, Timur wrote:
>>
>> Hi everyone,
>>
>> Is it possible to add JavaDocs to Clojure so that it can support Java
>> programmers. For instance a JavaDoc to a protocol or to an interface
>> defined in Clojure which is later on read by a Java developer?
>>
>> Regards,
>>
>> Timur
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/xCfrV3YhEsw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-20 Thread Leif
"Elapsed time: 1155.723592 msecs"

I implemented the changes Amith and Steven suggested on my multithreaded 
version.  I think we can safely say that, with a modest effort, Clojure can 
compare favorably to C#. :)

https://gist.github.com/leifp/a864bca941ecdacb5840
Cheers,
Leif

On Tuesday, May 19, 2015 at 5:18:24 AM UTC-4, Amith George wrote:
>
> Hi,
>
> Thank you for taking the time. That is a rather smart algo. The code and 
> the changes were easy to understand. 
>
> I didn't implement the parallelized version as my aim was to understand 
> why the clojure version was so slow compared to the equivalent C# version. 
> (Btw, you have access to a 12 core machine! :O)
>
> Ok. Two versions of the code - 
>
>
> https://github.com/amithgeorge/reddit-dailyprogrammer-clojure/blob/2655a83f7fcf51e4fedae164d7d17386a0c8854f/src/rdp/214_intermediate_leifp.clj
>
> lein run -m rdp.214-intermediate-leifp 1
> ;; took around 100s
>
>
> https://github.com/amithgeorge/reddit-dailyprogrammer-clojure/blob/2655a83f7fcf51e4fedae164d7d17386a0c8854f/src/rdp/214_intermediate_arr_leifp.clj
>
> lein run -m rdp.214-intermediate-arr-leifp 1 true
> ;; took around 70s
>
> The first file (214_intermediate_leifp.clj) is similar to what you had 
> after point 1. 
>
> The second file (214_intermediate_arr_leifp.clj) is your algo combined 
> with the tips provided in the posts above - mainly - using type hints; 
> native arrays, two argument arity of `<=` etc. It also uses a record 
> `Paper` instead of a map. However the record values are accessed by the 
> keyword instead of direct field access. 
>
> Applying those tips to my algo, reduced the time taken from 500s to 250s. 
> For your algo, those tips only reduced the time taken by 1/4th. Which makes 
> sense as your algo performs far less operations, so there are lesser number 
> of operations that can get a speed bump... 
>
> That said, I am none the wiser on how to write to fast single threaded 
> clojure :( 
>
> On Tuesday, 19 May 2015 05:34:21 UTC+5:30, Leif wrote:
>>
>> Summary:  With a new algorithm + parallelism, I reduced it from 528s to 
>> 11s.
>>
>> This sounded fun, so I took a crack at it, starting with your solution.  
>> Description and patch files here: 
>> https://gist.github.com/leifp/a864bca941ecdacb5840
>>
>> Starting with your solution, I:
>>
>>1. Divided the canvas into 100 blocks, created an index of 
>>{blockindex -> papers that intersect that block}. The reasoning is that 
>> if 
>>we calculate which block a pixel is in, we only need to check the papers 
>>that intersect that block.  In the extreme case, certain blocks only 
>>intersected one paper (the background).  In the original code we would 
>> have 
>>had to check all 100 papers for each pixel in that block; now we just 
>> check 
>>one. (5x average speedup)
>>2. Changed the code to calculate color areas for a block at a time; 
>>after that, it was a simple 2-line change to parallelize the work using 
>> pmap. 
>>(8x speedup on 12-core machine) 
>>3. Make paper a record; use direct field access (this resulted in a 
>>modest ~10% improvement, but maybe not worth it).
>>
>> So clojure was helpful in trying out algorithm ideas and parallelizing 
>> the code.  The final program would no doubt also be faster in C#, but my 
>> goal is "fast enough."
>>
>> Further idea (which I don't think I'll implement):  Index the papers 
>> using an data structure built for geometrical indexing, like an R-tree or 
>> variation, to get a near-optimal index without tuning.
>>
>> I hope my solution is interesting to you.  Questions / comments welcome.
>> Leif
>>
>> P.S.  I apologize for the messy, repetitive, stream-of-consciousness code.
>>
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: One more argument for cyclic dependencies

2015-05-20 Thread Justin Smith
I'll second the recommendation to use protocols or interfaces to solve this.

Clojure is fairly opinionated in that the tools available should push you 
toward developing against interfaces or protocols rather than concrete 
implementations. Things become much simpler when you accept this. You can 
even have a single file that defines all the protocols you might need, and 
each of your classes can implement one or more protocols, while defining 
methods or fields that use other protocols with no circularity needed.

On Tuesday, May 19, 2015 at 8:57:19 AM UTC-7, Mars0i wrote:
>
> Gary wrote: 
>
> * I was under the impression that Clojure only restricted cyclic 
> dependencies between ns forms. Have you tried calling 
> import/require/gen-class directly? 
>
> Not much.  I did try one trick that involved switching namespaces inside a 
> file, but it didn't work. I can try other things.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-20 Thread Steven Yi
Hi Amith,

Very glad you're seeing the performance increase there too!  I think
you're right about both the extraneous type hints and the
unchecked-math. I tend to turn on unchecked-math in a leiningen
profile that I use while developing, but leave it set to default for
normal builds. Because of that, I'm in the habit of using
unchecked-inc.  For the extra type hints there, I think I had
originally used the :member syntax and changed it to the .member
syntax but had left the type hints in.  It would have been better to
just use .member and leave the type hints out as you noted.

For some/sequences vs. loop-recur/arrays, I haven't done a deep enough
analysis and don't want to say something incorrect.  Here's some notes
in looking at it just now:

- get - using get [1] calls to RT[2], which in turns does some
instanceof checks to then call the specific type's function for
getting a value.  With PersistentVector[3], that should translate to
the ILookup.valAt() call, which in turn calls nth.  Compared to the
inlined aget[4][5] call, it's a lot more layers of functions.

- some[6] - this ends up calling first and next[7], which ends up
calling first and next in PersistentVector[8], which ends up
allocating a new ChunkedSeq. Granted, object allocation on the JVM is
super cheap (pointer bump) compared to allocating memory with
something like malloc in C, there's still a cost there + the setting
of fields in the constructor.  It's all very cheap operations on their
own but I'm guessing that in this context of a critical loop, plus the
logic to check for boundaries in the first/next calls, are adding up
compared to just indexing into the full array.

- some vs. loop-recur/rest - In this case, I'm not sure.  It might be
due to how you coded the loop with the call to empty? (assuming the
commented out code in your example is what you used).

I guess then all of this becomes a series of tradeoffs and trying to
find the right balance. IMO, sequences offer so many benefits over
arrays. It's really only in certain critical sections of code where
the performance costs might outweigh programmer benefits. I guess even
then, the amortized cost of the sequence compared to array goes down
if the the operations on the individual items becomes more expensive.
In this case it happened to be that the cost of the operation on the
set of values was pretty small compared to the cost of calling
first/next.  Maybe in other scenarios the use of an array won't give
the same benefit.

Well, hopefully if I missed something in the analysis above someone
here will correct me. :)

Cheers!
steven


[1] - 
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L1421-L1429
[2] - 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L719-L744
[3] - 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentVector.java#L657-L671
[4] - 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L2321-L2323
[5] - 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L2321-L2323
[6] - 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L2321-L2323
[7] - 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L651-L679
[8] - 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L651-L679


On Wed, May 20, 2015 at 9:37 AM, Amith George  wrote:
> Oh, a few more things I observed;
>
>- I figured out how to use *unchecked-math* and *warn-on-reflection* :)
>
> Earlier, I was setting them within a binding, but that didn't seem to do
> anything. Seems the correct way is to set them at the very top of the file,
> the first 2 lines after the namespace declaration.
>
> https://github.com/amithgeorge/reddit-dailyprogrammer-clojure/blob/0f49b7979f9c2e0e7a522f5ad875de0807d4e2da/src/rdp/214_intermediate_arr.clj#L4-L5
>
>- With the warnings now being generated properly, I was able to figure
> out where the type hints needed to be added. For example,
>
> (defn- covered?
>   [^long canvas-x ^long canvas-y ^Paper paper]
>   (and (<= ^long (.x1 paper) canvas-x ) (<= canvas-x ^long (.x2 paper))
>(<= ^long (.y1 paper) canvas-y ) (<= canvas-y ^long (.y2 paper
>
>
>  The `^long` type hint is not needed within the `<=` forms. As paper is
> typed to `Paper` and the various `x1, x2 etc` fields are of type long in the
> Paper definition.
>
>- Also,
>
> (recur (unchecked-inc i))
>
>
> can be
>
> (recur (inc i))
>
>
> because `*unchecked-math*` is set to a truthy value.
>
> Please correct me if I misunderstood anything :)
>
>
> On Tuesday, 19 May 2015 23:02:11 UTC+5:30, Steven Yi wrote:
>>
>> Hi Amith,
>>
>> One last optimization yields a 4x increase over the last version, and
>> now 12x over the original:
>>
>> "Elapsed time: 22848.384642 msecs"
>>
>> Code here:
>>
>> https://gist.github.com/kunstmusik/db6e14118e818abf3bb8
>>
>> Changes from last version:
>>
>> - parse-inputs - Put parsed 

Using @ alone

2015-05-20 Thread Pierre Thibault
Is possible to use the operator '@' alone? In the Joy Of Clojure book it is 
presented as '~@'. I would like an example.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using @ alone

2015-05-20 Thread Colin Yates
@my-atom is the same as (deref my-atom), is that what you mean?
On 20 May 2015 23:35, "Pierre Thibault"  wrote:

> Is possible to use the operator '@' alone? In the Joy Of Clojure book it
> is presented as '~@'. I would like an example.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Accessing static fields

2015-05-20 Thread Pierre Thibault
I can do Math/PI put how can I access PI if Math is in a expression like 
'(Math) for example?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using @ alone

2015-05-20 Thread Laurens Van Houtven
Hi Pierre,


> On May 20, 2015, at 3:35 PM, Pierre Thibault  
> wrote:
> 
> Is possible to use the operator '@' alone? In the Joy Of Clojure book it is 
> presented as '~@'. I would like an example.

There are multiple contexts in which @ could be used. One is syntactic sugar 
for the deref function; @x is just (deref x), where x is some reference type 
like an atom.

~@, unquote-splice, is an entirely different beast. It is used inside 
syntax-quote (a backtick, `) in macros to mean “take all of these forms and put 
them into this form”, e.g.:

(let [xs ‘(1 2 3 4)]
  `(+ ~@xs))

turns into:

(+ 1 2 3 4)

… so the difference between it and just ~ is the “splicing”; regular unquote 
(~) would get you:

(+ [1 2 3 4])


hth
lvh


> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing static fields

2015-05-20 Thread Laurens Van Houtven
Hi Pierre,

> On May 20, 2015, at 3:38 PM, Pierre Thibault  
> wrote:
> 
> I can do Math/PI put how can I access PI if Math is in a expression like 
> '(Math) for example?

Can you provide a more specific example? Math/PI is always Math/PI, it doesn’t 
change if you put it in a nested form/expression.

hth
lvh

> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using @ alone

2015-05-20 Thread Pierre Thibault
For example:

(def foo '(1 2 3))
(+ @foo)

Does not work. I am expecting 6.

Le mercredi 20 mai 2015 18:37:05 UTC-4, Colin Yates a écrit :
>
> @my-atom is the same as (deref my-atom), is that what you mean?
> On 20 May 2015 23:35, "Pierre Thibault"  > wrote:
>
>> Is possible to use the operator '@' alone? In the Joy Of Clojure book it 
>> is presented as '~@'. I would like an example.
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using @ alone

2015-05-20 Thread Pierre Thibault
OK,

~@ is one operator, I thought it was two different operators.

Thank you.

Le mercredi 20 mai 2015 18:38:50 UTC-4, Laurens Van Houtven a écrit :
>
> Hi Pierre,
>
>
> On May 20, 2015, at 3:35 PM, Pierre Thibault  > wrote:
>
> Is possible to use the operator '@' alone? In the Joy Of Clojure book it 
> is presented as '~@'. I would like an example.
>
>
> There are multiple contexts in which @ could be used. One is syntactic 
> sugar for the deref function; @x is just (deref x), where x is some 
> reference type like an atom.
>
> ~@, unquote-splice, is an entirely different beast. It is used inside 
> syntax-quote (a backtick, `) in macros to mean “take all of these forms and 
> put them into this form”, e.g.:
>
> (let [xs ‘(1 2 3 4)]
>   `(+ ~@xs))
>
> turns into:
>
> (+ 1 2 3 4)
>
> … so the difference between it and just ~ is the “splicing”; regular 
> unquote (~) would get you:
>
> (+ [1 2 3 4])
>
>
> hth
> lvh
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com 
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com 
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+u...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using @ alone

2015-05-20 Thread Colin Yates
@ (and deref) are used to dereference constructs which support multiple
values over time; atoms, futures and promises etc. ~@ is a different thing
entirely and is used to desplice lists in a macro.

In your example, you aren't in a macro and '() is defining a set, I.e. it
isn't a temperal construct.
On 20 May 2015 23:43, "Pierre Thibault"  wrote:

> For example:
>
> (def foo '(1 2 3))
> (+ @foo)
>
> Does not work. I am expecting 6.
>
> Le mercredi 20 mai 2015 18:37:05 UTC-4, Colin Yates a écrit :
>>
>> @my-atom is the same as (deref my-atom), is that what you mean?
>> On 20 May 2015 23:35, "Pierre Thibault"  wrote:
>>
>>> Is possible to use the operator '@' alone? In the Joy Of Clojure book it
>>> is presented as '~@'. I would like an example.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing static fields

2015-05-20 Thread Pierre Thibault
Hi Laurens,

My example was not very good. Here another one:

(.format (first '(String)) "%s" "foo")

Imagine String is obtained dynamically. I guess then I have to use Java 
reflection to do a dynamic invocation. I guess I am confused because 
classes in Java are not objects.

Le mercredi 20 mai 2015 18:40:13 UTC-4, Laurens Van Houtven a écrit :
>
> Hi Pierre,
>
> On May 20, 2015, at 3:38 PM, Pierre Thibault  > wrote:
>
> I can do Math/PI put how can I access PI if Math is in a expression like 
> '(Math) for example?
>
>
> Can you provide a more specific example? Math/PI is always Math/PI, it 
> doesn’t change if you put it in a nested form/expression.
>
> hth
> lvh
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com 
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com 
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+u...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing static fields

2015-05-20 Thread Pierre Thibault
I gave it a try:

(.. (class String) (getMethod "format" (into-array Class [String 
(Class/forName "[Ljava.lang.Object;")])))

But I am unable to get the method. I gave up.

Le mercredi 20 mai 2015 19:12:05 UTC-4, Pierre Thibault a écrit :
>
> Hi Laurens,
>
> My example was not very good. Here another one:
>
> (.format (first '(String)) "%s" "foo")
>
> Imagine String is obtained dynamically. I guess then I have to use Java 
> reflection to do a dynamic invocation. I guess I am confused because 
> classes in Java are not objects.
>
> Le mercredi 20 mai 2015 18:40:13 UTC-4, Laurens Van Houtven a écrit :
>>
>> Hi Pierre,
>>
>> On May 20, 2015, at 3:38 PM, Pierre Thibault  
>> wrote:
>>
>> I can do Math/PI put how can I access PI if Math is in a expression like 
>> '(Math) for example?
>>
>>
>> Can you provide a more specific example? Math/PI is always Math/PI, it 
>> doesn’t change if you put it in a nested form/expression.
>>
>> hth
>> lvh
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using @ alone

2015-05-20 Thread Pierre Thibault
OK,

I don't know how to write macros yet. I was confused.

Thank you.

Le mercredi 20 mai 2015 18:48:03 UTC-4, Colin Yates a écrit :
>
> @ (and deref) are used to dereference constructs which support multiple 
> values over time; atoms, futures and promises etc. ~@ is a different thing 
> entirely and is used to desplice lists in a macro.
>
> In your example, you aren't in a macro and '() is defining a set, I.e. it 
> isn't a temperal construct.
> On 20 May 2015 23:43, "Pierre Thibault"  > wrote:
>
>> For example:
>>
>> (def foo '(1 2 3))
>> (+ @foo)
>>
>> Does not work. I am expecting 6.
>>
>> Le mercredi 20 mai 2015 18:37:05 UTC-4, Colin Yates a écrit :
>>>
>>> @my-atom is the same as (deref my-atom), is that what you mean?
>>> On 20 May 2015 23:35, "Pierre Thibault"  wrote:
>>>
 Is possible to use the operator '@' alone? In the Joy Of Clojure book 
 it is presented as '~@'. I would like an example.

 -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using @ alone

2015-05-20 Thread Colin Yates
That's OK, I am also confused between '() which is a literal list and #{}
which is a literal set :).
On 21 May 2015 00:55, "Pierre Thibault"  wrote:

> OK,
>
> I don't know how to write macros yet. I was confused.
>
> Thank you.
>
> Le mercredi 20 mai 2015 18:48:03 UTC-4, Colin Yates a écrit :
>>
>> @ (and deref) are used to dereference constructs which support multiple
>> values over time; atoms, futures and promises etc. ~@ is a different thing
>> entirely and is used to desplice lists in a macro.
>>
>> In your example, you aren't in a macro and '() is defining a set, I.e. it
>> isn't a temperal construct.
>> On 20 May 2015 23:43, "Pierre Thibault"  wrote:
>>
>>> For example:
>>>
>>> (def foo '(1 2 3))
>>> (+ @foo)
>>>
>>> Does not work. I am expecting 6.
>>>
>>> Le mercredi 20 mai 2015 18:37:05 UTC-4, Colin Yates a écrit :

 @my-atom is the same as (deref my-atom), is that what you mean?
 On 20 May 2015 23:35, "Pierre Thibault"  wrote:

> Is possible to use the operator '@' alone? In the Joy Of Clojure book
> it is presented as '~@'. I would like an example.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient
> with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using @ alone

2015-05-20 Thread Pierre Thibault
No:

(type '())
clojure.lang.PersistentList$EmptyList

It a list just like it should be.

Le mercredi 20 mai 2015 20:02:22 UTC-4, Colin Yates a écrit :
>
> That's OK, I am also confused between '() which is a literal list and #{} 
> which is a literal set :).
> On 21 May 2015 00:55, "Pierre Thibault"  > wrote:
>
>> OK,
>>
>> I don't know how to write macros yet. I was confused.
>>
>> Thank you.
>>
>> Le mercredi 20 mai 2015 18:48:03 UTC-4, Colin Yates a écrit :
>>>
>>> @ (and deref) are used to dereference constructs which support multiple 
>>> values over time; atoms, futures and promises etc. ~@ is a different thing 
>>> entirely and is used to desplice lists in a macro.
>>>
>>> In your example, you aren't in a macro and '() is defining a set, I.e. 
>>> it isn't a temperal construct.
>>> On 20 May 2015 23:43, "Pierre Thibault"  wrote:
>>>
 For example:

 (def foo '(1 2 3))
 (+ @foo)

 Does not work. I am expecting 6.

 Le mercredi 20 mai 2015 18:37:05 UTC-4, Colin Yates a écrit :
>
> @my-atom is the same as (deref my-atom), is that what you mean?
> On 20 May 2015 23:35, "Pierre Thibault"  wrote:
>
>> Is possible to use the operator '@' alone? In the Joy Of Clojure book 
>> it is presented as '~@'. I would like an example.
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient 
>> with your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google 
>> Groups "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to clojure+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>  -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing static fields

2015-05-20 Thread Ambrose Bonnaire-Sergeant
Yes, you must use Java reflection.

Thanks,
Ambrose

On Thu, May 21, 2015 at 7:54 AM, Pierre Thibault  wrote:

> I gave it a try:
>
> (.. (class String) (getMethod "format" (into-array Class [String
> (Class/forName "[Ljava.lang.Object;")])))
>
> But I am unable to get the method. I gave up.
>
>
> Le mercredi 20 mai 2015 19:12:05 UTC-4, Pierre Thibault a écrit :
>>
>> Hi Laurens,
>>
>> My example was not very good. Here another one:
>>
>> (.format (first '(String)) "%s" "foo")
>>
>> Imagine String is obtained dynamically. I guess then I have to use Java
>> reflection to do a dynamic invocation. I guess I am confused because
>> classes in Java are not objects.
>>
>> Le mercredi 20 mai 2015 18:40:13 UTC-4, Laurens Van Houtven a écrit :
>>>
>>> Hi Pierre,
>>>
>>> On May 20, 2015, at 3:38 PM, Pierre Thibault 
>>> wrote:
>>>
>>> I can do Math/PI put how can I access PI if Math is in a expression like
>>> '(Math) for example?
>>>
>>>
>>> Can you provide a more specific example? Math/PI is always Math/PI, it
>>> doesn’t change if you put it in a nested form/expression.
>>>
>>> hth
>>> lvh
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing static fields

2015-05-20 Thread Keith Irwin
Not sure if this helps, but:

user => (eval (symbol "Math" "PI”))
3.141592653589793

user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s" 
(to-array ["adasd"])))
“adasd"

Maybe a macro of some sort?

(defmacro invoke-static
  [c meth & args]
  `(. ~(resolve (symbol c)) ~(symbol meth) ~@args))

user => (invoke-static "java.lang.String" "format" "the %s" (to-array ["foo"]))
“the foo"

user=> (invoke-static "System" "currentTimeMillis")
1432170076378

That kind of thing?

> On May 20, 2015, at 4:54 PM, Pierre Thibault  
> wrote:
> 
> I gave it a try:
> 
> (.. (class String) (getMethod "format" (into-array Class [String 
> (Class/forName "[Ljava.lang.Object;")])))
> 
> But I am unable to get the method. I gave up.
> 
> Le mercredi 20 mai 2015 19:12:05 UTC-4, Pierre Thibault a écrit :
> Hi Laurens,
> 
> My example was not very good. Here another one:
> 
> (.format (first '(String)) "%s" "foo")
> 
> Imagine String is obtained dynamically. I guess then I have to use Java 
> reflection to do a dynamic invocation. I guess I am confused because classes 
> in Java are not objects.
> 
> Le mercredi 20 mai 2015 18:40:13 UTC-4, Laurens Van Houtven a écrit :
> Hi Pierre,
> 
>> On May 20, 2015, at 3:38 PM, Pierre Thibault > 
>> wrote:
>> 
>> I can do Math/PI put how can I access PI if Math is in a expression like 
>> '(Math) for example?
> 
> Can you provide a more specific example? Math/PI is always Math/PI, it 
> doesn’t change if you put it in a nested form/expression.
> 
> hth
> lvh
> 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com <>
>> Note that posts from new members are moderated - please be patient with your 
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en 
>> 
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <>.
>> For more options, visit https://groups.google.com/d/optout 
>> .
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] Demo of the Holy Grail workflow

2015-05-20 Thread Daniel Szmulewicz
Hi everybody, 

A video showcasing the Holy Grail workflow has been posted on youtube.

https://www.youtube.com/watch?v=eoxsSrFK_Is

The workflow is built on top of Boot , a build tool, 
and system , 
a component library. It tries to turn the experience of developing for the 
web into a liberating and seamless experience.

Here are some of the properties of said workflow: 

   - Manual and automatic mode, ie. either you manipulate the system in the 
   REPL, or yo configure it to react to editing changes.
   - Restartable system. What warrants a system restart is 
   user-configurable. File-based granularity.
   - Changes that do not require a restart are available in the running 
   system instantly (via namespace reloading).
   - Full *Lisp-style* interactive programming via the REPL and 
   hot-reloading in the browser.
   
The video shows us a real-life, unmoderated development session. Some 
critics hailed it as an uncompromising, gut-wrenching piece of cinéma 
vérité. Viewer Discretion Is Advised. Thank you.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing static fields

2015-05-20 Thread Ambrose Bonnaire-Sergeant
Macros won't work because they are expanded at compile-time. We want to
choose the method at runtime.

Thanks,
Ambrose

On Thu, May 21, 2015 at 9:02 AM, Keith Irwin  wrote:

> Not sure if this helps, but:
>
> user => (eval (symbol "Math" "PI”))
> 3.141592653589793
>
> user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s"
> (to-array ["adasd"])))
> “adasd"
>
> Maybe a macro of some sort?
>
> (defmacro invoke-static
>   [c meth & args]
>   `(. ~(resolve (symbol c)) ~(symbol meth) ~@args))
>
> user => (invoke-static "java.lang.String" "format" "the %s" (to-array
> ["foo"]))
> “the foo"
>
> user=> (invoke-static "System" "currentTimeMillis")
> 1432170076378
>
> That kind of thing?
>
> On May 20, 2015, at 4:54 PM, Pierre Thibault 
> wrote:
>
> I gave it a try:
>
> (.. (class String) (getMethod "format" (into-array Class [String
> (Class/forName "[Ljava.lang.Object;")])))
>
> But I am unable to get the method. I gave up.
>
> Le mercredi 20 mai 2015 19:12:05 UTC-4, Pierre Thibault a écrit :
>>
>> Hi Laurens,
>>
>> My example was not very good. Here another one:
>>
>> (.format (first '(String)) "%s" "foo")
>>
>> Imagine String is obtained dynamically. I guess then I have to use Java
>> reflection to do a dynamic invocation. I guess I am confused because
>> classes in Java are not objects.
>>
>> Le mercredi 20 mai 2015 18:40:13 UTC-4, Laurens Van Houtven a écrit :
>>>
>>> Hi Pierre,
>>>
>>> On May 20, 2015, at 3:38 PM, Pierre Thibault 
>>> wrote:
>>>
>>> I can do Math/PI put how can I access PI if Math is in a expression like
>>> '(Math) for example?
>>>
>>>
>>> Can you provide a more specific example? Math/PI is always Math/PI, it
>>> doesn’t change if you put it in a nested form/expression.
>>>
>>> hth
>>> lvh
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing static fields

2015-05-20 Thread Keith Irwin
What about eval?

user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s" 
(to-array ["adasd"])))
“adasd"

I have a function form:

(defn static-invoke
  [c meth & args]
  (eval `(. ~(resolve (symbol c)) ~(symbol meth) ~@args)))

Which works for some things:

user => (static-invoke “System” “currentTimeMillis”)
1432171781154

But the String thing was problematic:

user => (static-invoke "String" "format" "a %s” (quote (to-array ["foo”])))
“a foo”

(This gave a weird error until I quoted the to-array form.)

Still not helpful?


> On May 20, 2015, at 6:09 PM, Ambrose Bonnaire-Sergeant 
>  wrote:
> 
> Macros won't work because they are expanded at compile-time. We want to 
> choose the method at runtime.
> 
> Thanks,
> Ambrose
> 
> On Thu, May 21, 2015 at 9:02 AM, Keith Irwin  > wrote:
> Not sure if this helps, but:
> 
> user => (eval (symbol "Math" "PI”))
> 3.141592653589793
> 
> user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s" 
> (to-array ["adasd"])))
> “adasd"
> 
> Maybe a macro of some sort?
> 
> (defmacro invoke-static
>   [c meth & args]
>   `(. ~(resolve (symbol c)) ~(symbol meth) ~@args))
> 
> user => (invoke-static "java.lang.String" "format" "the %s" (to-array 
> ["foo"]))
> “the foo"
> 
> user=> (invoke-static "System" "currentTimeMillis")
> 1432170076378
> 
> That kind of thing?
> 
>> On May 20, 2015, at 4:54 PM, Pierre Thibault > > wrote:
>> 
>> I gave it a try:
>> 
>> (.. (class String) (getMethod "format" (into-array Class [String 
>> (Class/forName "[Ljava.lang.Object;")])))
>> 
>> But I am unable to get the method. I gave up.
>> 
>> Le mercredi 20 mai 2015 19:12:05 UTC-4, Pierre Thibault a écrit :
>> Hi Laurens,
>> 
>> My example was not very good. Here another one:
>> 
>> (.format (first '(String)) "%s" "foo")
>> 
>> Imagine String is obtained dynamically. I guess then I have to use Java 
>> reflection to do a dynamic invocation. I guess I am confused because classes 
>> in Java are not objects.
>> 
>> Le mercredi 20 mai 2015 18:40:13 UTC-4, Laurens Van Houtven a écrit :
>> Hi Pierre,
>> 
>>> On May 20, 2015, at 3:38 PM, Pierre Thibault > 
>>> wrote:
>>> 
>>> I can do Math/PI put how can I access PI if Math is in a expression like 
>>> '(Math) for example?
>> 
>> Can you provide a more specific example? Math/PI is always Math/PI, it 
>> doesn’t change if you put it in a nested form/expression.
>> 
>> hth
>> lvh
>> 
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com <>
>>> Note that posts from new members are moderated - please be patient with 
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com <>
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en 
>>> 
>>> --- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to clojure+u...@googlegroups.com <>.
>>> For more options, visit https://groups.google.com/d/optout 
>>> .
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with your 
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com 
>> 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en 
>> 
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+unsubscr...@googlegroups.com 
>> .
>> For more options, visit https://groups.google.com/d/optout 
>> .
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com 
> 
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com 
> 
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from 

Re: Accessing static fields

2015-05-20 Thread Pierre Thibault
This is working well. It is pretty complex to do something that is suppose 
to be simple. I am not yet able to understand this code. I find Clojure 
hard to learn.

Thank you Keith.

Le mercredi 20 mai 2015 21:36:02 UTC-4, Keith Irwin a écrit :
>
> What about eval?
>
> user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s" 
> (to-array ["adasd"])))
> “adasd"
>
> I have a function form:
>
> (defn static-invoke
>   [c meth & args]
>   (eval `(. ~(resolve (symbol c)) ~(symbol meth) ~@args)))
>
> Which works for some things:
>
> user => (static-invoke “System” “currentTimeMillis”)
> 1432171781154
>
> But the String thing was problematic:
>
> user => (static-invoke "String" "format" "a %s” (quote (to-array ["foo”])))
> “a foo”
>
> (This gave a weird error until I quoted the to-array form.)
>
> Still not helpful?
>
>
> On May 20, 2015, at 6:09 PM, Ambrose Bonnaire-Sergeant <
> abonnair...@gmail.com > wrote:
>
> Macros won't work because they are expanded at compile-time. We want to 
> choose the method at runtime.
>
> Thanks,
> Ambrose
>
> On Thu, May 21, 2015 at 9:02 AM, Keith Irwin  > wrote:
>
>> Not sure if this helps, but:
>>
>> user => (eval (symbol "Math" "PI”))
>> 3.141592653589793
>>
>> user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s" 
>> (to-array ["adasd"])))
>> “adasd"
>>
>> Maybe a macro of some sort?
>>
>> (defmacro invoke-static
>>   [c meth & args]
>>   `(. ~(resolve (symbol c)) ~(symbol meth) ~@args))
>>
>> user => (invoke-static "java.lang.String" "format" "the %s" (to-array 
>> ["foo"]))
>> “the foo"
>>
>> user=> (invoke-static "System" "currentTimeMillis")
>> 1432170076378
>>
>> That kind of thing?
>>
>> On May 20, 2015, at 4:54 PM, Pierre Thibault > > wrote:
>>
>> I gave it a try:
>>
>> (.. (class String) (getMethod "format" (into-array Class [String 
>> (Class/forName "[Ljava.lang.Object;")])))
>>
>> But I am unable to get the method. I gave up.
>>
>> Le mercredi 20 mai 2015 19:12:05 UTC-4, Pierre Thibault a écrit :
>>>
>>> Hi Laurens,
>>>
>>> My example was not very good. Here another one:
>>>
>>> (.format (first '(String)) "%s" "foo")
>>>
>>> Imagine String is obtained dynamically. I guess then I have to use Java 
>>> reflection to do a dynamic invocation. I guess I am confused because 
>>> classes in Java are not objects.
>>>
>>> Le mercredi 20 mai 2015 18:40:13 UTC-4, Laurens Van Houtven a écrit :

 Hi Pierre,

 On May 20, 2015, at 3:38 PM, Pierre Thibault  
 wrote:

 I can do Math/PI put how can I access PI if Math is in a expression 
 like '(Math) for example?


 Can you provide a more specific example? Math/PI is always Math/PI, it 
 doesn’t change if you put it in a nested form/expression.

 hth
 lvh

 -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.



>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups

Re: One more argument for cyclic dependencies

2015-05-20 Thread Mars0i
Thanks Justin.  Exploring the options now, at least for the Student class, 
which only has to implement an interface.  Given the requirements of the 
standard ways of using the MASON libs, it initially seemed to me that 
gen-class was my only option.  It's clear now that there are other 
possibilities.  Among other things, I didn't realize that interfaces could 
be used without gen-class.  Sorting out what works, how to make the result 
as efficient as the gen-class version, etc. may take some time.

(I think we really need a book focused solely on Clojure-Java 
interoperability.  It's a big topic, with lots of options, pitfalls, poorly 
documented elements, etc.  I would almost say that about gen-class alone.  
I don't know that there's enough of a market for such a book that anyone 
will bother writing, it, though.)

On Wednesday, May 20, 2015 at 10:24:02 AM UTC-5, Justin Smith wrote:
>
> I'll second the recommendation to use protocols or interfaces to solve 
> this.
>
> Clojure is fairly opinionated in that the tools available should push you 
> toward developing against interfaces or protocols rather than concrete 
> implementations. Things become much simpler when you accept this. You can 
> even have a single file that defines all the protocols you might need, and 
> each of your classes can implement one or more protocols, while defining 
> methods or fields that use other protocols with no circularity needed.
>
> On Tuesday, May 19, 2015 at 8:57:19 AM UTC-7, Mars0i wrote:
>>
>> Gary wrote: 
>>
>> * I was under the impression that Clojure only restricted cyclic 
>> dependencies between ns forms. Have you tried calling 
>> import/require/gen-class directly? 
>>
>> Not much.  I did try one trick that involved switching namespaces inside 
>> a file, but it didn't work. I can try other things.
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using @ alone

2015-05-20 Thread Adam Morgan
Hi Pierre, 

If I understand you correctly, you are attempting to crack open a sequence, 
as ~@ would do in a macro.  You are probably looking for apply.

For example:

(apply + '(1 2 3))
6


On Wednesday, May 20, 2015 at 6:07:13 PM UTC-6, Pierre Thibault wrote:
>
> No:
>
> (type '())
> clojure.lang.PersistentList$EmptyList
>
> It a list just like it should be.
>
> Le mercredi 20 mai 2015 20:02:22 UTC-4, Colin Yates a écrit :
>>
>> That's OK, I am also confused between '() which is a literal list and #{} 
>> which is a literal set :).
>> On 21 May 2015 00:55, "Pierre Thibault"  wrote:
>>
>>> OK,
>>>
>>> I don't know how to write macros yet. I was confused.
>>>
>>> Thank you.
>>>
>>> Le mercredi 20 mai 2015 18:48:03 UTC-4, Colin Yates a écrit :

 @ (and deref) are used to dereference constructs which support multiple 
 values over time; atoms, futures and promises etc. ~@ is a different thing 
 entirely and is used to desplice lists in a macro.

 In your example, you aren't in a macro and '() is defining a set, I.e. 
 it isn't a temperal construct.
 On 20 May 2015 23:43, "Pierre Thibault"  wrote:

> For example:
>
> (def foo '(1 2 3))
> (+ @foo)
>
> Does not work. I am expecting 6.
>
> Le mercredi 20 mai 2015 18:37:05 UTC-4, Colin Yates a écrit :
>>
>> @my-atom is the same as (deref my-atom), is that what you mean?
>> On 20 May 2015 23:35, "Pierre Thibault"  
>> wrote:
>>
>>> Is possible to use the operator '@' alone? In the Joy Of Clojure 
>>> book it is presented as '~@'. I would like an example.
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient 
>>> with your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, 
>>> send an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient 
> with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google 
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
  -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with 
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why isn't definterface in the cheatsheet?

2015-05-20 Thread Mars0i
Is there any reason why definterface is missing from the Clojure 1.6 
documentation cheatsheets?  The same is true of the "other versions with 
tooltips".

Nothing I've read suggests that definterface is deprecated.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing static fields

2015-05-20 Thread Andy Fingerhut
Java interop _with method names known at compile time_ is pretty simple,
and is the most common case I have seen.

Why do you think it is supposed to be simple to select Java methods based
upon the values of variables at run time?

Andy

On Wed, May 20, 2015 at 7:31 PM, Pierre Thibault  wrote:

> This is working well. It is pretty complex to do something that is suppose
> to be simple. I am not yet able to understand this code. I find Clojure
> hard to learn.
>
> Thank you Keith.
>
> Le mercredi 20 mai 2015 21:36:02 UTC-4, Keith Irwin a écrit :
>>
>> What about eval?
>>
>> user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s"
>> (to-array ["adasd"])))
>> “adasd"
>>
>> I have a function form:
>>
>> (defn static-invoke
>>   [c meth & args]
>>   (eval `(. ~(resolve (symbol c)) ~(symbol meth) ~@args)))
>>
>> Which works for some things:
>>
>> user => (static-invoke “System” “currentTimeMillis”)
>> 1432171781154
>>
>> But the String thing was problematic:
>>
>> user => (static-invoke "String" "format" "a %s” (quote (to-array
>> ["foo”])))
>> “a foo”
>>
>> (This gave a weird error until I quoted the to-array form.)
>>
>> Still not helpful?
>>
>>
>> On May 20, 2015, at 6:09 PM, Ambrose Bonnaire-Sergeant <
>> abonnair...@gmail.com> wrote:
>>
>> Macros won't work because they are expanded at compile-time. We want to
>> choose the method at runtime.
>>
>> Thanks,
>> Ambrose
>>
>> On Thu, May 21, 2015 at 9:02 AM, Keith Irwin  wrote:
>>
>>> Not sure if this helps, but:
>>>
>>> user => (eval (symbol "Math" "PI”))
>>> 3.141592653589793
>>>
>>> user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s"
>>> (to-array ["adasd"])))
>>> “adasd"
>>>
>>> Maybe a macro of some sort?
>>>
>>> (defmacro invoke-static
>>>   [c meth & args]
>>>   `(. ~(resolve (symbol c)) ~(symbol meth) ~@args))
>>>
>>> user => (invoke-static "java.lang.String" "format" "the %s" (to-array
>>> ["foo"]))
>>> “the foo"
>>>
>>> user=> (invoke-static "System" "currentTimeMillis")
>>> 1432170076378
>>>
>>> That kind of thing?
>>>
>>> On May 20, 2015, at 4:54 PM, Pierre Thibault 
>>> wrote:
>>>
>>> I gave it a try:
>>>
>>> (.. (class String) (getMethod "format" (into-array Class [String
>>> (Class/forName "[Ljava.lang.Object;")])))
>>>
>>> But I am unable to get the method. I gave up.
>>>
>>> Le mercredi 20 mai 2015 19:12:05 UTC-4, Pierre Thibault a écrit :

 Hi Laurens,

 My example was not very good. Here another one:

 (.format (first '(String)) "%s" "foo")

 Imagine String is obtained dynamically. I guess then I have to use Java
 reflection to do a dynamic invocation. I guess I am confused because
 classes in Java are not objects.

 Le mercredi 20 mai 2015 18:40:13 UTC-4, Laurens Van Houtven a écrit :
>
> Hi Pierre,
>
> On May 20, 2015, at 3:38 PM, Pierre Thibault 
> wrote:
>
> I can do Math/PI put how can I access PI if Math is in a expression
> like '(Math) for example?
>
>
> Can you provide a more specific example? Math/PI is always Math/PI, it
> doesn’t change if you put it in a nested form/expression.
>
> hth
> lvh
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient
> with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from

Re: Why isn't definterface in the cheatsheet?

2015-05-20 Thread Andy Fingerhut
The cheat sheet doesn't include everything.  Most things in Clojure, yes,
but not all.  Looking at the log of the last time I generated the latest
version of the cheat sheet, it does not include the 172 Vars listed below.

You can file an issue if there are any you think especially ought to be
added: https://github.com/jafingerhut/clojure-cheatsheets/issues

Andy


*allow-unresolved-vars*
*assert*
*compiler-options*
*flush-on-newline*
*fn-loader*
*math-context*
*read-eval*
*source-path*
*use-context-classloader*
*verbose-defrecords*
->ArrayChunk
->Vec
->VecNode
->VecSeq
-cache-protocol-fn
-reset-methods
EMPTY-NODE
accessor
add-classpath
agent-errors
await1
chunk
chunk-append
chunk-buffer
chunk-cons
chunk-first
chunk-next
chunk-rest
chunked-seq?
clear-agent-errors
clojure.core.reducers/->Cat
clojure.core.reducers/CollFold
clojure.core.reducers/append!
clojure.core.reducers/cat
clojure.core.reducers/coll-fold
clojure.core.reducers/drop
clojure.core.reducers/filter
clojure.core.reducers/fjtask
clojure.core.reducers/flatten
clojure.core.reducers/fold
clojure.core.reducers/foldcat
clojure.core.reducers/folder
clojure.core.reducers/map
clojure.core.reducers/mapcat
clojure.core.reducers/monoid
clojure.core.reducers/pool
clojure.core.reducers/reduce
clojure.core.reducers/reducer
clojure.core.reducers/remove
clojure.core.reducers/take
clojure.core.reducers/take-while
clojure.data/Diff
clojure.data/EqualityPartition
clojure.data/diff-similar
clojure.data/equality-partition
clojure.java.browse/*open-url-script*
clojure.java.io/Coercions
clojure.java.io/IOFactory
clojure.java.io/default-streams-impl
clojure.java.io/make-input-stream
clojure.java.io/make-output-stream
clojure.java.io/make-parents
clojure.java.io/make-reader
clojure.java.io/make-writer
clojure.java.javadoc/*core-java-api*
clojure.java.javadoc/*feeling-lucky*
clojure.java.javadoc/*feeling-lucky-url*
clojure.java.javadoc/*local-javadocs*
clojure.java.javadoc/*remote-javadocs*
clojure.java.javadoc/add-local-javadoc
clojure.java.javadoc/add-remote-javadoc
clojure.java.shell/*sh-dir*
clojure.java.shell/*sh-env*
clojure.pprint/*print-base*
clojure.pprint/*print-miser-width*
clojure.pprint/*print-pprint-dispatch*
clojure.pprint/*print-pretty*
clojure.pprint/*print-radix*
clojure.pprint/*print-right-margin*
clojure.pprint/*print-suppress-namespaces*
clojure.pprint/code-dispatch
clojure.pprint/formatter
clojure.pprint/formatter-out
clojure.pprint/fresh-line
clojure.pprint/get-pretty-writer
clojure.pprint/pp
clojure.pprint/pprint-indent
clojure.pprint/pprint-logical-block
clojure.pprint/pprint-newline
clojure.pprint/pprint-tab
clojure.pprint/print-length-loop
clojure.pprint/set-pprint-dispatch
clojure.pprint/simple-dispatch
clojure.pprint/with-pprint-dispatch
clojure.pprint/write
clojure.pprint/write-out
clojure.repl/demunge
clojure.repl/dir
clojure.repl/dir-fn
clojure.repl/root-cause
clojure.repl/set-break-handler!
clojure.repl/source-fn
clojure.repl/stack-element-str
clojure.repl/thread-stopper
clojure.walk/keywordize-keys
clojure.walk/stringify-keys
clojure.xml/*current*
clojure.xml/*sb*
clojure.xml/*stack*
clojure.xml/*state*
clojure.xml/attrs
clojure.xml/content
clojure.xml/content-handler
clojure.xml/element
clojure.xml/emit
clojure.xml/emit-element
clojure.xml/startparse-sax
clojure.xml/tag
create-struct
definterface
defstruct
delay?
denominator
destructure
find-protocol-impl
find-protocol-method
hash-combine
hash-ordered-coll
hash-unordered-coll
method-sig
mix-collection-hash
munge
namespace-munge
numerator
primitives-classnames
print-ctor
print-dup
print-method
print-simple
proxy-call-with-super
proxy-name
read
read-string
reduced
reduced?
refer-clojure
replicate
sequence
special-symbol?
struct
struct-map
unchecked-add-int
unchecked-byte
unchecked-char
unchecked-dec-int
unchecked-divide-int
unchecked-double
unchecked-float
unchecked-inc-int
unchecked-int
unchecked-long
unchecked-multiply-int
unchecked-negate-int
unchecked-remainder-int
unchecked-short
unchecked-subtract-int
underive
unquote
unquote-splicing
with-bindings
with-bindings*
with-loading-context


On Wed, May 20, 2015 at 8:15 PM, Mars0i  wrote:

> Is there any reason why definterface is missing from the Clojure 1.6
> documentation cheatsheets?  The same is true of the "other versions with
> tooltips".
>
> Nothing I've read suggests that definterface is deprecated.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@

Re: Why isn't definterface in the cheatsheet?

2015-05-20 Thread Mars0i
Ah, OK, thanks.  I probably depend too mcuh on the cheatsheets.  But I'll 
go ahead and file an issue for definterface; I think it should be there as 
an alternative to gen-interface.

On Wednesday, May 20, 2015 at 10:24:16 PM UTC-5, Andy Fingerhut wrote:
>
> The cheat sheet doesn't include everything.  Most things in Clojure, yes, 
> but not all.  Looking at the log of the last time I generated the latest 
> version of the cheat sheet, it does not include the 172 Vars listed below.
>
> You can file an issue if there are any you think especially ought to be 
> added: https://github.com/jafingerhut/clojure-cheatsheets/issues
>
> Andy
>
>
> *allow-unresolved-vars*
> *assert*
> *compiler-options*
> *flush-on-newline*
> *fn-loader*
> *math-context*
> *read-eval*
> *source-path*
> *use-context-classloader*
> *verbose-defrecords*
> ->ArrayChunk
> ->Vec
> ->VecNode
> ->VecSeq
> -cache-protocol-fn
> -reset-methods
> EMPTY-NODE
> accessor
> add-classpath
> agent-errors
> await1
> chunk
> chunk-append
> chunk-buffer
> chunk-cons
> chunk-first
> chunk-next
> chunk-rest
> chunked-seq?
> clear-agent-errors
> clojure.core.reducers/->Cat
> clojure.core.reducers/CollFold
> clojure.core.reducers/append!
> clojure.core.reducers/cat
> clojure.core.reducers/coll-fold
> clojure.core.reducers/drop
> clojure.core.reducers/filter
> clojure.core.reducers/fjtask
> clojure.core.reducers/flatten
> clojure.core.reducers/fold
> clojure.core.reducers/foldcat
> clojure.core.reducers/folder
> clojure.core.reducers/map
> clojure.core.reducers/mapcat
> clojure.core.reducers/monoid
> clojure.core.reducers/pool
> clojure.core.reducers/reduce
> clojure.core.reducers/reducer
> clojure.core.reducers/remove
> clojure.core.reducers/take
> clojure.core.reducers/take-while
> clojure.data/Diff
> clojure.data/EqualityPartition
> clojure.data/diff-similar
> clojure.data/equality-partition
> clojure.java.browse/*open-url-script*
> clojure.java.io/Coercions
> clojure.java.io/IOFactory
> clojure.java.io/default-streams-impl
> clojure.java.io/make-input-stream
> clojure.java.io/make-output-stream
> clojure.java.io/make-parents
> clojure.java.io/make-reader
> clojure.java.io/make-writer
> clojure.java.javadoc/*core-java-api*
> clojure.java.javadoc/*feeling-lucky*
> clojure.java.javadoc/*feeling-lucky-url*
> clojure.java.javadoc/*local-javadocs*
> clojure.java.javadoc/*remote-javadocs*
> clojure.java.javadoc/add-local-javadoc
> clojure.java.javadoc/add-remote-javadoc
> clojure.java.shell/*sh-dir*
> clojure.java.shell/*sh-env*
> clojure.pprint/*print-base*
> clojure.pprint/*print-miser-width*
> clojure.pprint/*print-pprint-dispatch*
> clojure.pprint/*print-pretty*
> clojure.pprint/*print-radix*
> clojure.pprint/*print-right-margin*
> clojure.pprint/*print-suppress-namespaces*
> clojure.pprint/code-dispatch
> clojure.pprint/formatter
> clojure.pprint/formatter-out
> clojure.pprint/fresh-line
> clojure.pprint/get-pretty-writer
> clojure.pprint/pp
> clojure.pprint/pprint-indent
> clojure.pprint/pprint-logical-block
> clojure.pprint/pprint-newline
> clojure.pprint/pprint-tab
> clojure.pprint/print-length-loop
> clojure.pprint/set-pprint-dispatch
> clojure.pprint/simple-dispatch
> clojure.pprint/with-pprint-dispatch
> clojure.pprint/write
> clojure.pprint/write-out
> clojure.repl/demunge
> clojure.repl/dir
> clojure.repl/dir-fn
> clojure.repl/root-cause
> clojure.repl/set-break-handler!
> clojure.repl/source-fn
> clojure.repl/stack-element-str
> clojure.repl/thread-stopper
> clojure.walk/keywordize-keys
> clojure.walk/stringify-keys
> clojure.xml/*current*
> clojure.xml/*sb*
> clojure.xml/*stack*
> clojure.xml/*state*
> clojure.xml/attrs
> clojure.xml/content
> clojure.xml/content-handler
> clojure.xml/element
> clojure.xml/emit
> clojure.xml/emit-element
> clojure.xml/startparse-sax
> clojure.xml/tag
> create-struct
> definterface
> defstruct
> delay?
> denominator
> destructure
> find-protocol-impl
> find-protocol-method
> hash-combine
> hash-ordered-coll
> hash-unordered-coll
> method-sig
> mix-collection-hash
> munge
> namespace-munge
> numerator
> primitives-classnames
> print-ctor
> print-dup
> print-method
> print-simple
> proxy-call-with-super
> proxy-name
> read
> read-string
> reduced
> reduced?
> refer-clojure
> replicate
> sequence
> special-symbol?
> struct
> struct-map
> unchecked-add-int
> unchecked-byte
> unchecked-char
> unchecked-dec-int
> unchecked-divide-int
> unchecked-double
> unchecked-float
> unchecked-inc-int
> unchecked-int
> unchecked-long
> unchecked-multiply-int
> unchecked-negate-int
> unchecked-remainder-int
> unchecked-short
> unchecked-subtract-int
> underive
> unquote
> unquote-splicing
> with-bindings
> with-bindings*
> with-loading-context
>
>
> On Wed, May 20, 2015 at 8:15 PM, Mars0i 
> > wrote:
>
>> Is there any reason why definterface is missing from the Clojure 1.6 
>> documentation cheatsheets?  The same is true of the "other versions with 
>> tooltips".
>>
>> Nothing I've read suggests that definterface is deprecated.
>>
>

Re: Using @ alone

2015-05-20 Thread Pierre Thibault
Hi Adam,

I want to play to learn Clojure. It is not so much with a purpose in mind.

Yes, apply works well.

Le mercredi 20 mai 2015 23:14:43 UTC-4, Adam Morgan a écrit :
>
> Hi Pierre, 
>
> If I understand you correctly, you are attempting to crack open a 
> sequence, as ~@ would do in a macro.  You are probably looking for apply.
>
> For example:
>
> (apply + '(1 2 3))
> 6
>
>
> On Wednesday, May 20, 2015 at 6:07:13 PM UTC-6, Pierre Thibault wrote:
>>
>> No:
>>
>> (type '())
>> clojure.lang.PersistentList$EmptyList
>>
>> It a list just like it should be.
>>
>> Le mercredi 20 mai 2015 20:02:22 UTC-4, Colin Yates a écrit :
>>>
>>> That's OK, I am also confused between '() which is a literal list and 
>>> #{} which is a literal set :).
>>> On 21 May 2015 00:55, "Pierre Thibault"  wrote:
>>>
 OK,

 I don't know how to write macros yet. I was confused.

 Thank you.

 Le mercredi 20 mai 2015 18:48:03 UTC-4, Colin Yates a écrit :
>
> @ (and deref) are used to dereference constructs which support 
> multiple values over time; atoms, futures and promises etc. ~@ is a 
> different thing entirely and is used to desplice lists in a macro.
>
> In your example, you aren't in a macro and '() is defining a set, I.e. 
> it isn't a temperal construct.
> On 20 May 2015 23:43, "Pierre Thibault"  wrote:
>
>> For example:
>>
>> (def foo '(1 2 3))
>> (+ @foo)
>>
>> Does not work. I am expecting 6.
>>
>> Le mercredi 20 mai 2015 18:37:05 UTC-4, Colin Yates a écrit :
>>>
>>> @my-atom is the same as (deref my-atom), is that what you mean?
>>> On 20 May 2015 23:35, "Pierre Thibault"  
>>> wrote:
>>>
 Is possible to use the operator '@' alone? In the Joy Of Clojure 
 book it is presented as '~@'. I would like an example.

 -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from new members are moderated - please be patient 
 with your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from it, 
 send an email to clojure+u...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient 
>> with your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google 
>> Groups "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to clojure+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>  -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing static fields

2015-05-20 Thread Pierre Thibault
I love to program in Python and when you want do something in Python it is 
usually easy. This makes your imagination powerful. Sad to see it is not 
the same in Java.

Le mercredi 20 mai 2015 23:17:56 UTC-4, Andy Fingerhut a écrit :
>
> Java interop _with method names known at compile time_ is pretty simple, 
> and is the most common case I have seen.
>
> Why do you think it is supposed to be simple to select Java methods based 
> upon the values of variables at run time?
>
> Andy
>
> On Wed, May 20, 2015 at 7:31 PM, Pierre Thibault  > wrote:
>
>> This is working well. It is pretty complex to do something that is 
>> suppose to be simple. I am not yet able to understand this code. I find 
>> Clojure hard to learn.
>>
>> Thank you Keith.
>>
>> Le mercredi 20 mai 2015 21:36:02 UTC-4, Keith Irwin a écrit :
>>>
>>> What about eval?
>>>
>>> user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s" 
>>> (to-array ["adasd"])))
>>> “adasd"
>>>
>>> I have a function form:
>>>
>>> (defn static-invoke
>>>   [c meth & args]
>>>   (eval `(. ~(resolve (symbol c)) ~(symbol meth) ~@args)))
>>>
>>> Which works for some things:
>>>
>>> user => (static-invoke “System” “currentTimeMillis”)
>>> 1432171781154
>>>
>>> But the String thing was problematic:
>>>
>>> user => (static-invoke "String" "format" "a %s” (quote (to-array 
>>> ["foo”])))
>>> “a foo”
>>>
>>> (This gave a weird error until I quoted the to-array form.)
>>>
>>> Still not helpful?
>>>
>>>
>>> On May 20, 2015, at 6:09 PM, Ambrose Bonnaire-Sergeant <
>>> abonnair...@gmail.com> wrote:
>>>
>>> Macros won't work because they are expanded at compile-time. We want to 
>>> choose the method at runtime.
>>>
>>> Thanks,
>>> Ambrose
>>>
>>> On Thu, May 21, 2015 at 9:02 AM, Keith Irwin  wrote:
>>>
 Not sure if this helps, but:

 user => (eval (symbol "Math" "PI”))
 3.141592653589793

 user =>  (eval `(. ~(resolve (symbol "String")) ~(symbol "format") "%s" 
 (to-array ["adasd"])))
 “adasd"

 Maybe a macro of some sort?

 (defmacro invoke-static
   [c meth & args]
   `(. ~(resolve (symbol c)) ~(symbol meth) ~@args))

 user => (invoke-static "java.lang.String" "format" "the %s" (to-array 
 ["foo"]))
 “the foo"

 user=> (invoke-static "System" "currentTimeMillis")
 1432170076378

 That kind of thing?

 On May 20, 2015, at 4:54 PM, Pierre Thibault  
 wrote:

 I gave it a try:

 (.. (class String) (getMethod "format" (into-array Class [String 
 (Class/forName "[Ljava.lang.Object;")])))

 But I am unable to get the method. I gave up.

 Le mercredi 20 mai 2015 19:12:05 UTC-4, Pierre Thibault a écrit :
>
> Hi Laurens,
>
> My example was not very good. Here another one:
>
> (.format (first '(String)) "%s" "foo")
>
> Imagine String is obtained dynamically. I guess then I have to use 
> Java reflection to do a dynamic invocation. I guess I am confused because 
> classes in Java are not objects.
>
> Le mercredi 20 mai 2015 18:40:13 UTC-4, Laurens Van Houtven a écrit :
>>
>> Hi Pierre,
>>
>> On May 20, 2015, at 3:38 PM, Pierre Thibault  
>> wrote:
>>
>> I can do Math/PI put how can I access PI if Math is in a expression 
>> like '(Math) for example?
>>
>>
>> Can you provide a more specific example? Math/PI is always Math/PI, 
>> it doesn’t change if you put it in a nested form/expression.
>>
>> hth
>> lvh
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient 
>> with your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google 
>> Groups "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to clojure+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
 -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from i