Re: [core.spec] Stricter map validations?

2017-11-14 Thread Seth Verrinder
I took part of the goal to be that specs themselves would remain 
compatible, so an old set of specs wouldn't start failing on data that 
conforms to a new but compatible set of specs. That sort of compatibility 
isn't possible when you go from disallowing something to allowing it.

On Tuesday, November 14, 2017 at 10:15:23 AM UTC-6, Eric Normand wrote:
>
> Hey everybody!
>
> I'm chiming in after seeing this linked to in The Repl (
> https://therepl.net/).
>
> On Alex's suggestion, I rewatched Spec-ulation last night. The parts about 
> negation and evolution are towards the end. I was struck (once again) by 
> how clearly he picked apart changes. Relaxing a requirement is growth. And 
> adding requirements is breakage. But it left me with a question:
>
> Isn't disallowing a key and then allowing it (as optional) growth (instead 
> of breakage)? All of the old clients are still fine, and new clients can 
> use the key if they choose. You're relaxing the requirements. Taking the 
> opposite approach, I require some keys plus allow anything else. Some 
> clients will inevitably send me something with extra keys, which is okay, 
> they pass my specs. Later, I add in an optional key with a defined spec. So 
> I'm now restricting what used to be completely open. Isn't that breakage? I 
> feel like I'm seeing it exactly opposite as Rich Hickey. He says if you 
> disallow things, it's forever, because if you need to allow it later, 
> that's breakage. But there's not enough explanation for me to understand. 
> It seems like relaxing requirements. I feel like I'm missing something. In 
> short: why is it forever?
>
> He does mention is that logic engines don't have negation. Does this hint 
> that we will want to be using logic engines to reason over our specs?
>
> Thanks
> Eric
>

-- 
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 transducers in a new transducing context

2017-04-12 Thread Seth Verrinder
Reordering definitely matters:

StepA: write to x
StepB: read from x

StepB: read from x
StepA: write to x

On Wednesday, April 12, 2017 at 7:15:09 AM UTC-5, Léo Noel wrote:
>
> I could have one thread that invokes a transduce step on odd seconds and 
>> another that invokes on even seconds. Or some external api call that tells 
>> me to take the next step, which I do on a thread pulled from a pool.
>>
>
> Both strategies will fail to ensure no more than one thread at time. You 
> need something to prevent overlapping, e.g when a long step is running and 
> you get a request to start the next one.
>
>
> While this is a good reference, it's also 13 years old and the JMM has 
>> been updated since then. A much better reference explaining the semantics 
>> and constraints is:
>
> https://shipilev.net/blog/2014/jmm-pragmatics/ 
>
> In particular, even if there is a memory barrier, there are some 
>> reorderings allowed if the transducer state is not volatile that may be 
>> surprising. Making it volatile adds a critical edge in the total program 
>> order.
>
> I'm saying that the logical ordering of steps is irrelevant wrt how a 
>> multi-threaded program can be optimized/reordered under the JMM.
>
>
> Thank you for the reference. Very enlightening (esp. part III 
> ).
> I understand reordering is a thing. Does ordering really matter ? What 
> matters to us is that each step is able to see the changes made the step 
> before. That is, we need to ensure memory visibility across steps. This is 
> all what we need to be sure that the JVM won't run the program in an order 
> that doesn't yield the same result as what we expect.
> In a degenerate case, we'll put volatile on every variable, ensuring that 
> the running program is totally ordered and totally unoptimizable. Is this 
> what we want ?
>
>
> happens-before across threads requires a volatile or lock, but I don't see 
>> how the use of one is guaranteed by this logical ordering.
>>
>
> Volatiles and locks are means to an end. The end is memory visibility, and 
> the happens-before partial ordering is what is of interest to us, 
> application developers, to reason about this end. The happens-before rules 
> have not changed since jsr-133 (source 
> )
>  
> :
> * Each action in a thread happens-before every action in that thread that 
> comes later in the program's order.
> * An unlock (synchronized block or method exit) of a monitor 
> happens-before every subsequent lock (synchronized block or method entry) 
> of that same monitor. And because the happens-before relation is 
> transitive, all actions of a thread prior to unlocking happen-before all 
> actions subsequent to any thread locking that monitor.
> * A write to a volatile field happens-before every subsequent read of that 
> same field. Writes and reads of volatile fields have similar memory 
> consistency effects as entering and exiting monitors, but do not entail 
> mutual exclusion locking.
> * A call to start on a thread happens-before any action in the started 
> thread.
> * All actions in a thread happen-before any other thread successfully 
> returns from a join on that thread.
>
> Here is an example of a multithreaded transducing context that doesn't use 
> locks nor volatiles (inspired from the official documentation for agents 
> ) :
>
> (def xf (comp (partition-all 64) cat))
>
> (defn ! [f & args] (apply f args) f)
>
> (defn run [m n]
>   (let [p (promise)
> f (reduce (fn [f _] (partial send (agent f) (xf !)))
>   #(when (zero? %) (deliver p nil)) (range m))]
> (doseq [i (reverse (range n))] (f i))
> (f)
> @p))
>
> (run 1000 1000)
>
>
> The unsynchronized ArrayList in partition-all will be accessed by multiple 
> threads, and I can still be confident about visibility, because agents 
> ensure a happens-before ordering between each message. This behaviour is 
> actually delegated to the backing Executor, which may or may not use locks. 
> Locks are really an implementation detail, what is important is 
> happens-before guarantees.
>
>
> Seems risky to depend on that. eduction creates an iterable for example - 
>> it has no way of preventing somebody from creating the iterator on one 
>> thread and consuming it on another. 
>>
>
> Iterators are unsynchronized and mutable, like many classes in the Java 
> standard library. You know they're unsafe and need to treat them as such. 
> This leads to a more general debate on mutability. Objects generally fall 
> in 3 categories :
> 1. Immutable objects aka values. They're the default in Clojure and that's 
> great because they can be exposed safely and they're so easy to reason 
> about.
> 2. Thread-safe mutable objects. Includes core reference types, core.async 
> channels. They're useful to model identity

Re: Using transducers in a new transducing context

2017-04-11 Thread Seth Verrinder
Seems risky to depend on that. eduction creates an iterable for
example - it has no way of preventing somebody from creating the
iterator on one thread and consuming it on another.

On Tue, Apr 11, 2017 at 7:32 AM, Léo Noel  wrote:
>> volatile! is what ensures that there's a memory barrier.
>
>
> No. The memory barrier is set by the transducing context as a consequence of
> implementing the "single thread at a time" rule. Be it lock, thread
> isolation, agent isolation, or anything that ensures that the end of a step
> happens-before the beginning of the next. All these techniques ensure
> visibility of unsynchronized variables between two successive steps, even
> when multiple threads are involved.
>
>
> On Tuesday, April 11, 2017 at 1:36:30 PM UTC+2, Seth Verrinder wrote:
>>
>> The single thread at a time rule is implemented by the transducing
>> context (transduce, into, core.async, etc). Inside of a transducer's
>> implementation you just have to make the assumption that it's being
>> used properly. volatile! is what ensures that there's a memory
>> barrier.
>>
>> On Tue, Apr 11, 2017 at 2:46 AM, Léo Noel  wrote:
>> > Thank you Alex for these precisions.
>> >
>> >
>> >> The JVM is pretty good at minimizing this stuff - so while you are
>> >> stating
>> >> these barriers are redundant and are implying that's an issue, it would
>> >> not
>> >> surprise me if the JVM is able to reduce or eliminate the impacts of
>> >> that.
>> >> At the very least, it's too difficult to reason about without a real
>> >> perf
>> >> test and numbers.
>> >
>> >
>> >> Fast wrong results are still wrong. I do not think it's at all obvious
>> >> how
>> >> this affects performance without running some benchmarks. Volatiles do
>> >> not
>> >> require flushing values to all cores or anything like that. They just
>> >> define
>> >> constraints - the JVM is very good at optimizing these kinds of things.
>> >> It
>> >> would not surprise me if an uncontended thread-contained volatile could
>> >> be
>> >> very fast (for the single-threaded transducer case) or that a volatile
>> >> under
>> >> a lock would be no worse than the lock by itself.
>> >
>> >
>> > I agree that the perf argument is weak.
>> >
>> >
>> >> A transducer can assume it will be invoked by no more than one thread
>> >> at a
>> >> time
>> >
>> >
>> > Fine. Even simpler like this.
>> >
>> >
>> >> Transducers should ensure stateful changes guarantee visibility. That
>> >> is:
>> >> you should not make assumptions about external memory barriers.
>> >
>> >
>> > How do you enforce no more than one thread at a time without setting a
>> > memory barrier ?
>> > For the JMM, no more than one thread at a time means exactly that return
>> > of
>> > step n will *happen-before* the call to step n+1.
>> > This implies that what was visible to the thread performing step n will
>> > be
>> > visible to the thread performing the step n+1, including all memory
>> > writes
>> > performed during step n inside stateful transducers.
>> > https://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html
>> > Still no need for extra synchronization.
>> >
>> >
>> >> You're conflating the stateful values inside the transducer with the
>> >> state
>> >> returned by and passed into a transducer. That's a linkage that does
>> >> not
>> >> necessarily exist.
>> >
>> >
>> > What do you mean ? How could a function return a value without having
>> > executed its body ?
>> >
>> >
>> > On Monday, April 10, 2017 at 9:51:30 PM UTC+2, Alexander Gunnarson
>> > wrote:
>> >>
>> >> Thanks for clearing all of that up Alex! Very helpful.
>> >>
>> >> On Monday, April 10, 2017 at 3:46:45 PM UTC-4, Alex Miller wrote:
>> >>>
>> >>>
>> >>>
>> >>> On Monday, April 10, 2017 at 2:25:48 PM UTC-5, Alexander Gunnarson
>> >>> wrote:
>> >>>>
>> >>>> I think you present a key question: what assumptions can a transducer
>> >>>> make? We know the standard ones, but what of memory bar

Re: Using transducers in a new transducing context

2017-04-11 Thread Seth Verrinder
The single thread at a time rule is implemented by the transducing
context (transduce, into, core.async, etc). Inside of a transducer's
implementation you just have to make the assumption that it's being
used properly. volatile! is what ensures that there's a memory
barrier.

On Tue, Apr 11, 2017 at 2:46 AM, Léo Noel  wrote:
> Thank you Alex for these precisions.
>
>
>> The JVM is pretty good at minimizing this stuff - so while you are stating
>> these barriers are redundant and are implying that's an issue, it would not
>> surprise me if the JVM is able to reduce or eliminate the impacts of that.
>> At the very least, it's too difficult to reason about without a real perf
>> test and numbers.
>
>
>> Fast wrong results are still wrong. I do not think it's at all obvious how
>> this affects performance without running some benchmarks. Volatiles do not
>> require flushing values to all cores or anything like that. They just define
>> constraints - the JVM is very good at optimizing these kinds of things. It
>> would not surprise me if an uncontended thread-contained volatile could be
>> very fast (for the single-threaded transducer case) or that a volatile under
>> a lock would be no worse than the lock by itself.
>
>
> I agree that the perf argument is weak.
>
>
>> A transducer can assume it will be invoked by no more than one thread at a
>> time
>
>
> Fine. Even simpler like this.
>
>
>> Transducers should ensure stateful changes guarantee visibility. That is:
>> you should not make assumptions about external memory barriers.
>
>
> How do you enforce no more than one thread at a time without setting a
> memory barrier ?
> For the JMM, no more than one thread at a time means exactly that return of
> step n will *happen-before* the call to step n+1.
> This implies that what was visible to the thread performing step n will be
> visible to the thread performing the step n+1, including all memory writes
> performed during step n inside stateful transducers.
> https://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html
> Still no need for extra synchronization.
>
>
>> You're conflating the stateful values inside the transducer with the state
>> returned by and passed into a transducer. That's a linkage that does not
>> necessarily exist.
>
>
> What do you mean ? How could a function return a value without having
> executed its body ?
>
>
> On Monday, April 10, 2017 at 9:51:30 PM UTC+2, Alexander Gunnarson wrote:
>>
>> Thanks for clearing all of that up Alex! Very helpful.
>>
>> On Monday, April 10, 2017 at 3:46:45 PM UTC-4, Alex Miller wrote:
>>>
>>>
>>>
>>> On Monday, April 10, 2017 at 2:25:48 PM UTC-5, Alexander Gunnarson wrote:

 I think you present a key question: what assumptions can a transducer
 make? We know the standard ones, but what of memory barriers?
>>>
>>>
>>> Transducers should ensure stateful changes guarantee visibility. That is:
>>> you should not make assumptions about external memory barriers.
>>>

 Based on the current implementation, in terms of concurrency, it seems
 to make (inconsistent — see also `partition-by`) guarantees that sequential
 writes and reads will be consistent, no matter what thread does the reads 
 or
 writes. Concurrent writes are not supported. But should sequential
 multi-threaded reads/writes be supported?
>>>
>>>
>>> Yes. core.async channel transducers already do this.
>>>

 This is a question best left to Alex but I think I already know the
 answer based on his conversation with Rich: it's part of the contract.

 I think another key question is, is the channel lock memory barrier part
 of the contract of a core.async channel implementation?
>>>
>>>
>>> Yes, but other transducing processes may exist either in core in the
>>> future or in external libs.
>>>

 If not, volatiles will be necessary in that context if the memory
 barrier is ever taken away, and it would make sense that volatiles are used
 in transducers "just in case" specifically for that use case. But if the
 channel lock memory barrier is part of the contract and not just an
 implementation detail, then I'm not certain that it's very useful at all 
 for
 transducers to provide a guarantee of safe sequential multi-threaded
 reads/writes.
>
> --
> 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/VQj0E9TJWYY/unsubscribe.
> To unsubscribe from 

Re: Using transducers in a new transducing context

2017-04-10 Thread Seth Verrinder
The problem is at a lower level. The memory model of the JVM doesn't
guarantee that changes to an unsynchronized non-volatile reference are
visible to other threads. Transducers don't have to worry about
concurrency but they do have to worry about visibility of changes
across different threads.

On Mon, Apr 10, 2017 at 8:37 AM, Léo Noel  wrote:
> This topic is of high interest to me as it is at the core of my current
> works. I had a similar questioning a while ago and I have to say I'm even
> more confused with this :
>
>> While transducing processes may provide locking to cover the visibility of
>> state updates in a stateful transducer, transducers should still use
>> stateful constructs that ensure visibility (by using volatile, atoms, etc).
>
>
> I actually tried pretty hard to find a use case that would make
> partition-all fail because of its unsynchronized local state, and did not
> manage to find one that did not break any contract. I arrived at the
> conclusion that it is always safe to use unsynchronized constructs in
> stateful transducers. The reason is that you need to ensure that the result
> of each step is given to the next, and doing so you will necessarily set a
> memory barrier of some sort between each step. Each step happens-before the
> next, and therefore mutations performed by the thread at step n are always
> visible by the thread performing the step n+1. This is really brilliant :
> when designing a transducer, you can be confident that calls to your
> reducing function will be sequential and stop worrying about concurrency.
> You just have to ensure that mutable state stays local. True encapsulation,
> the broken promise of object-oriented programming.
>
> My point is that the transducer contract "always feed the result of step n
> as the first argument of step n+1" is strong enough to safely use local
> unsynchronized state. For this reason, switching partition-* transducers to
> volatile constructs really sounds like a step backwards to me. However,
> after re-reading the documentation on transducers, I found that this
> contract is not explicitly stated. It is just *natural* to think this way,
> because transducers are all about reducing processes. Is there a plan to
> reconsider this principle ? I would be very interested to know what Rich has
> in mind that could lead him to advise to overprotect local state of
> transducers.
>
>
>
> On Monday, April 10, 2017 at 4:44:00 AM UTC+2, Alexander Gunnarson wrote:
>>
>> Thanks so much for your input Alex! It was a very helpful confirmation of
>> the key conclusions arrived at in this thread, and I appreciate the
>> additional elaborations you gave, especially the insight you passed on about
>> the stateful transducers using `ArrayList`. I'm glad that I wasn't the only
>> one wondering about the apparent lack of parity between its unsynchronized
>> mutability and the volatile boxes used for e.g. `map-indexed` and others.
>>
>> As an aside about the stateful `take` transducer, Tesser uses the
>> equivalent of one but skirts the issue by not guaranteeing that the first n
>> items of the collection will be returned, but rather, n items of the
>> collection in no particular order and starting at no particular index. This
>> is achievable without Tesser by simply replacing the `volatile` in the
>> `core/take` transducer with an `atom` and using it with `fold`. But yes,
>> `take`'s contract is broken with this and so still follows the rule of thumb
>> you established that `fold` can't use stateful transducers (at least, not
>> without weird things like reordering of the indices in `map-indexed` and so
>> on).
>>
>> That's interesting that `fold` can use transducers directly! I haven't
>> tried that yet — I've just been wrapping them in an `r/folder`.
>>
>> On Sunday, April 9, 2017 at 10:22:13 PM UTC-4, Alex Miller wrote:
>>>
>>> Hey all, just catching up on this thread after the weekend. Rich and I
>>> discussed the thread safety aspects of transducers last fall and the
>>> intention is that transducers are expected to only be used in a single
>>> thread at a time, but that thread can change throughout the life of the
>>> transducing process (for example when a go block is passed over threads in a
>>> pool in core.async). While transducing processes may provide locking to
>>> cover the visibility of state updates in a stateful transducer, transducers
>>> should still use stateful constructs that ensure visibility (by using
>>> volatile, atoms, etc).
>>>
>>> The major transducing processes provided in core are transduce, into,
>>> sequence, eduction, and core.async. All but core.async are single-threaded.
>>> core.async channel transducers may occur on many threads due to interaction
>>> with the go processing threads, but never happen on more than one thread at
>>> a time. These operations are covered by the channel lock which should
>>> guarantee visibility. Transducers used within a go block (via something like
>>> transduce or into) oc

Re: Using transducers in a new transducing context

2017-04-09 Thread Seth Verrinder
I'll defer to Timothy on the particulars of core.async but it looks like 
[1] the transducer in channel is protected by a lock. If that's the case 
volatile isn't adding anything in terms memory barriers.

1: 
https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/channels.clj#L71

On Sunday, April 9, 2017 at 11:58:00 AM UTC-5, Alexander Gunnarson wrote:
>
> Thanks so much for your well-considered reply, Timothy! That makes sense 
> about volatiles being used in e.g. core.async or core.reducers contexts 
> where the reducing function that closes over the mutable value of the 
> stateful transducer is called in different threads. Why, then, are 
> unsynchronized ArrayLists used e.g. in 'partition-by'? It's also closed 
> over by the reducing function in just the same way as the volatile long 
> value internal to e.g. 'map-indexed'. I'm not yet clear on how one (the 
> ArrayList) is acceptable being non-volatile and the other (the volatile 
> long) is unacceptable. When .add is called, an unsynchronized mutable 
> counter is updated so the ArrayList can insert the next value at the 
> correct index. Do you have any insight into this? Meanwhile I'll go do some 
> digging myself on the Clojure JIRA etc. so I'm more informed on the 
> subject. 

-- 
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 transducers in a new transducing context

2017-04-09 Thread Seth Verrinder
My guess is that partition-all and partition use non-volatile references 
because none of the built-in stuff will return control back to the caller 
at a finer resolution than output value (AFAIK). That's why take needs 
volatile but partition-all doesn't (because for take the state persists 
between output values).
It does mean that new transducing contexts would need to synchronize though 
- which core.async does through mutexes.

On Sunday, April 9, 2017 at 8:47:25 AM UTC-5, tbc++ wrote:
>
> The volatile! is needed for the case where a transducer is only used by 
> one thread at a time, but the thread executing the transducer may change 
> from one call to the next. This happens fairly often with core.async. If 
> you used a non-atomic, non-volatile mutable field, the JVM would be free to 
> perform several optimizations (like keeping the local in a CPU register) 
> that would cause the value to not properly propagate to other threads in 
> the case of a context switch. Using volatile! tells the JVM to flush all 
> writes to this field by the time the next memory barrier rolls around. It 
> also tells the JVM to make sure it doesn't cache the reads to this field 
> across memory barriers. 
>
> It's a tricky subject, and one that's really hard to test, and frankly I 
> probably got some of the specifics wrong in that last paragraph, but that's 
> the general idea of why transducers use volatile!. 
>
> Timothy
>
> On Sun, Apr 9, 2017 at 12:49 AM, Alexander Gunnarson <
> alexander...@gmail.com > wrote:
>
>> EDIT: Transducers are actually not safe in `fold` contexts as I thought:
>>
>> (let [f (fn [i x] (println (str "i " i " " (Thread/currentThread))) 
>> (flush) x)
>>   r-map-indexed #(r/folder %2 (map-indexed %1))]
>>   (->> [6 7 8 9 10]
>>(r-map-indexed f)
>>(r/fold 1 (fn ([] (vector)) ([x] x) ([a b] (into a b))) conj)))
>>
>> Produces:
>>
>> i 0 Thread[ForkJoinPool-1-worker-2,5,main]
>> i 2 Thread[ForkJoinPool-1-worker-1,5,main]
>> i 3 Thread[ForkJoinPool-1-worker-1,5,main]
>> i 4 Thread[ForkJoinPool-1-worker-1,5,main]
>> i 1 Thread[ForkJoinPool-1-worker-3,5,main]
>>
>> So you would have to be careful to e.g. create different `map-indexed` 
>> transducers for single-threaded (e.g. `unsynchronized-mutable` box) and 
>> multi-threaded (e.g. `atom` box) contexts.
>>
>> On Sunday, April 9, 2017 at 2:10:06 AM UTC-4, Alexander Gunnarson wrote:
>>>
>>> I was wondering the same thing, shintotomoe. This thread 
>>>  talks 
>>> about it as well. I think it's safe to assume that since `ArrayList` uses 
>>> unsynchronized mutability internally (a quick review of the GrepCode 
>>> entry for `ArrayList` confirms this 
>>> ),
>>>  
>>> then we can rest assured that a `volatile` box as opposed to a totally 
>>> unsynchronized mutable variable is unnecessary, even in the context of 
>>> `fold`. After all, `reduce` (and by extension, `transduce`) is only ever 
>>> going to be single-threaded unless the data structure in question 
>>> unexpectedly implements a multithreaded reduce, which should never happen 
>>> (and if it does, you likely have bigger problems). To be honest, I'm not 
>>> sure why `volatile` is used in transducers instead of e.g. an 
>>> `unsynchronized-mutable` box. There may be a good reason, but I'm not 
>>> seeing it immediately. I'd love to learn.
>>>
>>> On Thursday, January 1, 2015 at 10:36:13 PM UTC-5, shintotomoe wrote:

 Thank you for the superfast response. I take it implementing your own 
 transducing process is not something you would usually do unless you have 
 a 
 unique use case (my own use case being already implemented by chan taking 
 a 
 transducer).

 Still, I was wondering about the use of ArrayList in partition-all, and 
 the recommendation to use volatiles inside transducers, which seem at 
 odds. 
 It seems we don't need to implement transducers in a thread-safe way. Is 
 that correct?

 On Friday, January 2, 2015 12:58:51 PM UTC+11, tbc++ wrote:
>
> Core.async already has pipeline, pipeline-blocking and pipeline-async. 
> In addition you can use a transducer inside a channel. Use those instead. 
>
> Timothy
>
> On Thu, Jan 1, 2015 at 6:55 PM, shintotomoe  
> wrote:
>
>> I was wondering how to apply a transducer inside a go process. What 
>> I've so far is the following
>>
>> (defn pipe-xform [in-ch out-ch xform]
>>   (let [tr
>> (let [tr (xform (fn
>>   ([result] result)
>>   ([result input] (conj! result input]
>>   (fn
>> ([] (locking tr (persistent! (tr (transient [])
>> ([input] (locking tr (persistent! (tr (transient []) 
>> input))]
>> (go-l

Re: Deploying multiple Clojure apps on one server using Reagent, Nginx, and Supervisor (Solved)

2017-01-06 Thread Seth Archambault
Thanks! Sounds like multiple war files would be the right way for me. 
Unfortunately, I'm falling into the original problem with finding 
information on how to do this...

Got any links to articles on how to do this? 
Thanks!


On Tuesday, January 3, 2017 at 7:12:54 PM UTC-5, Sean Corfield wrote:
>
> 1GB is certainly pretty small for the JVM world, if you’re thinking of 
> running multiple apps / sites as separate JVM processes.
>
>  
>
> However, there are several ways around that.
>
>  
>
> It’s common in the JVM world to have a single “web server” process load 
> and run multiple “web applications”. A servlet container (Tomcat, Jetty, 
> JBoss…) runs multiple apps each packaged as a WAR file (a zip file with 
> some additional metadata).
>
>  
>
> Another option is to package multiple applications into one uberjar and 
> start up multiple apps on different ports directly inside your own code, or 
> you could use a single app with middleware that selects a different set of 
> routes for each different domain / port / however you distinguish between 
> your apps externally.
>
>  
>
> Bottom line: having each app as a separate uberjar, spinning up in a 
> separate JVM isn’t the most scalable way of running multiple apps on a 
> single server.
>
>  
>
> For comparison, at World Singles, we have about 100 sites running on (a 
> cluster of instances of) a single web application under the hood. The 
> domain being requested determines how the request is handled – in our case 
> the skin and theme of each site, along with a lot of other metadata, is all 
> dynamic and based on the domain name. Our sites are similar enough that 
> this is possible. That’s for the main customer-facing sites. We also have 
> an affiliate web site and an internal admin web site. Those three codebases 
> are each, essentially, a WAR-based app and all three can run on a single 
> Tomcat instance (on each server in the cluster). We run a single JVM with 
> 10GB heap configured for Tomcat on each of a cluster of servers, each with 
> 64GB RAM (our database servers are in a separate cluster and have 128GB RAM 
> each, I believe).
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> On 1/3/17, 2:16 PM, "Seth Archambault"   on behalf of seth...@gmail.com > wrote:
>
>  
>
> Haha thanks for pointing that out - I mispoke - 1024 mb of ram - 1 gig of 
> ram. Using a $10 a month Vultr account. 1000 gigs would be a tad expensive!
>
> On Monday, January 2, 2017 at 8:27:19 PM UTC-5, William la Forge wrote:
>
> Seth, something seems amiss. 1,000 GB is 1,000,000 MB. At 84 mb per jar, 
> you can spin up 11,904 jar files. Which is worse than only being able to 
> run only dozens of PHP apps.
>
>  
>
> --b 
>
> -- 
> 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: Deploying multiple Clojure apps on one server using Reagent, Nginx, and Supervisor (Solved)

2017-01-03 Thread Seth Archambault
Haha thanks for pointing that out - I mispoke - 1024 mb of ram - 1 gig of 
ram. Using a $10 a month Vultr account. 1000 gigs would be a tad expensive!

On Monday, January 2, 2017 at 8:27:19 PM UTC-5, William la Forge wrote:
>
> Seth, something seems amiss. 1,000 GB is 1,000,000 MB. At 84 mb per jar, 
>>>> you can spin up 11,904 jar files. Which is worse than only being able to 
>>>> run only dozens of PHP apps.
>>>>
>>>
> --b 
>

-- 
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: Deploying multiple Clojure apps on one server using Reagent, Nginx, and Supervisor (Solved)

2017-01-02 Thread Seth Archambault
A new issue with this. I'm running on a Ubuntu server with 1000 gigs of ram 
- this has been enough in the past for dozens of php apps - however I'm 
finding with each jar I spin up on the server, it uses ~ 84mb each. At this 
rate it will become expensive to constantly create new apps. 

PHP's memory usage seems to be dictated by traffic, not by how many 
websites you have running, is Java's memory use different?

I am using supervisor + nginx to serve the Clojure Uberjars - is there 
anything I can do to make this more efficient / not increase with each new 
site? Is there any technology I should look into, or practices I should 
implement for this?

Being able to run many websites on one server is a critical issue for me... 
Anyone have any advice? Thanks!

On Friday, December 23, 2016 at 11:56:19 AM UTC-5, Seth Archambault wrote:
>
> :-O 
> That just blew my mind - Thanks! :)
>
> On Friday, December 23, 2016 at 11:01:28 AM UTC-5, James Reeves wrote:
>>
>> I think this is something a lot of web developers take for granted, so 
>> perhaps it isn't mentioned as much as it could be.
>>
>> The usual convention in Linux environments is to set the port via the 
>> PORT environment variable. So on the command line it would be:
>>
>>   PORT=3001 java -jar yourapp.jar
>>
>> That's what this line does in your source code:
>>
>> (Integer/parseInt (or (env :port) "3000"))
>>
>> It looks for the "PORT" environment variable, and if it doesn't find it 
>> then it defaults to "3000". Then it converts the resulting string into an 
>> integer.
>>
>> You may want to take a look at the Luminus deployment guide 
>> <http://www.luminusweb.net/docs/deployment.md>. Luminus is a commonly 
>> used project template, but the deployment docs apply to most Clojure web 
>> projects and cover a range of setups.
>>
>> - James
>>
>>
>> On 23 December 2016 at 14:11, Seth Archambault  wrote:
>>
>>> I'm posting this because right now someone is scrounging the internet 
>>> for 3 hours to find this simple solution, I hope that they find this post 
>>> sooner rather than later, and can move on to their next project!
>>>
>>> *TLDR*
>>>
>>> Goto /src/clj/myapp/server.clj
>>>
>>> Edit "3000" to be whatever you want:
>>>
>>>  (defn -main [& args]
>>>(let [port (Integer/parseInt (or (env :port) "3000"))]
>>>  (run-jetty app {:port port :join? false})))
>>>
>>> Now Here's the journey of a new user to find this information...
>>>
>>> Let's say you installed Clojure with:
>>>
>>> lein new reagent myapp
>>>
>>> You built out your app, and everything went well! Time to deploy.
>>>
>>> You may have stumbled upon this DigitalOcean guide, How To Deploy a 
>>> Clojure Web Application on Ubuntu 14.04 
>>> <https://www.digitalocean.com/community/tutorials/how-to-deploy-a-clojure-web-application-on-ubuntu-14-04>
>>>
>>> It worked mostly, though your app wants to run on port 3000, not 5000. 
>>> No problem, just changed it in the nginx config
>>>
>>> 6 server { 
>>>   7 listen 80;
>>>   8 server_name www.myapp.us myapp.us;
>>>   9 location / {
>>>  10 proxy_pass http://127.0.0.1:3000;
>>>  11 proxy_http_version 1.1;
>>>  12 proxy_set_header Connection "";
>>>  13 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>>  14 proxy_set_header Host $http_host;
>>>  15 access_log /var/www/myapp/logs/myapp.access.log;
>>>  16 error_log /var/www/myapp/logs/myapp.error.log;
>>>  17 }
>>>  18 }
>>>
>>> The recommended /etc/supervisor/conf.d/myapp.conf file worked great. 
>>> Your site is launched and all is well!
>>>
>>> Okay so with that resounding success you decide you want to launch a 
>>> second clojure app. 
>>>
>>> First, if you're used to using php and nginx, you might be thinking you 
>>> may be able to have your app run on the default port buy "look" for another 
>>> url, maybe it's something you can easily change in the nginx config, or the 
>>> supervisor config, or maybe the project.clj file. But a search on google 
>>> seems to be focused on using separate port numbers:
>>>
>>> How can I run multiple Ring apps on the same server? 
>>> <

Re: Deploying multiple Clojure apps on one server using Reagent, Nginx, and Supervisor (Solved)

2016-12-23 Thread Seth Archambault
:-O 
That just blew my mind - Thanks! :)

On Friday, December 23, 2016 at 11:01:28 AM UTC-5, James Reeves wrote:
>
> I think this is something a lot of web developers take for granted, so 
> perhaps it isn't mentioned as much as it could be.
>
> The usual convention in Linux environments is to set the port via the PORT 
> environment variable. So on the command line it would be:
>
>   PORT=3001 java -jar yourapp.jar
>
> That's what this line does in your source code:
>
> (Integer/parseInt (or (env :port) "3000"))
>
> It looks for the "PORT" environment variable, and if it doesn't find it 
> then it defaults to "3000". Then it converts the resulting string into an 
> integer.
>
> You may want to take a look at the Luminus deployment guide 
> <http://www.luminusweb.net/docs/deployment.md>. Luminus is a commonly 
> used project template, but the deployment docs apply to most Clojure web 
> projects and cover a range of setups.
>
> - James
>
>
> On 23 December 2016 at 14:11, Seth Archambault  > wrote:
>
>> I'm posting this because right now someone is scrounging the internet for 
>> 3 hours to find this simple solution, I hope that they find this post 
>> sooner rather than later, and can move on to their next project!
>>
>> *TLDR*
>>
>> Goto /src/clj/myapp/server.clj
>>
>> Edit "3000" to be whatever you want:
>>
>>  (defn -main [& args]
>>(let [port (Integer/parseInt (or (env :port) "3000"))]
>>  (run-jetty app {:port port :join? false})))
>>
>> Now Here's the journey of a new user to find this information...
>>
>> Let's say you installed Clojure with:
>>
>> lein new reagent myapp
>>
>> You built out your app, and everything went well! Time to deploy.
>>
>> You may have stumbled upon this DigitalOcean guide, How To Deploy a 
>> Clojure Web Application on Ubuntu 14.04 
>> <https://www.digitalocean.com/community/tutorials/how-to-deploy-a-clojure-web-application-on-ubuntu-14-04>
>>
>> It worked mostly, though your app wants to run on port 3000, not 5000. No 
>> problem, just changed it in the nginx config
>>
>> 6 server { 
>>   7 listen 80;
>>   8 server_name www.myapp.us myapp.us;
>>   9 location / {
>>  10 proxy_pass http://127.0.0.1:3000;
>>  11 proxy_http_version 1.1;
>>  12 proxy_set_header Connection "";
>>  13 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>  14 proxy_set_header Host $http_host;
>>  15 access_log /var/www/myapp/logs/myapp.access.log;
>>  16 error_log /var/www/myapp/logs/myapp.error.log;
>>  17 }
>>  18 }
>>
>> The recommended /etc/supervisor/conf.d/myapp.conf file worked great. Your 
>> site is launched and all is well!
>>
>> Okay so with that resounding success you decide you want to launch a 
>> second clojure app. 
>>
>> First, if you're used to using php and nginx, you might be thinking you 
>> may be able to have your app run on the default port buy "look" for another 
>> url, maybe it's something you can easily change in the nginx config, or the 
>> supervisor config, or maybe the project.clj file. But a search on google 
>> seems to be focused on using separate port numbers:
>>
>> How can I run multiple Ring apps on the same server? 
>> <http://stackoverflow.com/questions/15732618/how-can-i-run-multiple-ring-apps-on-the-same-server>
>>  
>>
>> You don't necessarily think of your app as a "Ring" app - sure it's a 
>> library, but isn't this just Clojure? Anyways, this seems to be the 
>> solution, but how do we change the port? 
>>
>> Searching google some more:
>>
>> Offical Lein Ring Instructions <https://github.com/weavejester/lein-ring> - 
>> not helpful
>> How to set ring port based on profile 
>> <http://stackoverflow.com/questions/27945399/how-to-set-ring-port-based-on-profile>
>>  - 
>> something about profiles, not helpful 
>> You browser the rest of the front page of google and continue to get 
>> posts like this.
>>
>> If you come from a mainstream language like PHP, you're thinking "Hmm, 
>> deploying multiple apps is an extremely basic task.. Why do I feel like I'm 
>> the first one to ever do it?"
>>
>> Thinking that maybe it's just a standard Java thing, you start searching 
>> for "change java jar port". But the

Re: POST in Ajax - Invalid anti-forgery token

2016-12-23 Thread Seth Archambault
Okay, armed with the new clarity, I felt embolden to tackle this once more. 
Here's the next steps for those trying to tack CSRF protection onto a 
Reagent project created with lein new reagent. 

In handler.clj - you'll add the ring.middleware.anti-forgery and refer to 
*anti-forgery-token*

(ns myapp.handler
  (:require
[ring.middleware.anti-forgery :refer [*anti-forgery-token*]]))


Then, lower down in your code you'll have something like this:

(html5
  [:head
   [:meta {:csrf-token *anti-forgery-token*}]


This will create a token for you.  

Now I haven't gone the rest of the distance with this problem so I can't 
say that it's all downhill from here, it's possible I'm messing up and 
re-generating a token that won't match what's already matched in the 
session. Let me know if that's what I'm doing :(

But the next thing I would do, is in /cljs/myapp/core.cljs - I would find a 
way to pull in this token from the meta tag (maybe by using vanilla 
javascript) and then add it to my post commands. 

A couple things that confused me:

It's not obvious that you have to add ring.middleware.anti-forgery to 
handler.clj, because in the examples in the documentation we're pulling 
that in so we can do "wrap-anti-forgery" in our middleware.clj. However, 
this is done automatically using ring.middleware.defaults, in the 
middleware.clj file, so it looks like ring.middleware.anti-forgery doesn't 
need to be anywhere. 

However, without ring.middleware.anti-forgery, it seems 
*anti-forgery-token* isn't bound.. once you require that, that it exists!

Let me know if my assumptions are wrong on this - it's possible I'm going 
down the wrong direction and that *anti-forgery-token* is actually stored 
in the session somewhere, but I have no idea how to access the session at 
this point.. That sounds like a whole nother bag of worms.

*Epilogue*

The turning point for me was realizing that the ring-defaults file is 
ridiculously easy to comprehend on Github. I'm so used to php projects 
where inspecting classes is basically impossible - in order to understand 
one thing, you need to understand 12 other things, which in turn require an 
understanding of 3 other things etc. To open up defaults.cli and see that 
site-defaults is just a simple map, literally made me sigh in relief :p

I'm beginning to grasp the structure of packages of namespaces, which makes 
seeing into the code easier.  It strikes me Clojure is a system which 
dramatically rewards investment into it's fundamental building blocks. I 
feel like I have a lot to learn, but it's all worth learning.  Thanks!

-- 
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: POST in Ajax - Invalid anti-forgery token

2016-12-23 Thread Seth Archambault
Wow, thank you! This makes a lot of sense, it sounds like I really do not 
need CSRF protection.. I'm just adding complexity there..

I think my key mess up here was getting my client side / server side code 
mixed up in my head. I am really enjoying using ClojureScript and Clojure 
side by side, but yeah it makes sense that I can't use ring's libraries 
inside a client side language. That's just something I'll have to keep in 
mind.

I'm guessing if I was going to make use of CSRF in the future, I would drop 
it into a meta tag on the server side, and then reference that meta tag 
with javascript (that's how Laravel does it). ...but I'll cross that bridge 
when I come to it.

Thanks!
Seth 

On Friday, December 23, 2016 at 10:36:46 AM UTC-5, James Reeves wrote:
>
> The "use" function is a deprecated shortcut for "require" and "refer". I 
> can see why it would be confusing, so I'll change the examples on the 
> ring-anti-forgery site.
>
> Packages can contain many namespaces, so in general you won't find package 
> names matching up precisely to the namespace or namespaces that they 
> provide.
>
> Regarding CSRF protection, you firstly only need it if you have user 
> authentication in your app. If that doesn't matter, you can turn it off.
>
> If you do have user authentication, then read on.
>
> It's difficult to produce a library that does everything automatically, 
> because it requires cooperation between server-side and client-side code. 
> Ring just handles the server-side, so it's up to you, or another library, 
> to handle the client-side.
>
> I'm not sure how to explain the general functionality any better than the 
> README of the project already does:
>
> Any request that isn't a HEAD or GET request will require an anti-forgery 
>> token, or an "access denied" response will be returned. The token is bound 
>> to the session, and accessible via the *anti-forgery-token* var.
>
>  
>
> By default the middleware looks for the anti-forgery token in the 
>> "__anti-forgery-token" form parameter, which can be added to your forms as 
>> a hidden field. 
>
>  
>
> The middleware also looks for the token in the "X-CSRF-Token" and 
>> "X-XSRF-Token" header fields, which are commonly used in AJAX requests. 
>
>
> In terms of what that specifically means for you, you need to do two 
> things:
>
>1. Add the value of the *anti-forgery-token* somewhere your 
>ClojureScript can find it.
>
>2. Add the value to the "X-CSRF-Token" header each time you send an 
>AJAX request.
>
> There may be libraries that handle the client-side for you. Maybe someone 
> else can suggest one. The specifics really depend on how your app is put 
> together.
>
> - James
>
>
> On 23 December 2016 at 14:39, Seth Archambault  > wrote:
>
>> So when I use cljs-ajax to post to my APP I get an Invalid anti-forgery 
>> token error. 
>>
>> Despite there being dozens of posts about this issue, none of them have a 
>> solution that seems to work if you started your project using this:
>>
>> lein new reagent myapp
>>
>> The first post that comes up as a "solution" actually recommends 
>> disabling CSRF protection, which seems like just avoiding the problem 
>> rather than solving it, but they don't actually tell you how to do that 
>> either!
>>
>> After 4 hours of searching for any solution, I admit that the only fix 
>> that I found was this:
>>
>> (ns reformdems.middleware
>>   (:require [ring.middleware.defaults :refer [site-defaults 
>> wrap-defaults]]
>> [ring.middleware.json :refer [wrap-json-params]]
>> [prone.middleware :refer [wrap-exceptions]]
>> [ring.middleware.reload :refer [wrap-reload]]))
>>
>> (defn wrap-middleware [handler]
>>   (-> handler
>>   (wrap-defaults (merge site-defaults {:security {:anti-forgery 
>> false} :params {:keywordize true}}))
>>   wrap-exceptions
>>   wrap-reload
>>   wrap-json-params))
>>
>>
>> By setting :security :anti-forgery to false, I no longer get the 
>> Anti-Forgery issue. But yeah, this isn't a real solution.
>>
>> What I'm looking to do is get one of the solutions involving 
>> "*anti-forgery-token*" 
>> or (anti-forgery-field) working.
>>
>> Unfortunately, these instructions here, don't work, and only produce hard 
>> to understand errors:
>> https://github.com/ring-clojure/ring-anti-forgery
>&

POST in Ajax - Invalid anti-forgery token

2016-12-23 Thread Seth Archambault
So when I use cljs-ajax to post to my APP I get an Invalid anti-forgery 
token error. 

Despite there being dozens of posts about this issue, none of them have a 
solution that seems to work if you started your project using this:

lein new reagent myapp

The first post that comes up as a "solution" actually recommends disabling 
CSRF protection, which seems like just avoiding the problem rather than 
solving it, but they don't actually tell you how to do that either!

After 4 hours of searching for any solution, I admit that the only fix that 
I found was this:

(ns reformdems.middleware
  (:require [ring.middleware.defaults :refer [site-defaults wrap-defaults]]
[ring.middleware.json :refer [wrap-json-params]]
[prone.middleware :refer [wrap-exceptions]]
[ring.middleware.reload :refer [wrap-reload]]))

(defn wrap-middleware [handler]
  (-> handler
  (wrap-defaults (merge site-defaults {:security {:anti-forgery false} 
:params {:keywordize true}}))
  wrap-exceptions
  wrap-reload
  wrap-json-params))


By setting :security :anti-forgery to false, I no longer get the 
Anti-Forgery issue. But yeah, this isn't a real solution.

What I'm looking to do is get one of the solutions involving 
"*anti-forgery-token*" 
or (anti-forgery-field) working.

Unfortunately, these instructions here, don't work, and only produce hard 
to understand errors:
https://github.com/ring-clojure/ring-anti-forgery

As a side note, it's really confusing when all the libraries use this 
language:

(use 'ring.util.anti-forgery)
(anti-forgery-field)


Meanwhile "use" is not in any of the code generated using lein. I would 
expect this would be the proper way to use the libraries:

(ns myapp.server
  (:require 
[ring.util.anti-forgery) :refer [anti-forgery-field]]))

Of course, I'm just guessing at that refer command, but my point is this 
inconsistency makes me feel like I'm looking at solutions designed for an 
older version of Clojure or something? 

I'm also concerned that given a library [ring/ring-anti-forgery "1.0.1"] 
there is no way to intuitively know how to "require" that library in your 
code. In the above situation the word "util" gets added when requiring it..


*Anyways, my main question is this:*What is the modern way to do CSRF 
protection?

Secondly, I'm concerned I'm doing something wrong - ring.middleware feels 
like a magical thing where you apply wrappers, and then stuff just 
magically works. I'm not a big fan of magic, I want to be able to see a 
pathway for finding a solution, not just google around and figure out a 
wrapper needs to be added.. Any recommendations on that front?

Thanks!
Seth

-- 
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.


Deploying multiple Clojure apps on one server using Reagent, Nginx, and Supervisor (Solved)

2016-12-23 Thread Seth Archambault
s folder structure isn't explicitly connected 
to the project.clj - like there's no way you could study the project.clj 
and determine that /src/clj/myapp/server.clj is used by anything. It just 
happens magicaly, the complexity is hidden...

Again, I'm really enjoying clojure so far, and I really agree with the 
creators vision, but I'm concerned whenever really easy tasks take forever 
to do and seem to have hidden complexity.

I'm interested in other peoples thoughts here. Have you felt in a similar 
way? What am I doing wrong? 

Thanks!
Seth

-- 
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: is this macro right?

2016-01-04 Thread Seth Verrinder
Hi,
I posted another answer to this. There's an additional problem with the 
macro that explains what you're seeing in your first example.

- Seth

On Monday, December 28, 2015 at 2:47:39 AM UTC-6, Mian Pao wrote:
>
>
> http://stackoverflow.com/questions/34448773/is-function-print-has-bug-in-clojure
>

-- 
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: Output of printf is buffered

2014-06-24 Thread Seth Yuan
Yeah, this is definitely an annoying bug.

On Thursday, April 10, 2014 8:03:02 PM UTC+8, Kevin Ilchmann Jørgensen 
wrote:
>
> nREPL server started on port 53667 on host 127.0.0.1
> REPL-y 0.3.0
> Clojure 1.5.1
> Docs: (doc function-name-here)
>   (find-doc "part-of-name-here")
>   Source: (source function-name-here)
>  Javadoc: (javadoc java-object-or-class-here)
> Exit: Control+D or (exit) or (quit)
>  Results: Stored in vars *1, *2, *3, an exception in *e
>
> *user=> (source println)*
> (defn println
>   "Same as print followed by (newline)"
>   {:added "1.0"
>:static true}
>   [& more]
> (binding [*print-readably* nil]
>   (apply prn more)))
> nil
> *user=> (source prn)*
> (defn prn
>   "Same as pr followed by (newline). Observes *flush-on-newline*"
>   {:added "1.0"
>:static true}
>   [& more]
> (apply pr more)
> (newline)
> (when *flush-on-newline*
>   (flush)))
> nil
> *user=> (source printf)*
> (defn printf
>   "Prints formatted output, as per format"
>   {:added "1.0"
>:static true}
>   [fmt & args]
>   (print (apply format fmt args)))
> nil
> *user=> (source print)*
> (defn print
>   "Prints the object(s) to the output stream that is the current value
>   of *out*.  print and println produce output for human consumption."
>   {:added "1.0"
>:static true}
>   [& more]
> (binding [*print-readably* nil]
>   (apply pr more)))
> nil
> *user=> (source pr)*
> (defn pr
>   "Prints the object(s) to the output stream that is the current value
>   of *out*.  Prints the object(s), separated by spaces if there is
>   more than one.  By default, pr and prn print in a way that objects
>   can be read by the reader"
>   {:dynamic true
>:added "1.0"}
>   ([] nil)
>   ([x]
>  (pr-on x *out*))
>   ([x & more]
>(pr x)
>(. *out* (append \space))
>(if-let [nmore (next more)]
>  (recur (first more) nmore)
>  (apply pr more
> nil
> *user=> *flush-on-newline**
> true
> user=>
>
>
> On Thu, Apr 10, 2014 at 1:50 PM, Cecil Westerhof  > wrote:
>
>> 2014-04-10 13:40 GMT+02:00 Di Xu >:
>>
>> there're three buffer mode in unix, line buffered, full buffered and no 
>>> buffered, if the output is terminal then it's default to line buffered. 
>>> That means it buffer the output until '\n' occurs, you can force output via 
>>> flush.
>>>
>>
>> The printf format string is "%s: %s\n", so there is a newline, but it is 
>> not acted upon.
>>  
>>  
>>
>>> 2014-04-10 19:30 GMT+08:00 Cecil Westerhof >> >:
>>>
 2014-04-10 12:52 GMT+02:00 Kevin Ilchmann Jørgensen >>> >:

 I believe this is how the terminal behave. You can force an 
> (clojure.core/flush)
>

 But why does println not behave this way?

 I think I stick to println for the moment.


 On Thu, Apr 10, 2014 at 12:34 PM, Cecil Westerhof  > wrote:
>
>> I have the following simple program:
>> (def time-format (new java.text.SimpleDateFormat "hh:mm:ss"))
>>
>> (defn now []
>>   (new java.util.GregorianCalendar))
>>
>> (defn give-message [message]
>>   (printf 
>> "%s: %s\n" (. time-format format (. (now) getTime)) message))
>>
>> (give-message "Start")
>> (doseq [i (range 1 10001)]
>>(let [val (Math/sqrt i)
>> diff (Math/abs (- (Math/pow val 2) (* val val)))]
>> (when-not (< diff 1.5E-8)
>>   (println (format "Different for %d (%e)" i diff)
>> (give-message "Stop")
>>
>> It does what it should, but I have a little problem with it: the 
>> output of give-message is only showed after terminating the program. Why 
>> is 
>> that?
>>
>> When changing give-message to:
>> (defn give-message [message]
>>   (println (format "%s: %s" (. time-format format (. (now) 
>> getTime)) message)))
>>
>> the output is shown immediately.
>>
>
>> -- 
>> Cecil Westerhof 
>>
>> -- 
>> 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 

Re: Advice on data structure communication and awareness

2014-05-19 Thread Seth
Hi Mike! You might talk to Zack at CapClug. The session before the one you 
attended he walked through two small Clojure projects, with and without 
Prismatic schema.

On Saturday, May 17, 2014 2:22:51 PM UTC, Mike Fikes wrote:
>
> I've never used a dynamically-typed language and an issue I've encountered 
> with Clojure is a difficulty with readily "seeing" the data structures 
> being consumed or returned by functions I'm writing, especially when I come 
> back to them several days later and if those structures get to be somewhat 
> nested or otherwise complex.
>
> As a small concrete example, lets say that I currently have a function 
> that accepts data that looks like {:a "A" :b "B"} and, at some point I 
> change the internals of the function to instead operate on data that looks 
> like [[:a "A"] [:b "B"]].
>
> I could see the docstring communicating that the initial implementation of 
> the function accepts a map, and then perhaps it boils down to finding 
> suitable language to describe the structure in the revised implementation 
> ("sequence of pairs", "relation", or some other language suitable to the 
> abstraction).
>
> I suppose this is no different than the "documentation" aspect that 
> generics provided in Java when we went from raw types like List to 
> List, but, of course, generics can get unwieldy rather quickly with 
> things like List>>.
>
> Does there exist idiomatic language that developers employ in their 
> docstrings to quickly convey this kind of info? I see that the docstrings 
> for clojure.core are fairly readable, but they tend to operate on very 
> simple data structures.
>

-- 
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: How to structure a Clojure day for noobs?

2012-12-20 Thread Seth Chandler
I would spend A LOT of time on working with the IDE be it 
Eclipse/Counterclockwise, IntelliJ or whatever.  In my limited experience 
the main impediment to Clojure is not Clojure itself, which is very 
sensible, but in dealing with file locations, dependency management, 
projects, Leiningen, all of which are -- with due respect -- very 
difficult, particularly for people not coming from an Eclipse or similar 
background.  Once you have the confidence that comes with understanding 
your IDE, you can learn Clojure by playing and by reading idiomatic code. 
 Until then, however, Clojure development can be VERY frustrating .  Maybe 
this will all go away once we have better IDEs (LightTable, Session) full 
developed, but until then don't just "assume" that people understand the 
IDE.

On Saturday, December 15, 2012 4:13:21 PM UTC-6, ulsa wrote:
>
> In a couple of months, I'll have a whole day of teaching Clojure to ten of 
> my colleagues. They are experienced Java programmers, but otherwise Clojure 
> rookies. Any tips on how to structure such a workshop day?
>

-- 
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

Using gen-class to generate methods with same names and arities but different type signatures

2012-08-02 Thread Seth Chandler
Don't have an answer but I would sure enjoy hearing the group's wisdom on this. 

-- 
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


Re: community interest in machine learning (?)

2012-07-19 Thread Seth Chandler
I'm extremely interested.  I'm new to Clojure, coming mostly from a 
Mathematica background, but I just finished a major project linking 
Mathematica to Weka and am interested in doing something similar with 
Clojure.  Weka, by the way, is 99% terrific, and so before people go 
completely reinvent the wheel, it might be worthwhile thinking about a 
Clojure-Weka interface of sorts.  

On Sunday, July 15, 2012 11:10:22 AM UTC-6, Joshua Bowles wrote:
>
> New to Clojure (but not Lisp).
>
> Does anyone have a good sense of the interest in machine learning in 
> Clojure community?
> I've seen in the last few threads some interesting posts and libraries 
> related to machine learning, and there is plenty of stuff one can get from 
> Java (mahout, weka, clj-ml [
> http://antoniogarrote.github.com/clj-ml/index.html]), but I'm curious to 
> know if anyone here has a sense of the overall community interest. 
>
> It's nice to see interesting libraries that support needed tasks for 
> machine learning (I'm all for links to libraries), but what I'm really 
> trying to get is* a sense of the overall interest the community has in 
> machine learning*. For example, Python community overall has a lot of 
> interest in scientific computing and machine learning. Compare this to 
> Ruby... not that you couldn't provide good libraries in Ruby (for example 
> the SciRuby project), but the Ruby community overall does not seem to have 
> much interest in these kinds of academic pursuits.
>

-- 
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

s-expression levels and higher order functions

2012-07-19 Thread Seth Chandler
I'm new both to Clojure and to this group, so please be gentle.  I come to 
Clojure mostly from a Mathematica background, which has a certain Lispyness 
to it.  One of the things one can do in Mathematica is to map a function to 
an s-expression but not at its top level, but rather at some user specified 
level.  Thus Map[f, {{a,b},{c,d}},{2}] will (because of the {2} as the last 
argument) evaluate to {{f[a],f[b]},{f[c],f[d]}} rather than 
{f[{a,b}],f[{c,d}]}.  I have found this capability of having functions that 
work at levels of an expression to be extremely valuable.  Is there work 
already done that extends the higher order functions to permit something 
like this.  And, yes, I am sure one could write a macro and perhaps that 
has already been done, but I was curious as to what was out there.  My 
Google search did not yield much on this topic, but perhaps I used the 
wrong Clojure vocabulary.

Thanks

-- 
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

defrecord/defprotocol documentation suggestions

2011-03-18 Thread Seth
I would suggest adding something on the lines of these - it is
confusing to newcomers, and it really isnt complete documentation to
not include. The crux of the matter is how clojure defines methods
when a record has inline protocols, etc. Maybe i missed this in the
documentations.


1. extend-protocol will allow the record to refer to the same protocol
if the protocol is redefined (and even if the protocol is simply
reloaded, but the definition doesnt change, it will still screw up
records whicih define the protocol inline), inline wont

http://groups.google.com/group/clojure/browse_thread/thread/607902114ab55ecd

2. record definitions with inline protocol definitions get redifined
on a :reload-all (i think), even if their definitions dont actually
change. This means previous records of the same type dont refer to the
new same type - this is only of a concern when developing at the repl.
This is a problem for type hinting and dispatching on classes in
multimethods, and for testing types.


3. if defrecord has inline protocol definitions, you can access these
methods with the dot syntax - otherwise you cant.
;;example - dot
(defprotocol PSocket (close [this]))
(defrecord socket []
  PSocket
  (close [this] true))
(.close (socket.)) and (close socket) works
(defrecord socket2 [])
(extend-protocol PSocket
  socket2
  (close [this] false))

(.close (socket2.)) ;;no matching field found error
(close (socket2.)) ;;=> returns false

And for defprotocol

1. (defprotocol Test)
Test => returns a map

while in another ns, when you import the ns which has Test, Test will
return the actual class.
This is a problem for multimethods in the same ns - of course, you can
just do myns.Test

-- 
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


Re: with-timeout... ?

2011-03-09 Thread Seth
oooh ... I can definitely find a use for this in my project! Thanks
for pointing it out.

-- 
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


Re: with-timeout... ?

2011-03-09 Thread Seth
Or you could just modify the source of promise ... i dont know why
promises dont support timeouts 

(defprotocol PWait
  (wait-for [this timeout units] [this timeout]))
;;copied from clojure source, but adding timeout wait-for
(defn promise
  "Alpha - subject to change.
  Returns a promise object that can be read with deref/@, and set,
  once only, with deliver. Calls to deref/@ prior to delivery will
  block. All subsequent derefs will return the same delivered value
  without blocking."
  {:added "1.1"}
  []
  (let [d (java.util.concurrent.CountDownLatch. 1)
v (atom nil)]
(reify
  clojure.lang.IDeref
  (deref [_] (.await d) @v)
  PWait
  (wait-for [this timeout]
(wait-for this timeout
  java.util.concurrent.TimeUnit/MILLISECONDS))
  (wait-for [this timeout units]
(if timeout
  (.await d timeout units)
  (do (.await d) true)))
  clojure.lang.IFn
  (invoke [this x]
  (locking d
(if (pos? (.getCount d))
  (do (reset! v x)
  (.countDown d)
  x)
  (throw
   (IllegalStateException.
"Multiple deliver calls to a promise"

-- 
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


Re: Serialising functions...

2011-03-01 Thread Seth
Now reflecting on it, and without looking exactly at source code, i
think it is clear that functions are implemented as classes (which
extend RestFn, etc). and the  body are methods of the classes - so,
one couldnt force function class names to be the same. And of course
they need to be random enough to order to avoid collision.

Of course this could be wrong, but it sounds correct.

-- 
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


Re: Serialising functions...

2011-03-01 Thread Seth
> So, combine the ClassLoader hackery with slapping "implements
> Serializable" on clojure.lang.IFn?

Actually, I just looked at the implementation code -and this is not
true. Actually, a variadic function is of type RestFn and otherwise it
is of type AFunction. Restfn extends AFunction, and AFunction already
implements Serializable.

So heres what causes the changing names -

In Compiler.java
https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/Compiler.java

In the below method of the FnExpr class
static Expr parse(C context, ISeq form, String name) throws Exception

it creates a string name with the following
fn.name = basename+simpleName (around line 3137)

and then at the end, it calls fn.getCompiledClass() - which uses
defineClass
to create a class using the compiled bytecode and the function name.

So - it seems we need to either change this behavior to not generate
random classes (but there is probably a reason for this?), or to use
a custom classloader (seems better).

-- 
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


Re: Arithmetic operations on custom types

2011-02-28 Thread Seth
whats wrong with clojure.contrib.generic.arithmetics? Too slow? The
only other method that i know of is too :

(a). use defprotocol, but this will only dispatch on the first value
(b). use gen-class, but this require aot compilation

For the first approach, see
https://github.com/ztellman/cantor/blob/master/src/cantor/vector.clj
and
https://github.com/ztellman/cantor


And if you want to use + and * in the namespace, you can do something
like:

(ns test (:refer-clojure :exclude [+ *]))

Or, if you dont feel like doing refer-clojure every time, you might be
interested in this:
http://planet-clojure.org/page28.html
under "Computing with Units and Dimension"

-- 
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


Re: Serialising functions...

2011-02-28 Thread Seth
Notice that saving the code wouldn't work if you had locals (i.e.
clojures). On the other hand, clojures are serialized when you
serialize the function.

For example, heres some code which saves the function to a file, and
then loads it back
;
;
(def f "/home/seth/Desktop/test")
(defn get-bytes
   "convert object to byte array"
   [obj]
   (let [bytes-out (java.io.ByteArrayOutputStream.)
 out-obj (java.io.ObjectOutputStream. bytes-out)]
 (try
   (do (.writeObject out-obj obj) (.toByteArray bytes-out))
   (finally (.close out-obj)

(defn my-identity "Copies obj through serialization and
deserialization."
  [obj]
  (let [byte-out (java.io.FileOutputStream. f)
obj-out  (java.io.ObjectOutputStream. byte-out)]
(try (.writeObject obj-out obj)
 (finally (.close obj-out)))
(let [obj-in  (new java.io.ObjectInputStream
   (java.io.FileInputStream. f))]
  (try (.readObject obj-in)
   (finally (.close obj-in))
;;from debug-repl
(defmacro locals
  "Produces a map of the names of local bindings to their values."
  []
  (let [symbols (keys &env)]
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols)))


(meta (my-identity (let [a 2] (with-meta (fn [] 2) {:locals
(locals)}
;;
;;
;;


Also, it is possible to use a custom class loader - I believe
Leiningen and Cake both do this.
Leiningen, i think uses an ant class loader - see
https://github.com/technomancy/leiningen/blob/master/src/leiningen/compile.clj

For defining a classloader in clojure, take a look here
https://github.com/ninjudd/classlojure

So you might want to add to leiningen the ability to specify a
function which returns a classloader and then runs the whole project
in that classloader.  Before doing that, you can experiment with
changing the current threads classloader.

Finally, theres no reason why you couldnt change the clojure core
source to make functions serializable - it wouldnt break anything with
any other code. So, if you could figure out how to make leiningen
import  only your modified clojure core jar (instead of the regular
clojure-1.2.0.jar), it would work nicely.

-- 
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


Re: type hinting record types?

2011-02-27 Thread Seth
Maybe records shouldnt be redefined if their definition hasnt changed?

-- 
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


Re: slime warn-on-reflection?

2011-02-26 Thread Seth
Thanks! Works like a charm (except you cant turn it off - but thats
ok!)!

-- 
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


Re: type hinting record types?

2011-02-26 Thread Seth
Makes sense - I was hoping there was a way around this in which the
type hints would also work for the original class.

-- 
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


Re: type hinting record types?

2011-02-25 Thread Seth
Notice that this occurs even if i dont redefine record A - if i do
(require :reload-all 'my-namespace), any old record object will now
fail with type hinted functions.

-- 
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


type hinting record types?

2011-02-25 Thread Seth
Ive recently started type hinting - however, when I have a record of,
lets say type A, and then i change the definition of record A, all
functions which have type hinted A now fail when i pass in the old A
records that i have already defined  (cannot cast from type  A to type
A is the error message)- is this an expected behavior?

-- 
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


slime warn-on-reflection?

2011-02-25 Thread Seth
Has any gotten the warn-on-reflection to work in slime when compiling
a buffer?  Warning occur when i paste a function into the repl, but no
reflections occur when i compile a buffer or when i load the file.

-- 
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


removing primitive support 4 or less restriction?

2011-02-24 Thread Seth
I know that this has come up - but when will the  restriction of "fns
taking primitives support only 4 or fewer args" be removed?

-- 
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


Re: deploying application updates to end users

2011-02-19 Thread Seth
Permissions seem a lot of hastle - also, im using a native library the
user has to install (zeromq), so that would be even more of a pain .
But thanks for the suggestion!

-- 
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


deploying application updates to end users

2011-02-18 Thread Seth
Has anyone had any experience in the best way to deploy updates to end
users who have no programming experience? The application basically
consists of a src directory, and a bat file which runs 'lein run' to
start the program. It also consists of some extraneous files that have
to be installed on the system under another program directory.

The simplest method would be to take zip files and unzip them to the
appropriate place. But i was wondering about things like
'uninstalling' updates, automatic updates from (free hosting?)
website, better 'patch' formats, etc.

-- 
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


Re: Best method for storing dynamic data in database

2011-02-13 Thread Seth
or i could have just used base64:) I love leiningen +maven+central
repository!

(import (java.io ByteArrayOutputStream ObjectOutputStream
 ByteArrayInputStream ObjectInputStream)
org.apache.commons.codec.binary.Base64)
(defn bytes-to-obj
  "convert string to object"
  [s]
  (.readObject
   (ObjectInputStream.
(ByteArrayInputStream.
 s
(defn obj-to-bytes
   "convert object to string"
   [obj]
   (with-open [bos (ByteArrayOutputStream.)
   stream (ObjectOutputStream. bos)]
 (.writeObject stream obj)
 (.flush stream)
 (.toByteArray bos)))
(defn encode [o]
  (Base64/encodeBase64String (obj-to-bytes o)))
(defn decode [o]
  (bytes-to-obj (Base64/decodeBase64 o)))
(defmethod print-dup :default [o w]
  (.write w (str "#=(forex.module.ea/decode \"" (encode o) "\")")))

-- 
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


Re: Best method for storing dynamic data in database

2011-02-13 Thread Seth
not fast, but it works:) any ideas on better code?

;code from 
http://www.mail-archive.com/clojure@googlegroups.com/msg19378.html
;;saving objects to strings and going back -slow, but it works
(import (java.io ByteArrayOutputStream ObjectOutputStream
 ByteArrayInputStream ObjectInputStream))

(use 'clojure.contrib.duck-streams)

(defn str-to-bytes [s]
  (.getBytes s))

(defn str-from-bytes [b]
  (new String b))

; encode a raw array of bytes as a base64 array of bytes
(defn encode64 [b]
  (. (new sun.misc.BASE64Encoder) encode b))

; decode a string encoded in base 64, result as array of bytes
(defn decode64 [s]
  (let [decoder (new sun.misc.BASE64Decoder)]
(. decoder decodeBuffer s)))

(defn obj-to-bytes
   "convert object to string"
   [obj]
   (with-open [bos (ByteArrayOutputStream.)
   stream (ObjectOutputStream. bos)]
 (.writeObject stream obj)
 (.flush stream)
 (.toByteArray bos)))

(defn bytes-to-obj
  "convert string to object"
  [s]
  (.readObject
   (ObjectInputStream.
(ByteArrayInputStream.
 s

; compress human readable string and return it as base64 encoded
(defn encode [s]
  (let [b (obj-to-bytes s)
output (new java.io.ByteArrayOutputStream)
deflater (new java.util.zip.DeflaterOutputStream

  output
  (new java.util.zip.Deflater) 1024)]
(. deflater write b)
(. deflater close)
(str-from-bytes (encode64 (. output toByteArray)

; take an object that was compressed & base64 encoded.. and undo
allthat
(defn decode [s]
  (let [b (decode64 s)
input (new java.io.ByteArrayInputStream b)
inflater (new java.util.zip.InflaterInputStream
  input
  (new java.util.zip.Inflater) 1024)
result (to-byte-array inflater)]
(. inflater close)
(bytes-to-obj result)))
(defmethod print-dup :default [o w]
  (.write w (str "#=(forex.module.ea/decode \"" (encode o) "\")")))

-- 
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


Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
I know that IMeta is used with the (meta) function and with IObj, you
can also implement with-meta. And fn? tests for 'true functions' ,
i.e. only the function created by (fn). Not sure about the rest...

-- 
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


Re: Best method for storing dynamic data in database

2011-02-13 Thread Seth
any serializable java object should be supported. hmmm... i guess that
would work - simply output the object as a byte string and then decode
that.

-- 
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


Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
whats wrong with implementing Fn and IMeta?

On Feb 13, 9:35 pm, Ken Wesson  wrote:
> As for being able to attach metadata, you just have to implement IObj
> on your functoids.

-- 
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


Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
and of course i forgot to include some utility functions. oh well...

-- 
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


Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
And just for the heck of it, if anyones interested - heres the hook
code.

(ns forex.util.emacs))
(defmacro is [val & message]
  `(let [result# ~val]
 (if (not result#)
   (throw (Exception. ~(or (and (first message) `(format
~@message)) (format "assert: %s" (str val)
   result#)))

(defn fn-meta [function meta]
  (let [ns-from *ns*]
(proxy [clojure.lang.AFn clojure.lang.Fn  clojure.lang.IMeta] []
  (invoke [& args] (apply function args))
  (meta [] (merge (meta function) (merge {:ns ns-from} meta))

(defn- val-of [a] (if (var? a) (var-get a) a))
;;TODO: add log to this
(defn- apply-fn [a args]
  (try (apply (val-of a) args)
   (catch Exception e
 (println (format "error in hook %s %s: %s" a (val-of a)
e)
(defmacro- run-fn [a & args]
  `(let [a# ~a]
 (try ((val-of a#) ~@args)
  (catch Exception e# (println
   (format "error in hook %s %s: %s" a#
(val-of a#) e#))

(defn- as-ns [a]
  (condp = (class a)
  String (find-ns (symbol a))
  clojure.lang.Symbol (find-ns a)
  a))
(defn ns-metas
  ([fn] (ns-metas *ns* fn))
  ([ns fn]
 (is (as-ns ns) "%s is not a ns, or cant find it" ns)
 (let [vars (filter fn (vals (ns-interns (as-ns ns]
   (apply hash-map (interleave vars (map var-get vars))
(defn ns-vars
  ([] (ns-vars *ns*))
  ([ns]
 (is (as-ns ns) "%s is not an ns, or cant find it" ns)
 (let [vars (filter #(:var (meta  %)) (vals (ns-interns (as-ns
ns]
   (apply hash-map (interleave vars (map var-get vars))

(defmacro defvar
  ([name]
 (let [new-name (with-meta name (assoc (meta name) :var true))]
   `(defonce ~new-name nil)))
  ([name init]
 (let [new-name (with-meta name (assoc (meta name) :var true))]
   `(defonce ~new-name ~init
(defmacro defhook [& args] `(defvar ~@args))
(defmacro setq [& args]
  `(do ~@(map
  (fn [[var val]]
`(alter-var-root #'~var (fn [a#] ~val)))
  (group args


(defn- member
  ([value list] (member value list =))
  ([value list test]
 (some #(test % value) list)))

(defn- pushnew* [hook arg id replace]
  (if replace
(alter-var-root hook (fn [old]
   (doall (concat
   (list arg)
   (filter #(and (if id (not (= (:id (meta %)) 
id)) true)
(not (= % arg))) old)
(alter-var-root hook (fn [old]
   (doall (if (empty? (take 1 (filter #(or (when id (= 
(:id (meta
%)) id)) (= % arg)) old)))
(concat (list arg) old)
old))
(defmulti pushnew (fn [a b & args] [(if (fn? a) ::fn (type a)) (if
(fn? b) ::fn (type b))]))
(defmethod pushnew [clojure.lang.Var ::fn]
  ([hook function] (pushnew hook function *ns* true))
  ([hook function id] (pushnew hook function id true))
  ([hook function id replace]
 (let [new-function (if (:id (meta function)) function (if id (fn-
meta function {:id id}) function))]
   (pushnew* hook new-function id replace
(defmethod pushnew [clojure.lang.Var clojure.lang.Var]
  ([hook var] (pushnew hook var nil false))
  ([hook var id] (pushnew hook var id false))
  ([hook var id replace] (pushnew* hook var id replace)))


(defn- add-to-list* [hook arg id replace]
  (if replace
(alter-var-root hook (fn [old]
   (doall (concat
   (filter #(and (if id (not (= (:id (meta %)) 
id)) true)
(not (= % arg))) old)
   (list arg)
(alter-var-root hook (fn [old]
   (doall (if (empty? (take 1 (filter #(or (when id (= 
(:id (meta
%)) id)) (= % arg)) old)))
(concat old (list arg))
old))
(defmulti add-to-list (fn [a b & args] [(if (fn? a) ::fn (type a)) (if
(fn? b) ::fn (type b))]))
(defmethod add-to-list [clojure.lang.Var ::fn]
  ([hook function] (add-to-list hook function *ns* true))
  ([hook function id] (add-to-list hook function id true))
  ([hook function id replace]
 (let [new-function (if (:id (meta function)) function (if id (fn-
meta function {:id id}) function))]
   (add-to-list* hook new-function id replace
(defmethod add-to-list [clojure.lang.Var clojure.lang.Var]
  ([hook var] (add-to-list hook var nil false))
  ([hook var id] (add-to-list hook var id false))
  ([hook var id replace] (add-to-list* hook var id replace)))

(comment
  (defn push [var val]
(alter-var-root var (fn [it] (concat (list val) it)

(defn add-hook [hook function] (pushnew hook function))
(defn add-hooks [hook functions] (doall (map #(pushnew hook %)
functions)))

;;RUNNING hooks
(defn run-hooks [& hooks]
  (mapc (fn [hook] (mapc #(run-fn %) hook)) hooks))

(defn run-hook-with-args [hook & args]
  (mapc #(ap

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
oh, and of course the funuction needs to be executable (they are after
all just functions with metadata) - so we cant use ifn?, which would
return true on record!

-- 
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


Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
I already have code which uses fn? everywhere. So i needed to inherit
Fn interface. Adding metadata to the function (basically, an id) was a
necessary afterthought. Basically, im using an emacs like hook
interface for the gui end of my application, so its hightly
configurable - but i need to know which namespace the function can
from (or id, if supplied), so that i can overwrite the hook when
adding a hook with similar ns/id.

On Feb 13, 9:08 pm, Ken Wesson  wrote:
> On Sun, Feb 13, 2011 at 7:00 PM, Seth  wrote:
> > Cool, thats what I thought. Sometimes, i wish i could inherit from a
> > class, but then i just use proxy to do it instead :) For example, i
> > made a function which acted like a fn? , but had some metadata. At
> > first i was going to use records, but couldnt because i needed to
> > inherit from Afn, but proxies worked beautifully!
>
> If you controlled the testing code, could you have used ifn? instead
> of fn?, or would ifn? returning true on things like vectors, maps, and
> sets have caused a problem?
>
> The ifn? function tests only for the interface IFn, which deftype can
> be used to implement (and defrecord implements by default as map
> lookup).

-- 
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


Best method for storing dynamic data in database

2011-02-13 Thread Seth
I have an application which contains a number of running threads, each
which has a state to it. A state is a single record. It contains some
random stuff, but most importantly it a has a :var slot which contains
a map in which the keys are vars and the values are whatever the vars
are (if they can be dynamically updated, they are atoms/refs types
otherwise they are simple constants).

I have tried a simple print-dup method. This works fine when I dont
have java objects in it. But when i have things like DateTimes and
such, it doesnt work. On the other side of things, serializing wont
work for things like functions  (i think) that are a value  in the
map. When i print-dup, functions work fine , because they output
something like (find-symbol ). So, i need a combination of print-
dup for clojure objects and serializing for java objects.

Is there any solution out there that does this, saving it all to a
database?  I was thinking that a special record could be produced
which wraps around the clojure objects when serializing and then when
deserializing, it could do what one does with print-dup method - and
for regular java objects, simple serialization could be used.

-- 
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


Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
Cool, thats what I thought. Sometimes, i wish i could inherit from a
class, but then i just use proxy to do it instead :) For example, i
made a function which acted like a fn? , but had some metadata. At
first i was going to use records, but couldnt because i needed to
inherit from Afn, but proxies worked beautifully!

On Feb 13, 9:00 am, Stuart Sierra  wrote:
> I believe there are some technical issues with allowing re-definition of a
> class that inherits from a concrete (non-interface) superclass, but I don't
> know the details.
>
> However, it was mainly a design decision.  Clojure is opinionated, and one
> of its opinions is that concrete inheritance is bad.  It leads to problems
> like fragile base classes, and (in Java at least) it limits you to a single
> inheritance hierarchy.  Even some Java developers will even tell you to use
> inheritance only from interfaces, and put shared code into static methods
> elsewhere.
>
> -Stuart Sierra
> clojure.com

-- 
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


any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-12 Thread Seth
As the question states - why doesnt defrecord support java class
inheritence? Is it just because people think it wouldnt be 'good' or
are there true technical issues with doing it?

-- 
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


Re: Time/size bounded cache?

2011-02-06 Thread Seth
do you really need that? How about an infinite lazy sequence?
(defn infinite [arg]
  (lazy-seq
   (Thread/sleep 2000) ;;simulate 2 second retrieval time
   (concat (for [i (range 0 arg)]
 i) (infinite arg

(def a (infinite 3))
(first a) ;;=> sleep 2 seconds, return 0
(take 3 (filter #(= % 2)  a)) ;;wait a bit and return 3 twos

(loop [i 0 a (infinite 3)] ;;wait a bit, process 3 twos, and return
"done"
  (cond
   (= i 3) "done"
   (= (first a) 2) (recur (+ i 1) (rest a))
   true (recur i (rest a

-- 
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


Re: overriding seq in defrecord

2011-02-06 Thread Seth
I also found it useful to define my own clojure.core. This is because
i wanted swap! and reset! to work on my AtomHash. So i did something
like this, using clj-nstools.
http://code.google.com/p/clj-nstools/
ns+ is sort of slow for large projects, but im sure that can be
improved.

(ns clj.core
  (:refer-clojure :exclude [swap! reset!])
  (:import clojure.lang.APersistentMap java.io.Writer))

(defmulti swap! (fn [a & args] (class a)))
(defmethod swap! clojure.lang.Atom [& args]
  (apply clojure.core/swap! args))
(defmulti reset! (fn [a & args] (class a)))
(defmethod reset! clojure.lang.Atom [& args]
  (apply clojure.core/reset! args))

and then, using ns+ for another ns, we can do at the top of our file

(clojure.core/use 'nstools.ns)
(ns+ my.ns
  (:clone clj.core)
  anything else here )

Too bad something like ns+ isnt included in clojure core, its quite
useful

-- 
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


Re: overriding seq in defrecord

2011-02-06 Thread Seth
The problem is that defrecord explicitly defines the interface you are
trying to implement, so you are effectively attempting to declare the
interface twice. And since clojure.lang.seqable isnt a protocol, you
cant redefine it with extend. So, you will have to rewrite the
defrecord macro or similar that implements what defrecord does, except
it will actually look at your interfaces to see if you are attempting
to implement the same one, and then use the users interface if so.

Heres an example of a custom deftype i wrote which basically
reimplements defrecord + some more. It is an 'AtomHash', which means
it acts like a hash map (i.e. like a record),
but instead of accessing the record slots directly, it accesses an
atom, which itself contains the map. I never figured out how to make
(merge (atom-hash {:a 2}) {:a 4}) return an atom-hash, but oh well.
Actually, i think the new clojure 1.3 has internal protocols for
merge. Anyways, from this, you can build  a macro which replaces user
defined sequences with any defaults. Or you could just use it as a
template.

(deftype AtomHash [val]
  Object
  (toString [this] (str ""))
  clojure.lang.IPersistentMap
  clojure.lang.ILookup
  (valAt [this key] (get @val key))
  (valAt [this key notfound] (get @val key notfound))
  clojure.lang.IPersistentCollection
  (count [this] (.count @val))
  (empty [this]  {})
  (cons [this e]  (.cons @val e))
  (equiv [this gs] (or (identical? this gs)
   (when (identical? (class this) (class gs))
 (= val (.val gs)
  clojure.lang.Associative
  (containsKey [this k] (or (and (get @val k) true) false))
  (entryAt [this k] (get @val k))
  clojure.lang.Seqable
  (seq [this] (seq @val))
  clojure.lang.IPersistentMap
  (assoc [this k g] (assoc @val k g))
  (assocEx [this k g] (assoc this k g))
  (without [this k] (.without @val k))
  clojure.lang.IDeref
  (deref [this] @val))
;;REPLACE namespace with implementation namespace
(defmethod print-dup AtomHash [o w]
  (.write w "#=(util/atom-hash ") (print-dup @o w) (.write w ")"))

(defmethod clojure.core/print-method AtomHash [o w]
  (.write w (.toString o)))

(defn atom-hash
  ([] (atom-hash {}))
  ([a] {:pre [(map? a)]} (AtomHash. (atom a


;;examples
(let [{:keys [a b]} (atom-hash {:a 2})] (list a b))

-- 
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


Re: how to print-dup records?

2011-02-04 Thread Seth
cool! thought you had to refer or something the namespace, but i guess
the reader works differently.

changes are here
https://github.com/Storkle/defrecord2

basically, i modified it to work with print-dup and i got rid of the
pprint methods and changed the way constructor names are specified. so
now

(defrecord2 (hi my-constructor) [a b] Protocol1 )
and (my-constructor {:a 2 :b 3})

(pprint a-record) ;pprints like a normal record

but
(binding [*print-dup* true] (print-str (my-constructor {:a 2})))
will output something like this

#=(my.namespace/my-constructor .)

-- 
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


Re: how to print-dup records?

2011-02-02 Thread Seth
Ive just thought up that using print-dup for records might become a
nightmare. This is because it will now matter which ns you load it
from. If it loads an ns where the constructor function isnt defined or
isnt imported, it will throw an error. This will become a nightmare
when mixes records from various nses. A possible solution would be to
create a generic function, called new-record, which takes the ns and
the constructor function (find-ns ns-of-function function-symbol) and
then call that. Pretty simple.

-- 
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


Re: how to print-dup records?

2011-02-01 Thread Seth
Looks like it will do!
One change, though, that I made for myself  is that
(defrecord2 (name constructor-name) [args] Protocol1 ...)
so you can do protocols
or (defrecord2 name [args] Protocol1...) for default

-- 
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


how to print-dup records?

2011-01-31 Thread Seth
This is my attempt:

(defn record? [a]
  (and (map? a) (not (instance? clojure.lang.APersistentMap a

(defmethod print-dup clojure.lang.IPersistentMap [m, ^Writer w]
  (if (record? m)
(do (.write w "#=(")
(print-dup (class m) w) (.write w ". ")
(doall (map #(do (print-dup % w) (.write w " ")) (map second (seq
m
(.write w ")")
)
(do
  (#'clojure.core/print-meta m w)
  (.write w "#=(")
  (.write w (.getName (class m)))
  (.write w "/create ")
  (#'clojure.core/print-map m print-dup w)
  (.write w ")"


;;used from 
http://groups.google.com/group/clojure/browse_thread/thread/cb5246d07142a3dc?fwc=2&pli=1
(defn frm-save
 "Save a clojure form to file."
  [file form]
  (with-open [w (java.io.FileWriter.
 (if (instance? File file) file (File. file)))]
(binding [*out* w *print-dup* true] (prn form

(defn frm-load
  "Load a clojure form from file."
  [file]
  (with-open [r (java.io.PushbackReader.
 (java.io.FileReader. (if (instance? File file) file (File.
file]
 (let [rec (read r)]
   rec)))



However, it appears that the reader cant read classes
For example

(defrecord Foo [a])
(frm-save "/home/seth/Desktop/test" (Foo. 2))
(frm-load "/home/seth/Desktop/test")

Another problem is that it saves it as the ns it is in, for example my-
ns.Foo, and when you reload it it wont find my-ns.Foo unless you have
required it. But, editing the test file to just output

#=(#=foo. 2 3 )

and then loading that throws a class not found exception.

Any general way to print-dup these records?

-- 
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


Re: best way to define alias for all publics in ns?

2011-01-19 Thread Seth
The core actually wouldn't have to be modified, as it already does
something similar. After all, the function 'use' already does it - if
we 'use' error-kit, it adds to the symbol map (seen by (ns-refers
*ns*)) a map from the symbol to the actual var in error-kit. Thus, in
ns A where we have used error kit, evaluating #'handle  will actually
give us as a return value of #'clojure.contrib.error-kit/handle
because the symbol handle refers to the other ns's var.

The only problem is the import one - 'use' only imports vars which
actually belong to the ns you are using. We want it to not only import
public vars, but also to 'refer' certain vars which we also want to
export. So, the simple solution would be to tag the symbol in our ns
with special metadata, maybe an 'export' key, and then write another
function which does what 'use' does but also refers vars which have
the 'export' metadata.

Personally, i think the use function in the core should be rewritten
to consider two things when importing vars:
(1) if the symbol belongs to the ns you are using, then refer it
(2) if the symbol has  :export in the symbols metadata, then also
refer it.

-- 
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


Re: best way to define alias for all publics in ns?

2011-01-18 Thread Seth
Theres a subtle problem here that makes both solutions not work in
some cases.
I am trying to reexport error-kit, and it makes use of a var #'handle,
and in the macro with-handler, it tests if there is a handle  = to
#'handle. If you define a var in your own namespace named handle, it
will of course not be equal to #'clojure.contrib.error-kit/handle.
When you 'use' error-kit, it maps from the symbol handle to the
#'clojure.contrib.error-kit/handle , so everything works. However, all
exports from your namespaces have to have a (.ns var) = to the current
namespace - a clear contradiction. Therefore, it is not possible to
use the function 'use'. One would have to create a different function
to get this to work - maybe put a 'export' metadata and have the new
use function search for that.

On Jan 17, 10:12 pm, Ken Wesson  wrote:
> On Mon, Jan 17, 2011 at 10:47 PM, Seth  wrote:
> > if you 'use' ns A in ns B, ns C which uses B will not see the
> > functions of A. Im trying to create a ns which collects functions from
> > various other ns and exports them so that all you have to do is use
> > that one uber ns.
>
> And, Clojure being a language with good meta facilities, you figured
> it ought to be as easy as
>
> (ns uber-ns
>   :use (other-ns yet-another-ns))
>
> (foo other-ns)
> (foo yet-another-ns)
>
> for some choice of "foo".
>
> I'd figure something like this might work:
>
> (defn make-def [name value]
>   `(def name value))
>
> (defmacro foo [target-ns]
>   `(do
>      ~@(map
>          #(make-def % (symbol (str target-ns "/" %)))
>          (get-all-public-symbols target-ns
>
> given an implementation of "get-all-public-symbols" that, given a
> namespace *symbol* and *at macroexpansion time*, produces a seq of the
> symbols of public vars in that namespace; so if called on the symbol
> 'clojure.core it would produce something like ('condp 'for 'map 'doall
> 'println 'seq ...) and foo would produce something like (do (def condp
> clojure.core/condp) (def for clojure.core/for) ...).
>
> Making foo copy the metadata of the var as well as the value is left
> as an exercise for the reader. As is implementing
> get-all-public-symbols.

-- 
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


Re: best way to define alias for all publics in ns?

2011-01-17 Thread Seth
if you 'use' ns A in ns B, ns C which uses B will not see the
functions of A. Im trying to create a ns which collects functions from
various other ns and exports them so that all you have to do is use
that one uber ns.

-- 
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


Re: best way to define alias for all publics in ns?

2011-01-17 Thread Seth
woops, mistake

(defn ns-export [from-ns]
  (count (doall (map (fn [[sym var]]
   (let [v (if (.hasRoot var)
 (var-get var))
 var-obj (if v (intern *ns* sym v))]
 (when var-obj
   (alter-meta! var-obj
(fn [old] (merge (meta var) old)))
   var-obj)))
 (ns-publics from-ns)

-- 
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


best way to define alias for all publics in ns?

2011-01-17 Thread Seth
I have this function which takes all of the publics from one ns and
exports them in the current ns. My question is, is this the best way
to do it? Is there another method which doesnt use eval? I know eval
is supposed to be  'evil ' :)

(defn ns-export [from-ns]
  (map (fn [[sym var]]
 (let [v (if (.hasRoot var)
   (var-get var))
   var-obj (if v (intern *ns* sym v))]
   (when var-obj
 (alter-meta! var-obj
  (fn [old] (merge (meta var) old)))
 var-obj)))
   (ns-publics from-ns))
  true)

(defmacro eval-when [& args]
  (eval `(do ~@args)) nil)

(eval-when
 (require 'clojure.contrib.error-kit)
 (ns-export (find-ns 'clojure.contrib.error-kit)))

-- 
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


Re: map destructuring with defaults

2011-01-06 Thread Seth
Ah. But a new map is being created with the default :or operation. I
guess the ability to get this entire map with defaults is not
available directly from clojure destructuring binding.

-- 
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


Re: Knuth's literate programming "tangle" function in Clojure

2011-01-05 Thread Seth
Now that i think of it, it is mostly a fear of having decreased
productivity in writing code that affected my statement that i liked
the little files. Im used to, i suppose, developing code for a
specific function in a file, being able to compile, goto line numbers
where there are errors,
send code to slime, etc. Looking over your example made things much
clearer. Its like your guiding your reader to specific parts of the
'little files', describing the theory behind them, moving on, etc. And
each code fragment has a chunk name associated with it, and all of
them are combined into the final .clj file using the code fragment
names (in a separate chunk).

At first, i thought this would be less productive than simply putting
all of the code in one clj file, but now that i think about it i think
it would, with the appropriate tools. And it wouldn't even be too
difficult, with org-mode (prefer it over latex any day!)

Im going to start transferring a subsection of my program to literate
programming, using org-mode. See how it goes...

Oh, and Tim, you might want to take a closer look at org-mode. Instead
of having to tangle out the code that builds everything, you could
create an executable shell script block in org-mode - the makefile
script could be tangled into a string using noweb syntax, and then
everything could go from there. You can execute the block by hitting C-
c c-c in the org file (or something like that). Pretty cool, in my
opinion!

-- 
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


Re: Knuth's literate programming "tangle" function in Clojure

2011-01-05 Thread Seth
>Just discovered org-mode myself --- does anyone know of guide to using
>it with clojure for a total newbie?

I havent actually used it for clojure per se. I was just imagining how
it could be used. You have the ability to embed arbitrary code (from
many different languages). You can edit the code in its own emacs
major mode and then it will automatically be saved back once done. You
can then document it using org-modes awesome abilities.
However, this is sort of clumsy.

I would rather be able to have all of my code in all of its 'little
files' arranged in directories. And when im editing the clojure files,
i would like to be like 'oh, i want to document this better/introduce
the motivation etc! And then automatically have the code, or parts of
the code, copied to the org file and then i could document it. And
then jump back to the code to continue developing. And have changes in
the clojure file automatically reflected in the org file. I was
thinking that 'chunk' labels could be embedded in the source code
(like in marginalia in github: just comments like ;;##Block Name) so
that we wouldn't have to have all code in one file in one chunk, but
could split it up.

-- 
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


Re: Knuth's literate programming "tangle" function in Clojure

2011-01-05 Thread Seth
The literate programming is actually a contrib to org-mode.
http://orgmode.org/worg/org-contrib/babel/

Ive actually used it to create my emacs.el, by having code in
emacs.org and have init.el tangle out the emacs code. Of course i
never documented
anything and did it for the novelty of being able to organize all that
code in one file, instead of expanding it to other files :)

-- 
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


map destructuring with defaults

2011-01-04 Thread Seth
Is there any way to get the entire map when destructuring plus the
defaults?
(let [{:keys [a] :or {a 4} :as b} {:b 3}] b)
returns {:b 3}

but i would like it to return {:b 3 :a 4}

-- 
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


Re: Knuth's literate programming "tangle" function in Clojure

2011-01-04 Thread Seth
have you guys checked out org-mode + babel for emacs? This would be an
excellent place to start  to do literate programming. Interesting
ideas ... maybe i will try this in my own 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


Re: pods?

2010-12-24 Thread Seth

> It's planned to be new reference type, which handles transients inside. So 
> you send it functions living over transients for update. On deref the pod 
> automatically converts things back into a persistent value. So updates will 
> be fast, but things are transparently switched back to Clojure-style for you. 
> Pods allow also for different strategies of update. At the moment transients 
> are locked into one thread. But with pods this could be changed. Also – like 
> Refs – you can modify several pods at the same time with a consistent 
> snapshot. The pods take care of locking for you.


Is there any code for it yet?

-- 
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


pods?

2010-12-23 Thread Seth
I am interested in the references to pods that are floating around the
internet. However, when i downloaded the github master repository, i
couldn't find pod anywhere. Of course there are 17 other branches...
Clojures support for mutable multithreading is great if there are no
side effects, but sometimes there have to be side effects - and i find
myself resorting to locking. Can anyone give any reference to the code
for pods/give any explanation?

-- 
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


Re: Calling methods with a dollar sign in them

2010-12-22 Thread Seth
ok, thats what i thought. Any change of a literal syntax for symbols
like in lisp, |symbol|??

-- 
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


Re: Calling methods with a dollar sign in them

2010-12-21 Thread Seth
oh, and the public var is defined as private in the .class file, so i
can't use set!

-- 
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


Calling methods with a dollar sign in them

2010-12-21 Thread Seth
I am attempting to interop with scala. In scala, if you have a class
which is a var, a method is defined in the .class file called varname_
$eq  which will set the var. Problem is, clojure apprent converts
dollar signs to the text  _DOLLARSIGN_. Is there any way to prevent
this?

-- 
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


Re: using swig in clojure

2010-11-19 Thread Seth
unfortunately doesnt work. The library loads succesfully but i still
get the error when calling add. Note that compiling on the top is a
workaround to get it working on the repl.

i added the loadlibrary to an init function which is good and i
decided to ahead of time compile it - and it worked! I could call
(init) and then add, without getting a link error!

The question is why do i need to ahead of time compile this code to
get it to work? Any ideas?

-- 
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


Re: Reloading java classes

2010-11-04 Thread Seth
All i need to do is a function to reload a class I specify, nothing
fancy. Surely there is some way?

-- 
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


using swig in clojure

2010-11-04 Thread Seth
Ive recently had troubles using swig in clojure getting a 'unsatisfied
link exception' even though using the swig generated library worked in
regular java code. I believe there was a post on this somewhere in
these google groups.

Anyways, I have figured out that if I place the following code in a
clojure file (test.clj)
(System/loadLibrary "Seth")

and go (compile 'test) on the REPL, i get


No such file or directory
  [Thrown class java.io.IOException]

Restarts:
 0: [QUIT] Quit to the SLIME top level

Backtrace:
  0: java.io.UnixFileSystem.createFileExclusively(Native Method)
  1: java.io.File.createNewFile(File.java:900)
  2: clojure.lang.Compiler.writeClassFile(Compiler.java:5885)
  3: clojure.lang.Compiler.compile(Compiler.java:6043)
  4: clojure.lang.RT.compile(RT.java:368)
  5: clojure.lang.RT.load(RT.java:407)
  6: clojure.lang.RT.load(RT.java:381)
  7: clojure.core$load$fn__4511.invoke(core.clj:4905)
  8: clojure.core$load.doInvoke(core.clj:4904)
  9: clojure.lang.RestFn.invoke(RestFn.java:409)
 --more--




However, afterwards i can succesfully do
(import Seth)
(Seth/add 2 3) => 5

I cant do the loadlibrary thing on the repl, or it wont work (i get
the 'unsatisfied link error' when calling (Seth/add)).  Notice that if
I do (compile 'test) again i get the same error above, which is
weird because if i do (System/loadLibrary "Seth") on the repl i get
the 'expected' error

Native Library /home/seth/.random/java/libSeth.so already loaded in
another classloader
  [Thrown class java.lang.UnsatisfiedLinkError]

Restarts:
 0: [QUIT] Quit to the SLIME top level

Backtrace:
  0: java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1715)
  1: java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
  2: java.lang.Runtime.loadLibrary0(Runtime.java:840)
  3: java.lang.System.loadLibrary(System.java:1047)
  4: user$eval1825.invoke(NO_SOURCE_FILE:1)
  5: clojure.lang.Compiler.eval(Compiler.java:5424)
  6: clojure.lang.Compiler.eval(Compiler.java:5391)
  7: clojure.core$eval.invoke(core.clj:2382)
 --more--




Anyone know whats going on and how this can be fixed?

-- 
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


Reloading java classes

2010-11-03 Thread Seth
Is it possible to reload modified classes? I would likely to quickly
test my java classes with clojure.

-- 
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


Best syntax for clojure-clr generics

2010-10-18 Thread Seth
I would like to start a discussion on the best syntax for clojure-clr
generics because in most large pieces of software on CLR you have to
specify types to create generic classes. Heres my proposal.

<> Reader macro expands to the macro g
example:

(AGenericClass.  arg1
arg2)
expands to
(AGenericClass. (g Double Integer (a-form-which-returns-class) arg1
arg2)
expands to
(AGenericClass. (#generic-id-gen-symbol Double Integer ...) ...)

and the . operator will look for the #generic-id-gen-symbol as the
first argument and will then realize it must create a generic class,
the symbol would be invalid in any other place. Or maybe the <> would
add metadata to the object, and the . macro could access this metadata
to determine if it needs to create a generic?

I think the <> Syntax would be the easiest and most convenient to use.

Any opinions or other suggestions?

-- 
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


Re: Conj arrivals and Thursday night...

2010-10-18 Thread Seth
What's this about an after party?

On Oct 18, 5:59 pm, Eric Lavigne  wrote:
> > Hey Conj goers,
>
> > I'm scheduled to arrive around 6:30, and after I check in am planning
> > to spend the rest of the night writing code. Anyone want to help
> > commandeer a random lobby to join in on the fun?
>
> > Andrew
>
> Count me in. Sounds like a great way to kick off the conference. My
> plane gets in at 1:39, so I can also meet earlier if anyone is up for
> it.
>
> Also looking for a Saturday evening activity, since the after-party
> ran out of tickets so quickly. Am I the only Clojurian who didn't
> check for new mail between 1:22pm and ~4pm, or are there just a lot
> more Clojurians than I imagined? :-)
>
> Looking forward to meeting everyone in a few days!
>
> Eric Lavigne
> 352-871-7829http://twitter.com/ericlavigne
> lavigne.e...@gmail.com

-- 
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


Re: The vsClojure Project

2010-10-03 Thread Seth
Yay! Following.

On Oct 2, 9:33 pm, jmis  wrote:
>         I'd like to announce my Visual Studio 2010 Clojure extension project,
> vsClojure.  The extension is not yet complete but provides a base for
> further enhancements.  Currently, it supports syntax highlighting,
> auto-indentation, brace matching, a Clojure project type, repl
> support, and a few other minor features.  If you're curious you can
> give it a try, contribute, or just check it out at GitHub (http://
> github.com/jmis/vsClojure).
>
> Thanks,
> jmis

-- 
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


Re: how to use leiningen install

2010-09-12 Thread Seth
take that back, all i had to do was go to project.clj and remove the
offending entry!

-- 
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


Re: how to use leiningen install

2010-09-12 Thread Seth
tried it out, looks good! except i accidently broke it by doing
cljr install /home/seth/.m2/helloworld 0.1, from then on it didn't
work so i had to reinstall it :(

(i though i could directly give address to repository)

-- 
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


Re: how to use leiningen install

2010-09-12 Thread Seth
Woops, i left out a 0 on the version number, so i did ".1" instead of
"0.1"!  Now it works!

Also, is there any way to use a library from the local maven
repository in a fresh clojure repl. By fresh, i mean i have set up
emacs to run a new clojure repl not related to previous projects. Is
there any way so that all libraries in the local maven repository are
located in the java class loading path so i can do (import
'helloworld).

-- 
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


how to use leiningen install

2010-09-11 Thread Seth
Im attempting a 'hello world' leiningen in which i install a simply
hello world library using lein install and then i create a new
project , hello2, which depends on that project. However, leiningen
does not seem to look in the local maven repository for the
dependencies so i get

1) helloworld:helloworld:jar:.1

  Try downloading the file manually from the project website.

  Then, install it using the command:
  mvn install:install-file -DgroupId=helloworld -
DartifactId=helloworld -Dversion=.1 -Dpackaging=jar -Dfile=/path/to/
file

  Alternatively, if you host your own repository you can deploy the
file there:
  mvn deploy:deploy-file -DgroupId=helloworld -
DartifactId=helloworld -Dversion=.1 -Dpackaging=jar -Dfile=/path/to/
file -Durl=[url] -DrepositoryId=[id]

  Path to dependency:
1) org.apache.maven:super-pom:jar:2.0
2) helloworld:helloworld:jar:.1



Is there any way to get lein to look at the local repository?

-- 
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


how to use leiningen install

2010-09-11 Thread Seth
Im attempting a 'hello world' leiningen in which i install a simply
hello world library using lein install and then i create a new
project , hello2, which depends on that project. However, leiningen
does not seem to look in the local maven repository for the
dependencies so i get

1) helloworld:helloworld:jar:.1

  Try downloading the file manually from the project website.

  Then, install it using the command:
  mvn install:install-file -DgroupId=helloworld -
DartifactId=helloworld -Dversion=.1 -Dpackaging=jar -Dfile=/path/to/
file

  Alternatively, if you host your own repository you can deploy the
file there:
  mvn deploy:deploy-file -DgroupId=helloworld -
DartifactId=helloworld -Dversion=.1 -Dpackaging=jar -Dfile=/path/to/
file -Durl=[url] -DrepositoryId=[id]

  Path to dependency:
1) org.apache.maven:super-pom:jar:2.0
2) helloworld:helloworld:jar:.1



Is there any way to get lein to look at the local repository?

-- 
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


Re: lisp error system in clojure

2010-09-09 Thread Seth
exact what i want!
Heres a nice link which describes it

http://pragprog.com/magazines/2009-07/when-things-go-wrong

On Sep 9, 6:20 am, Meikel Brandmeyer  wrote:
> Hi,
>
> On 9 Sep., 05:31, Seth  wrote:
>
> > Is there any code out there which reproduces common lisp's restart
> > error handling capabilities?
>
> I think clojure.contrib.error-kit is the closest approach.
>
> Sincerely
> Meikel

-- 
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


lisp error system in clojure

2010-09-09 Thread Seth
Is there any code out there which reproduces common lisp's restart
error handling capabilities?

-- 
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


Re: Is it possible in theory to write/modify a Clojure compiler that doesn't

2010-08-28 Thread Seth
This sounds very similar to groovyc: 
http://groovyland.wordpress.com/2009/03/03/groovyscalajava/

On Aug 28, 12:50 pm, Luke VanderHart 
wrote:
> For the past week or two, I've been investigating what it would take
> to write something that would allow *.clj  and *.java files to
> seamlessly compile together, such that they could be freely intermixed
> in a project. I knew it was a difficult problem, but I think the
> adoption benefits would be substantial, and the benefits huge for
> those stuck in Java-land at work.
>
> My conclusion (and *please* tell me if I'm missing something) is,
> unfortunately, that the problem requires full compiler support from
> both ends. Either a new compiler needs to be written that can compile
> both Clojure and Java, or the existing Java/Clojure compilers need
> some fairly extensive patching to make this possible, to share a
> dependency graph and symbol tables.
>
> The exception would be if it were possible to simply "pass through"
> class references when compiling *.clj files to *.class files, and not
> resolve them until run-time (or perhaps a seperate "resolution" phase
> of the compile process, for more compile-time safety). I realize this
> can't be done for dependencies between Clojure source files, since
> macro definitions are required at compile time. But is there any
> reason you couldn't do this for Java references from Clojure files?
>
> Then, it'd be very easy - just compile all the Clojure, put the
> classes in the classpath, and compile the Java.
>
> Any thoughts?

-- 
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


Re: What is the best way to parasitically invade a java project with clojure goodness?

2010-08-23 Thread Seth
Going from Java to Clojure isn't quite as easy as going the other way,
as @brweber2 demonstrated at the local Clojure meetup. Here's the code
he used in the presentation, might send him a direct message on
Twitter for more info:

http://github.com/brweber2/javacallclj


On Aug 22, 7:48 pm, Robert McIntyre  wrote:
> Let's say my group has a fairly large java project on which ~20 people
> are working.
> We want to start using clojure with our existing code.
>
> Specifically, we want to have clojure classes that provide functions
> for our java classes, and vice versa.
>
> Two questions on the best way to do this:
>
> (:1 Should the clojure source files intermingle with the java source files,
> each according to it's relavance to the problem, or should there be a top
> level separation between them?)
>
> (:2 Say I have this:
>      English.java --- which defines some cool data structure
> representing English sentences
>      Chinese.java --- same as above except for Chinese.
>      awesome-junk.clj --- which provides unthinkably cool AI functions
> that map English objects to Chinese objects. This is AOT compiled so
> other things can use it.
>      PainstakinglyMadeGUI.java --- which provides an awesome GUI that
> uses the English and Chinese objects and calls the functions provided
> by awesome-junk.
>
> Now, how can I build this project from nothing!?
> You can't compile all the java objects first, because they need
> awesome-junk.clj.
> You can't compile awesome-junk first, because it needs Chinese and
> English class files to exist.
> What do you do?  What if you have 20 java files and 20 clj files that
> all depend on each other in interesting ways?
> This isn't a problem with pure java because you just throw them all
> together "at-once" and let javac sort em' out.
> Can it be just as easy with a heterogeneous mix of files? (maybe with
> an eclipse plugin or something?))
>
> --Robert McIntyre

-- 
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


Re: More urgency for CinC & CLR given Oracle's lawsuit against Google?

2010-08-13 Thread Seth
Sorry all -- I think my original message went slightly awry. The
announcement was a shock and quickly followed by waves of grumbling
from devs I follow on Twitter. While it's easy to extrapolate the
future from Oracle's past and this announcement, it's not necessarily
useful or accurate to do so. I never suspected Clojure to be in any
mid-term jeopardy. But it did seem like a good opportunity to stoke
the CinC and CLR topics and see if there was a big change in the level
of interest. Apparently not, and that's probably prudent.

That said, I personally am now more interested in better CLR support
for Clojure. While it's not a strength of mine, I'm sure I will find
some way to contribute to that.

Sorry again for any off topic churning, and here's hoping the JVM will
continue to be a good place for Clojure to be for quite some time.

Seth

On Aug 13, 4:06 pm, Mike Meyer  wrote:
> On Fri, 13 Aug 2010 23:08:40 +0400
>
> Mikhail Kryshen  wrote:
>
> > I doubt it is possible to create runtime like JVM or CLR without patent
> > problems.
>
> Given that virtual machine technology "like"(1) the JVM and CLR have
> been around since the 70s - long before even C++ ++ -- was a gleam in
> Gosling's eye - I'm pretty sure it's possible to create a runtime
> "like" the JVM or CLR that has no insurmountable patent
> problems. Sure, Oracle can create problems for anyone implementing a
> VM by suing them, but if you started with something like either the
> UCSD P-Machine VM or a SmallTalk VM (Squeak, maybe?) - which Gosling
> cites as inspirations for the JVM (2) - such suits are clearly
> baseless, as the technology is obviously prior art. So it can't
> infringe the patent, only invalidate it.
>
>        
> *) This all depends on exactly what you mean by "like". Gosling and
> the Java group at Sun are sharp people, I'm sure they added ideas that
> were patentable, and probably even worth granting a patent to. If
> "like" includes "having patented feature foo", then foo may be missing
> from the VMs that are prior art, so they aren't "like" JVM or CLR. But
> just having a portable VM also qualifies as "like" JVM in some sense.
>
> 1)http://queue.acm.org/detail.cfm?id=1017013
> --
> Mike Meyer           http://www.mired.org/consulting.html
> Independent Network/Unix/Perforce consultant, email for more information.
>
> O< ascii ribbon campaign - stop html mail -www.asciiribbon.org

-- 
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


More urgency for CinC & CLR given Oracle's lawsuit against Google?

2010-08-13 Thread Seth
Given Oracle's lawsuit against Google for its use of the JVM, is
anyone else suddenly much more concerned about the states of Clojure
in Clojure and CLR compatibility? I know the former is an important
goal and also that the existence of the latter is due to heroic
volunteer efforts on behalf of a small number of people. Frankly I've
been sitting on the sidelines cheering the efforts on.

But now I'm much more concerned about writing Clojure code that can
only run as Oracle sees fit. I've got a small bit of code which needs
OpenJDK on an Linux Amazon EC2 instance. What will the Oracle scry of
that?

If it sounds like I'm stirring up FUD I apologize, it's not my intent.
Oracle has its fiduciary responsibilities and the patent system is
what it (sigh) is.

Here's my ideal option: a production quality release of Clojure
targeting the CLR before the first anniversary of SCOracle day
(2010-08-12). This would have to be an organized effort since big
meaty chunks like CinC are probably within scope of only a few
Clojurians (i.e. not me).

Just my personal opinion -- questions, comments, and corrections are
welcome.

Seth

-- 
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


Re: Building mixed clojure and java code

2010-07-14 Thread Seth
It appears that lein-javac is not compatible with Leiningen 1.2.0-RC2:

% lein compile-java
[...]
Exception in thread "main" java.lang.Exception: Unable to resolve
symbol: make-path in this context (compile_java.clj:10)

On Jul 14, 9:19 am, Moritz Ulrich 
wrote:
> There is lein-javac which integrates javac into the leiningen
> build-flow:http://github.com/antoniogarrote/lein-javac
>
>
>
>
>
> On Wed, Jul 14, 2010 at 3:16 PM, Martin DeMello  
> wrote:
> > On Wed, Jul 14, 2010 at 6:45 PM, Martin DeMello  
> > wrote:
> >> What are people using to build mixed clojure/java code? Currently just
> >> using lein {uber,}jar to build and distribute.
>
> > Hit send too soon - I meant to say, currently my project is just
> > clojure, and lein works very nicely to package it. If I wanted to
> > include some java sources, what would the easiest way to build the
> > combined project be?
>
> > martin
>
> > --
> > 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
>
> --
> Moritz Ulrich
> Programmer, Student, Almost normal Guy
>
> http://www.google.com/profiles/ulrich.moritz

-- 
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


Re: Any Clojure job out there?

2010-04-19 Thread Seth
It's not Clojure specific but I've seen a few mentions of it on
http://lispjobs.wordpress.com/

RSS feed: http://lispjobs.wordpress.com/feed/

On Apr 18, 12:59 pm, Nicolas Buduroi  wrote:
> Hi, I've been having lots of fun in the past months working in Clojure
> only on my own time and wonder if there's opportunities to be paid for
> it. Our community is growing everyday and I've heard that Clojure is
> being more and more used in the real world. So, is there any job
> opening for us Clojurians?
>
> P.S.: I don't want this post to be just for me, so I encourage you to
> post job offers from anywhere even if you're not searching for
> telecommuters. BTW, I'm in Montreal.
>
> Thanks
>
> --
> 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 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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


Re: New Recruit

2010-04-18 Thread Seth
Since you are really interested in both Clojure and statistics, might
I recommend two RSS feeds:

* The Incanter RSS feed -- you might already have this but just in
case. @liebke pays close attention to documentation in Incanter and as
well as comments to the blog.

http://incanter-blog.org/feed/


* Bradford Cross (@bradfordcross) is a major player in FlightCaster
which is using Incanter in production. Actually, I wonder how the
Icelandic eruption outlier is screwing with their predictions. Maybe
they've taken the once-a-century periodic catastrophe into
consideration. Either way, the blog is math-heavy with a good
conversational tone.

http://measuringmeasures.com/blog/atom.xml


* Actually one more link, but I couldn't find an RSS feed. Clojuratica
weds Clojure and Wolfram Mathematica:

http://groups.google.com/group/clojuratica


I hope you get a lot out of Clojure -- it's a great language.

On Apr 18, 10:54 am, llcawthorne  wrote:
> Hello!
>
> I normally lurk on lists a bit before introducing myself (if I ever
> introduce myself), but I just wanted to say hello; especially since it
> tends to take a little bit to ascertain the norms on any given list,
> but what the heck, eh?
>
> I saw Aaron Bedra's presentation on Clojure at the POSSCON in
> Columbia, and decided I could no longer put off learning more about
> Clojure.
>
> Clojure, Clojure-contrib, Compojure and Incanter installed easily
> enough on my machines last night after the conference.  Incanter looks
> neat; I always meant to learn R when I took STAT 509 (Statistics for
> Engineers) but never got around to it, and it was not required by the
> course.
>
> I am a student with a bit of experience in Haskell and Scheme and have
> used more than I care to of Java due to the cirriculum, so Clojure
> seems to roll up a lot of this previous work into a package and push
> in some as yet to be .  In my free time over the summer I hope to
> continue my explorations solo, keep an eye on the list, and maybe end
> up bugging y'all with questions when I run into them.
>
> Lewis Cawthorne
>
> --
> 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 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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


Re: Choosing a Clojure build tool

2010-03-25 Thread Seth
I am in complete agreement! Clojure continues to hinder itself by not
providing an official executable. java -cp clojure.jar was good enough
for Clojure 0.9, but that's not where it is anymore.

Even simple things like submitting bug reports would be helped by
having a default "clj" executable. It would avoid a lot of questions
about system configuration when reporting a bug.

So many people and projects have RE-implemented a "clj" script!

Seth

On Mar 25, 5:32 pm, "Heinz N. Gies"  wrote:
> On Mar 25, 2010, at 19:55 , Chas Emerick wrote:
>
> > I published a blog post earlier today, along with a short screencast that 
> > might be of interest:
>
> > "Like any group of super-smart programmers using a relatively new language, 
> > a lot of folks in the Clojure community have looked at existing build tools 
> > (the JVM space is the relevant one here, meaning primarily Maven and Ant, 
> > although someone will bark if I don't mention Gradle, too), and felt a rush 
> > of disdain. I'd speculate that this came mostly because of XML allergies, 
> > but perhaps also in part because when one has a hammer as glorious as 
> > Clojure, it's hard to not want to use it to beat away at every problem in 
> > sight."
>
> I slowly get the feeling that build tools are too much in the focus. Why 
> don't we start up with a good shell integration, being able to run clj  script> go nice and including dependencies in jars and stuff.
>
> Making it easy to work with plain .clj files to include, load, run them would 
> get us a huge way ahead and I think kind of freeing us from what I feel as 
> the burden of the java world.
>
> Regards,
> Heinz

-- 
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

To unsubscribe from this group, send email to 
clojure+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Why I have chosen not to employ clojure

2010-03-21 Thread Seth
I hate to feed trolls, but this is a solid example of passive-
aggresive behavior. Also, ignoring plausible sounding, spell-checked
diatribes is bad.

The installation of one or two jar files from a Maven repository is
par for the JVM course. Deployment? Works on any reasonable JVM out
there. Could the install/deploy behavior be improved? Sure, but try
targeting something less ubiquitous than "ant". Slackware more modern
than Ubuntu??

Contrasting Clojure with Flash on Ubuntu really takes the cake. Flash
has never had a good reputation outside of Windows. Also, either the
poster is running as root (!) or has somehow forgotten a very
important su/sudo between steps 2 and 3. Either way, no sysadmin has
to be convinced.

Wresting with pigs is bad because you get dirty and the pig likes it.

On Mar 21, 2:42 pm, Tim Johnson  wrote:
> I have evaluated clojure for the last couple of days, and it is both my own
> professional decision and my recommendation to the professional organizations
> that I belong to and report to that clojure is not ready for prime time.
>
> Before any of you think that I am a disgruntled newbie turned troll, know
> the following:
>
> 1)As soon as I see the copy of this email in my "clojure mailbox", I will
> unsubscribe from this mailing list, delete the clojure mailbox and I will not
> be following up in any way.
>
> 2)In as much as clojure is a new programming language with a small but
> enthusiastic user base and a brilliant developer I confess to a certain deja 
> vu
> here. That would be rebol 10 years ago. Brilliantly conceived, brilliantly
> designed by one of the best programmers on the planet. Never went anywhere.
> I've used rebol for 10 years steadily and made a lot of money with it, but
> there is almost 0 demand for rebol programmers out there.
>
> 3)Although I may be a noob with it comes to clojure and even more of a noob
> when it comes to java, I have been a professional analyst and programmer for 
> 21
> years and own my own company. Many seasoned programmers, analysts and system
> adminstrators look at a new system as something to "employ". As a front end 
> for
> java, I do not consider clojure to be "employable".
>
> I think that clojure is brilliantly conceived and it is clear from what I have
> read of Rich Hickey's words that his vision is right in the same channel with
> mine, but that is not the problem. The fact that I respect the developer and
> the product is the reason that I have taken this time to write this email.
>
> The reason I choose NOT to employ clojure can be summed up in three words.
> ---
> Install and deploy.
> ---
>
> I consider this to be clojure's fatal weakness. Certainly I can get clojure up
> and running, but "selling" clojure to a sysadmin is going to be a problem at
> this time. There was a time when PHP was NOT present on virtually all 
> webservers.
> PHP got it's "foot in the door" because it was very easy to deploy.
>
> Consider the two threads that I started up - one is titled "Web programming in
> Clojure" - there's the good stuff. Generous reponse, lots of input.
>
> The other one is titled "Installation issues on slack 13.0 (ant?)". This where
> it all falls apart.
>
> Sadly, this is like the first impression and we all know how lasting first
> impressions are. In fact as you can see, the thread ended with no resolution.
> I'm sorry to pick on "steve" but his response is a case study
>
> * Steve  [100320 05:24]:
>
> > Reading the getting started page on the website will get you further
> > still :http://clojure.org/getting_started
>
> Sadly inadequate! Check out the comparable kawa resources and instructions for
> a better example.
>
> > If you do need ant then a more modern distro will make your life much
> > easier (eg. apt-get install ant).
>
> Again, so inadequate. I also use ubuntu. Have for years. apt-get is a thing
> of beauty. When it works. And bye the way, slackware is much more modern
> when it comes to up-to-date build tools. So know I not only have to "sell"
> clojure to the sysadmins, I have to sell them ubuntu too? Good luck with
> that!
>
> Here's how I installed the flash player on my system.
> 1)Downloaded install_flash_player_10_linux.tar.gz
> 2)Unzipped libflashplayer.so
> 3)Copied to /usr/lib/firefox-3.5.2/plugins/
>
> Make clojure "install and deployment" like the example above and more of us 
> will
> EMPLOY clojure and 10 years from now there WILL be a market for clojure
> programmers.
>
> Goodby and good luck.
> --
> Tim
> t...@johnsons-web.comhttp://www.akwebsoft.com

-- 
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

Re: Swank, ELPA and Emacs version do you use?

2010-03-20 Thread Seth
M-x version

GNU Emacs 23.1.1 (i386-apple-darwin9.8.0, NS apple-appkit-949.54) of
2009-08-16 on black.local

Most of my configuration comes from the Emacs Stater Kit:
http://github.com/technomancy/emacs-starter-kit

On Mar 20, 3:46 pm, alux  wrote:
> Sorry to have so many questions.
>
> I lookes at swank at github, it says it supports Emacs 23 and up; and
> I should use ELPA to install it.
>
> The ELPA install page, explains how to install stuff for Emacs 21 and
> 22.
>
> As far as I understand, the Emacs init files dont support the usage of
> different EMacs versions. So which Emacs version do you use?
>
> Thank you, alux

-- 
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

To unsubscribe from this group, send email to 
clojure+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Java method call irritation

2010-03-18 Thread Seth
Would :deprecated be a reasonable thing to include in a function's
metadata? Just the presence of it seems good enough, but I guess
pairing it with some programmer friendly message ("hey, use bar
instead of foo") might be nice.

Or... maybe 10,000 lines of XML as metadata! :-)

On Mar 18, 10:50 am, Stuart Halloway 
wrote:
> memfn is from the depths of time and should be deprecated -- it is  
> idiomatic to write an anonymous fn around the method.
>
> Stu
>
>
>
> > This seems like a potential usecase for (memfn):
>
> > -
> > clojure.core/memfn
> > ([name & args])
> > Macro
> >  Expands into code that creates a fn that expects to be passed an
> >  object and any args and calls the named instance method on the
> >  object passing the args. Use when you want to treat a Java method as
> >  a first-class fn.
>
> > user> (= (map (memfn getName) (-> (Runtime/
> > getRuntime) .getClass .getMethods seq))
> >         (map #(.getName %) (-> (Runtime/
> > getRuntime) .getClass .getMethods seq)))
> > true
>
> > On Mar 18, 6:21 am, Meikel Brandmeyer  wrote:
> >> Hi,
>
> >> Java methods are not clojure functions. To treat them like first-
> >> class
> >> functions you have to wrap them in clojure functions as you did in
> >> your second example.
>
> >> For your actual task: you might want to look at clojure.contrib.repl-
> >> utils/show.
>
> >> Sincerely
> >> Meikel
>
> > --
> > 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- Hide quoted text -
>
> - Show quoted text -

-- 
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


Re: Java method call irritation

2010-03-18 Thread Seth
This seems like a potential usecase for (memfn):

-
clojure.core/memfn
([name & args])
Macro
  Expands into code that creates a fn that expects to be passed an
  object and any args and calls the named instance method on the
  object passing the args. Use when you want to treat a Java method as
  a first-class fn.

user> (= (map (memfn getName) (-> (Runtime/
getRuntime) .getClass .getMethods seq))
 (map #(.getName %) (-> (Runtime/
getRuntime) .getClass .getMethods seq)))
true


On Mar 18, 6:21 am, Meikel Brandmeyer  wrote:
> Hi,
>
> Java methods are not clojure functions. To treat them like first-class
> functions you have to wrap them in clojure functions as you did in
> your second example.
>
> For your actual task: you might want to look at clojure.contrib.repl-
> utils/show.
>
> Sincerely
> Meikel

-- 
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


Re: Full Disclojure - I Need Topics!

2010-02-05 Thread Seth
Laurent,

Merci beaucoup! I have linked to the video. I will be presenting
Clojure to the company I work for soon, and videos for Eclipse and
NetBeans really help me out. The fewer times I mention Emacs the
better, apparently :-|

Seth

On Feb 5, 12:10 am, Laurent PETIT  wrote:
> 2010/2/5 Seth :
>
> > Sean,
>
> > The new installation videos look great -- I have linked to them from
> > my company's intranet. Any plans for an installation video for
> > Counterclockwise for Eclipse?
>
> Hello,
>
> there's this one I've realized very quickly (as a proof of concept
> since it was my first screencam on linux for youtube):
>
> http://www.youtube.com/watch?v=1T0ZjBMIQS8
>
> No sound, just visual. Demonstrates counterclockwise installed from
> scratch plus creation of a helloworld project in 3 minutes.
> (pre-requisites : a working eclipse installation)
>
> But I agree it would be more thaninteresting, it would be awesome, to
> see Sean register and publish a full featured video on his vimeo
> channel !
>
> Keep up the good work!
>
>
>
>
>
> > It's neat of you to produce these videos in your spare time -- they
> > are much appreciated!
>
> > On Feb 4, 9:35 pm, Greg  wrote:
> >> > Here's a challenge for you - Monads.  If you can clearly explain monads 
> >> > you'll be my hero. :-)
>
> >> Seconded. Plus the existing Clojure docs I'm able to find on monads seem 
> >> to be totally out of date, the example code fails to run as well.
>
> >> - Greg
>
> >> On Feb 4, 2010, at 5:55 PM, Glen Stampoultzis wrote:
>
> >> > On 25 January 2010 16:34, Sean Devlin  wrote:
> >> > Hello everyone,
> >> > I'm having a blast making the Full Disclojure series.  It's one the
> >> > best projects I've had a chance to work on.
>
> >> > However, there's going to be a problem soon.  I only have a few more
> >> > topics left before I run out.  No more topics, no more videos.
>
> >> > This is where you come in.  I'm interested in what the community (i.e.
> >> > you) would like to see talked about.  It could be the core language,
> >> > contrib, a popular library, your-really-awesome-library-that-you-would-
> >> > like-to-get-exposure, or some development tool.  Bring up anything and
> >> > everything.  If it's interesting enough, I'll try to do an episode on
> >> > it.  There are no bad suggestions.
>
> >> > Here's a challenge for you - Monads.  If you can clearly explain monads 
> >> > you'll be my hero. :-)
>
> >> > --
> >> > 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 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 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


  1   2   >