Re: User contributed packages (Cabel, CPAN, etc)

2009-03-23 Thread Warren
Sounds like OSGi. Any progress on Clojure working with OSGi? On Mar 22, 9:59 pm, Phil Hagelberg wrote: > Bradbev writes: > > I feel that the next big growth phase for Clojure will be in the user > > community and the code that we can generate.  A good package manager > > will help fuel that gr

question on last page of Conjure tutorial

2009-09-27 Thread Warren
What am I doing wrong? thanks, Warren --~--~-~--~~~---~--~~ 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

Re: question on last page of Conjure tutorial

2009-09-29 Thread Warren
That worked! Thanks! On Sep 28, 8:18 am, Matt wrote: > Try: > > > (deftest test-add >   (add { :controller controller-name :action "add" })) > > > Let me know if that works. In the tutorial, I guess I should be more > clear on what to change. > > -M

Re: Is it possible to implement break or return in Lisp?

2009-11-01 Thread Warren
Maybe could be done using continuation passing style? (http:// en.wikipedia.org/wiki/Continuation-passing_style) On Nov 1, 7:04 pm, CuppoJava wrote: > Hi, > For the purposes of a DSL that I'm writing, it would be very > convenient to have a break/return statement that early exits from a > subrou

Re: [ANN] Time-Bombed Open License - thoughts?

2015-06-07 Thread Warren
If you are concerned about the free-rider problem, why not dual license under AGPL? It's seems sufficiently "viral" that most commercial entities will elect to take a commercial license, but it allows the source to be leveraged by other open source projects. The only downside is that AGPL do

Does Clojure support efficient coroutines?

2012-09-25 Thread Warren
Hi, It seems the JVM doesn't provide any support for coroutines, generators, light-weight threads, or non-reusable continuations. I can't find any mention of coroutines in the docs, so I'm guessing Clojure doesn't have them due to the lack of JVM support. Is that corre

Transactional memory design rationale

2012-09-25 Thread Warren
his sort of principled open nesting solves the problem that clojure's "commute" does but also handles cases when an operation commutes with _some_ other operations but not _all_, e.g. two hashmap writes to different keys don't conflict with each other but writes to the same key d

Re: Does Clojure support efficient coroutines?

2012-09-26 Thread Warren
All I need is some sort of threads that can handle 1000 simultaneous threads and 300,000 context switches per second. I don't actually need the coroutine value-passing feature; they are just one thing that lightweight threads can be built on top of. Regular OS threads (via java.lang.Thread) wou

Re: newbie question

2009-11-07 Thread Warren Wood
On Nov 6, 12:10 pm, John Harrop wrote: > On Fri, Nov 6, 2009 at 1:07 PM, John Harrop wrote: > > On Fri, Nov 6, 2009 at 1:01 PM, Warren Wood > > wrote: > > >> In the meantime, I came up with the following, which seems to work. > >> I'm sure it can be

Re: newbie question

2009-11-07 Thread Warren Wood
Thanks, that was indeed helpful! On Nov 6, 6:47 pm, Alex Osborne wrote: > Alex Osborne wrote: > > Like Mark's but using split-with instead of split-at: > > > (defn partition-when [pred coll] > >    (lazy-seq > >     (when-let [[x & xs] (seq coll)] > >       (let [[xs ys] (split-with (complement

Re: newbie question

2009-11-07 Thread Warren Wood
16) (partial <= 9)) (range 1 20)) evaluates to (10 12 14 16) On Nov 7, 9:39 pm, Warren Wood wrote: > On Nov 6, 12:10 pm, John Harrop wrote: > > > > > > > On Fri, Nov 6, 2009 at 1:07 PM, John Harrop wrote: > > > On Fri, Nov 6, 2009 at 1:01 PM, Warren Woo

ClassCastException from RT.java in Day Communique

2010-01-06 Thread Warren Wood
The cast in the following method from RT.java throws a ClassCastException when trying to compile Clojure within the Day Communique 4.2.1 content management system. Any suggestions? thanks, Warren static public long lastModified(URL url, String libfile) throws Exception{ if(url.getProtocol

Re: ClassCastException from RT.java in Day Communique

2010-01-06 Thread Warren Wood
Here is what the exception says : Caused by: java.lang.RuntimeException: java.lang.ClassCastException: com.day.cq.net.jar.ContentBusJarURLConnection cannot be cast to java.net.JarURLConnection at clojure.lang.RT.(RT.java:291) On Jan 6, 3:11 pm, Warren Wood wrote: > The cast in the follow

Re: "I don't feel the absence of a debugger, because I've learnt enough that I don't ever need a debugger."

2013-05-28 Thread Warren Lynn
May I suggest that as useful as your strategies are, they cannot replace a debugger? Let's be clear about our logic before claiming "it is not much needed". Maybe YOU really don't need it, but that is different from claiming it is not needed. A debugger as good as it is cannot replace the 4 fi

Re: "I don't feel the absence of a debugger, because I've learnt enough that I don't ever need a debugger."

2013-05-28 Thread Warren Lynn
> Still miss the Elisp debugger, which is great. It's right there, in your > editing environment. It's good for debugging my own code. It's really > good for working out someone elses code. I wish I debug clojure in the > same way. It's not essential, of course. But nice. > > Phil > I miss

Re: "I don't feel the absence of a debugger, because I've learnt enough that I don't ever need a debugger."

2013-05-29 Thread Warren Lynn
I did not say that a debugger was not useful at all, I said that the > importance of having a > debugger is *overestimated* especially in an immutable world. > > Relying on a debugger as an important tool to support coding is like > admitting > the failure of your code before it runs. It's l

my first clojure "wat" moment - misunderstanding or bug?

2013-10-02 Thread James Warren
I've been using Clojure for a couple months, so while I feel comfortable with it, I'm not certain whether some unusual behavior I encountered is a bug or a lack of understanding on my part. (I suspect the latter.) The context arose from using Clojure reflection to inspect a class generated by

Re: my first clojure "wat" moment - misunderstanding or bug?

2013-10-03 Thread James Warren
you > need the sequence of keys. > > [1] > http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/EnumMap.java#EnumMap.EntryIterator > > Thanks, > Elias. > > On Wednesday, October 2, 2013 5:19:31 PM UTC-4, James Warren wrote: >> &

Re: Is it possible to set breakpoint using nrepl-ritz?

2013-03-15 Thread Warren Lynn
> It is using the latest development code (C-c C-x C-b on the line to > break at). A release should be out containing this in the next few > days. > > Hugo > I was eager to use the line debugging commands but had no success. After "M-x nrepl-ritz-jack-in", I loaded a clojure file (just the

Re: Is it possible to set breakpoint using nrepl-ritz?

2013-03-16 Thread Warren Lynn
> Could you create an issue for this. > > > Just did that. Even with "M-x nrepl-ritz-break-on-exception" (and adding an (throw ...) in the code), it still does not work for me. Just hangs. Also after "M-x nrepl-ritz-break-on-exception", my "ac-nrepl" does not work anymore, Whenever auto co

Re: ANN: Spyscope 0.1.3

2013-04-12 Thread Warren Lynn
I requested some of the features added in this release. Thanks a lot for the work. -- -- 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 - plea

Re: ritz-nrepl starts up slowly?

2013-05-13 Thread Warren Lynn
> > Is it normal to take this long to start the repl? > > > I don't know if it is normal. But I can confirm it takes much longer to start ritz-nrepl compared to nrepl only, which itself is already kind of slow. The slow speed really is killing a lot of fun here. -- -- You received this mes

Re: ritz-nrepl starts up slowly?

2013-05-16 Thread Warren Lynn
> The killing of the user process is currently not very reliable. > > > This might be an Emacs "bug" (at least on Windows). The problem is there even for nrepl without ritz (some java process will still dangle there after exiting nrepl). What I did to work around this is to add some code/advi

Re: Clojure 1.2 Release

2010-09-13 Thread Warren Wood
Can we get a status update on that :) ? On Aug 19, 3:22 pm, Mark Derricutt wrote: > I think I can do that - or at least push that along.  Will check into it > when I get to the office in about 30 minutes. > > PS: Direct sync to central is easy via oss.sonatype.org repositories. > > -- > Pull me d

Avoid duplicate computation in commute?

2012-05-17 Thread Warren Lynn
Hi, The duplicate computation in "commute" seems to me quite a blemish on clojure's beauty. I even see somebody's code with comments "pre- compute x because otherwise commute will call it twice". So I need to keep that fact in the back of my mind when using it? That is not what I was hoping for.

Re: Avoid duplicate computation in commute?

2012-05-17 Thread Warren Lynn
Thanks and these are certainly workable solutions. But is there any particular reason why with commute the update function is ALWAYS called twice, even when no other thread changed the ref value at the commit time? That is what bothers me. On May 17, 5:46 pm, DAemon wrote: > Would some of this di

Re: Avoid duplicate computation in commute?

2012-05-17 Thread Warren Lynn
r as I know. Although I could be > wrong, *throws question to the Gods of clojure* > > > > > > > > On Fri, May 18, 2012 at 8:03 AM, Warren Lynn wrote: > > Thanks and these are certainly workable solutions. But is there any > > particular reason why with commute t

defrecord with "inheritance"

2012-05-20 Thread Warren Lynn
So from what I read the philosophy of Clojure discourages inheritance on concrete data types. However, maybe I am too entrenched in my OO thinking, how do I define a new record type that includes all the data members of another record type? I am thinking about the classic Employee/Person example.

Re: defrecord with "inheritance"

2012-05-20 Thread Warren Lynn
...)})) > > The problem is that you can't reuse methods defined inline, i.e. you can't > say "my record implements this protocol just like that other record". > > воскресенье, 20 мая 2012 г., 23:22:55 UTC+6 пользователь Warren Lynn > написал: > > > > &g

Re: defrecord with "inheritance"

2012-05-20 Thread Warren Lynn
;s life a little bit easier. On May 20, 4:55 pm, Kevin Downey wrote: > On Sun, May 20, 2012 at 1:50 PM, Warren Lynn wrote: > > Thanks. That will work. But I wish things can get more concise and > > elegant. > > > I like the Python idea of "make simple things easier a

Re: defrecord with "inheritance"

2012-05-20 Thread Warren Lynn
m, Kevin Downey wrote: > On Sun, May 20, 2012 at 10:22 AM, Warren Lynn wrote: > > So from what I read  the philosophy of Clojure discourages inheritance > > on concrete data types. However, maybe I am too entrenched in my OO > > thinking, how do I define a new record type tha

Re: defrecord with "inheritance"

2012-05-20 Thread Warren Lynn
Well, I don't want to be a beginner for too long, :-) On May 20, 5:19 pm, Kevin Downey wrote: > On Sun, May 20, 2012 at 2:13 PM, Warren Lynn wrote: > > Maybe for Person/Employee example with very simple functions do not > > need data types, but I don't think that

Re: defrecord with "inheritance"

2012-05-20 Thread Warren Lynn
objectives). Part of my learning here is to find out if the language is right for me. On May 20, 5:37 pm, Bill Caputo wrote: > On May 20, 2012, at 4:23 PM, Warren Lynn wrote: > > >> defrecord, deftype, and defprotocol provide extensible low level > >> abstractions li

Re: defrecord with "inheritance"

2012-05-20 Thread Warren Lynn
sure what > "natural" could possibly mean besides "familiar" which is a limited metric > in my opinion. > > David > > > > > > > > On Sun, May 20, 2012 at 6:17 PM, Warren Lynn wrote: > > Thanks for the suggestion. I understand par

Re: defrecord with "inheritance"

2012-05-20 Thread Warren Lynn
7;d argue with you over whether that is the whole point of high-level > languages.  I might say that high-level languages are there to make coding > more efficient and effective. > > > > > > > > On Sun, May 20, 2012 at 5:16 PM, Warren Lynn wrote: > > > I agree &

Re: defrecord with "inheritance"

2012-05-20 Thread Warren Lynn
nosky > > Sender: clojure@googlegroups.com > Date: Sun, 20 May 2012 17:42:10 > To: > Reply-To: clojure@googlegroups.com > Subject: Re: defrecord with "inheritance" > > I'd argue with you over whether that is the whole point of high-level > languages.  I

Re: defrecord with "inheritance"

2012-05-20 Thread Warren Lynn
cannot do anything on the computer without it. You never know. :-) On May 20, 9:44 pm, David Nolen wrote: > On Sun, May 20, 2012 at 9:35 PM, Warren Lynn wrote: > > I hope my original "feature > > request" at the beginning falls into such category. > > Don't hold y

Re: defrecord with "inheritance"

2012-05-21 Thread Warren Lynn
Sometimes it seems to me"OO" and "inheritance" have become some kind of taboos. I don't believe OO is all that wrong. To me Clojure seems to have good potential to harness the good part of OO without carrying into the bad parts. So I am hoping. :-) On May 21, 2:25 pm, "nicolas.o...@gmail.com" wro

Re: defrecord with "inheritance"

2012-05-22 Thread Warren Lynn
gt;   (age [this] (age (:person this))) > > > Arguably, if we were deferring to the current Java best practices and > > encapsulation, one should be creating interfaces of getters and setters > > rather than directly accessing instance variables anyway, making the extra > &

Re: defrecord with "inheritance"

2012-05-22 Thread Warren Lynn
Maybe some macros can help. But if it is a good and common pattern, then it should be included as part of the the language. One thing I am glad to see in Clojure is it absorbed some known good macros in Common Lisp (like "awhen" becomes "when-let") so people don't need to re- invent the wheels agai

user.clj not working with lein 2.0

2012-06-04 Thread Warren Lynn
Hi, I just started using lein version 2. Before (with lein 1.7), after running "lein swank" and connect with "slime-connect" in emacs, in my REPL i have clojure.repl included in "user" automatically namespace, because I have a file user.clj under ~/.lein with the following content: (use 'clojure.

Re: user.clj not working with lein 2.0

2012-06-04 Thread Warren Lynn
:injections works! slime works too (with slime-describe-symbol for doc). Thank you! On Jun 4, 11:05 pm, Phil Hagelberg wrote: > On Mon, Jun 4, 2012 at 5:55 PM, Warren Lynn wrote: > > (use 'clojure.repl) > > (use 'clojure.java.javadoc) > > > But now in

Exclude some dependencies with lein uberjar

2012-06-12 Thread Warren Lynn
Hi, As titled, I need to exclude certain dependencies from my final .jar file (because those dependencies will already be there in the final target Java environment). How can I do that? Thank you. PS: I am using Leinengen 2 -- You received this message because you are subscribed to the Google G

Re: Exclude some dependencies with lein uberjar

2012-06-12 Thread Warren Lynn
> As the name says uberjar is what you should be able to run with no > worries about the classpath - all deps are included in the final jar. > Since you asked to exclude some deps, you likely run the final jar in > a kind of managed environment. Why are there some deps not the others? > What

Re: Exclude some dependencies with lein uberjar

2012-06-12 Thread Warren Lynn
If you don't need AOT then you can include the common lib in > dependencies in the :dev profile. > > If you need AOT then you'll have to write a plugin that works like a > more selective variant of uberjar. > > -Phil > I do need AOT, and I am not ready yet to write any plugins. Maybe I can

Re: Exclude some dependencies with lein uberjar

2012-06-13 Thread Warren Lynn
> Why does AOT happen after exclusion? Shouldn't exclusion be the last > > step in the process which would hardly break anything and would > > eventually fix the issue? > > Oh, I meant this would be a problem if you used profiles for > separating dependencies. If you use :uberjar-exclusions y

Type hint for vector element?

2012-06-13 Thread Warren Lynn
It is very common for all elements in a vector to be always of the same type. Is there any way to hint the type to Clojure? Does such hint can even improve performance? Thank you. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group

Why is lein so slow?

2012-06-13 Thread Warren Lynn
I cannot help notice that leinengen seems quite slow. Even "lein help" takes 8 seconds to finish printing all the information. I am using version 2 on Windows 7(that .bat file). Can anyone explain what is going on? Or is it just me? Thank you. -- You received this message because you are subsc

Calling Clojure from Java and classloader

2012-06-13 Thread Warren Lynn
Ok, I hit a wall and really did not see this coming. Based on what I have read, its really easy for Clojure and Java to work together. So I wrote some test Clojure code with a very simple defrecord (say named as "testrec") and AOT compile it, create a jar file, and add it to a "HelloWorld" java pr

Re: Calling Clojure from Java and classloader

2012-06-15 Thread Warren Lynn
> It's not really a good idea to AOT your code and then directly try to > use it from java. The generated java bytecode isn't guaranteed to be > stable across versions of clojure, and you're depending on > implementation details. > > One way to use your clojure code from java is through RT

How to do aynchrounous producer/consumer

2012-06-15 Thread Warren Lynn
What I want to do is something I probably have done dozens of times in C++: two threads, one thread putting items in a queue, another taking it out (FIFO). How to do it in Clojure? I am at a loss. I thought about a few options: 1. "watches", but it cannot change the queue itself (can only watc

Re: How to do aynchrounous producer/consumer

2012-06-16 Thread Warren Lynn
On Saturday, June 16, 2012 12:47:03 AM UTC-4, Alan Malloy wrote: > > (map consume (seque (produce-lazily))) > > Thank you! This is not exactly what I want (my input data is pushed from an external Java framework), but I was not aware there is a "seque" function, which might be useful for my oth

Namespace loading with deftype/defrecord used from Java

2012-06-17 Thread Warren Lynn
Basically, the issue is: When a deftype/defrecord named class is used from Java, its containing namespace is not loaded automatically, so even calling a function in the same namespace will raise an exception like this: java.lang.IllegalStateException: Attempting to call unbound fn ... An example

Re: How to do aynchrounous producer/consumer

2012-06-17 Thread Warren Lynn
Thank you all for the suggestions. I decided to use Java as lamina seems an overkill for me and I may lose some control over things I want to have. I was wishing for a pure Clojure solution, but a wrapping layer over the Java works fine. On Sunday, June 17, 2012 4:43:17 AM UTC-4, Jeff Rose wr

General subsequence function

2012-06-27 Thread Warren Lynn
I am surprised that there seems to be no general sub-sequence function that will return a segment of a sequence without changing the underlying concrete type. I found "subvec", but it works only on vectors. "subseq" is not what I thought it is. Did I miss anything? Or is there a simple idiomati

Re: General subsequence function

2012-06-27 Thread Warren Lynn
You can combine 'drop and 'drop-last to get a seq version of subvec (but > lazy and O(n)). As for the issue of concrete types: in general, clojure's > sequence functions return seqs, not instances of whatever concrete type you > gave them. If you need a specific type, you normally just pour t

Re: General subsequence function

2012-06-27 Thread Warren Lynn
> > Ordering problem aside, I'd argue this is not an unreasonable amount of > code for what seems to me a pretty rare set of requirements. Most people > who want a same-type segment from the middle of an ordered collection > (which is already uncommon in my experience) are probably either usin

Re: General subsequence function

2012-06-27 Thread Warren Lynn
Thanks, but this does not keep the concrete type. On Wednesday, June 27, 2012 3:42:25 PM UTC-4, Ulises wrote: > > > I'd forgotten that 'into adds things in the "default" place for whatever > type you're using, hence the reversal on lists. I'm not sure if there's a > simple way to get the same ty

Re: General subsequence function

2012-06-27 Thread Warren Lynn
ns if and > when a need arises. This is neither simple nor pretty, but an advantage of > no-side-effects functional programming is that when you call a pure > function you don't need to worry about how simple or pretty might be its > internal details. > --Larry > > On 6/27

Re: General subsequence function

2012-06-27 Thread Warren Lynn
It seems the name "append" has not yet been taken. How about we do this with Clojure: 1. add a new function "append", which splices multiple ordered collection together and always returns the result in the concrete type of its first argument. So: (append [1] '(2 3)) => [1 2 3] (append '(1) [2

Re: General subsequence function

2012-06-28 Thread Warren Lynn
Some of my thoughts: 1. The argument that other languages do not have a similar thing is not valid. If that is valid, we don't need Clojure in the first place. 2. The argument that other people did not raise the issue before and not enough people support it so this is a non-issue is also not va

Re: General subsequence function

2012-06-28 Thread Warren Lynn
Here is "another language" elisp: Anybody who use Emacs can do this: (subseq (make-vector 5 10) 2 4) => [10 10] (subseq '(10 10 10 10 10) 2 4) => (10 10) As simple as that. Is that even worth the debate? :-) On Thursday, June 28, 2012 11:30:25 AM UTC-4, Warren Lynn

Re: General subsequence function

2012-06-28 Thread Warren Lynn
f (as you will be even slower to to have your own). On Thursday, June 28, 2012 2:52:54 PM UTC-4, Tassilo Horn wrote: > > Warren Lynn writes: > > Hi Warren, > > > 1. add a new function "append", which splices multiple ordered > collection > > together

Re: General subsequence function

2012-06-28 Thread Warren Lynn
ere is the option of trying to convince other people to > do one of the above. That can be anywhere on the scale of amazingly quick > & easy, to incredibly frustrating & hard, depending upon your ideas, how > persuasive you are, and who reads your arguments. > > Andy >

Re: General subsequence function

2012-06-28 Thread Warren Lynn
Is there any reason why "last" needs to be slow on vectors? Can it just do the right thing and be fast on it? On Thursday, June 28, 2012 4:28:30 PM UTC-4, Meikel Brandmeyer (kotarak) wrote: > > Hi, > > Am 28.06.2012 um 20:52 schrieb Tassilo Horn: > > > And yes, there are some counter examples

Why cannot "last" be fast on vector?

2012-06-28 Thread Warren Lynn
This is an off-shoot subject from my last post "General subsequence function". I found people had similar questions before (one year ago): http://groups.google.com/group/clojure/browse_thread/thread/712711f049507c63/aea7cf438aa22922 As of Clojure 1.4, seems nothing changed, as "source" show here

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
Tamreen: Thank you. Your posts really explained why it is so. I understand the reasons now, but I can hardly agree those reasons are good ones (not arguing with you, as you pointed out, the reasons are weak for this case). As I pointed out before in my other post ("General subsequence function

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
Sorry, I should have addressed my last post to "puzzler". On Friday, June 29, 2012 10:51:44 AM UTC-4, Warren Lynn wrote: > > > Tamreen: > > Thank you. Your posts really explained why it is so. I understand the > reasons now, but I can hardly agree those reasons are go

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
Surely nobody can restrict/enforce anything on anybody, and I can always have my own "mycore" ns. In theory, I could even create my own language without the need to persuade anybody (or just fork from Clojure and have my own private copy). That will be the ultimate "Libertarian", but some peopl

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
> The design choice has nothing to do with speed, it has nothing to do > with concrete types like lists and vectors either, no matter what > might have been said before by others. > > David > If the design choice has nothing to do with speed path, Could you let us know why we cannot get fre

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
their > own interrest. > > It is logical you ask for it, but there is no need to insist or maybe > be a little offensive if others don't share your views. > > Regards, > > Nicolas Bousquet. > > On 29 juin, 01:32, Warren Lynn wrote: > > This is an off-sho

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
eld wrote: > > On Fri, Jun 29, 2012 at 7:51 AM, Warren Lynn wrote: > > 1. Put good documentations on the functions, and the programmer needs to > > have some idea what data structure is fast/slow for what use. > > At the risk of continuing what is quickly becoming a rat

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
2012 4:41:59 PM UTC-4, David Nolen wrote: > > On Fri, Jun 29, 2012 at 4:25 PM, Warren Lynn wrote: > > My understanding here is "ISeq" is an INTERNAL, implementation level > > interface/abstraction, not the user/language level abstraction (which in > > this case sh

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
Although I have not yet looked at any of Clojure's internals yet, I suspect the change won't be too difficult (for the right person). So I hope/wish someone with enough knowledge, skills and influence will agree with me and advocate a review of the design ("last" may not be the only one with is

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
The same? If internally it can be faster, be faster. If not, don't change. On Friday, June 29, 2012 6:05:37 PM UTC-4, David Nolen wrote: > > On Fri, Jun 29, 2012 at 5:17 PM, Mark Engelberg > wrote: > > It is clear that some collections *could* support a more efficient last. > > Anything with

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
ed to use "peek" for vector and "last" for sequence. That defeats the very purpose of abstraction. On Friday, June 29, 2012 7:42:14 PM UTC-4, David Nolen wrote: > > On Fri, Jun 29, 2012 at 6:49 PM, Warren Lynn wrote: > > The same? If internally it can be faster, be f

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
Again, I don't know the internal details. If you are saying because of the current implementation, the change is difficult, then we will be talking about the implementation, not about the abstraction design. I have very little to say about that. On Friday, June 29, 2012 7:50:56 PM UTC-4, David

Re: Why cannot "last" be fast on vector?

2012-06-29 Thread Warren Lynn
On Friday, June 29, 2012 9:23:09 PM UTC-4, Bobby Eickhoff wrote: > > Warren, you're on the right track with your alternative design: > Intuitively and ideally, "last" should return the last element of a finite, > ordered collection. But Clojure's "last" operate

Re: Why cannot "last" be fast on vector?

2012-06-30 Thread Warren Lynn
eality. On Saturday, June 30, 2012 3:47:58 AM UTC-4, Craig Brozefsky wrote: > > Warren Lynn writes: > > >Although I have not yet looked at any of Clojure's internals yet, I > >suspect the change won't be too difficult (for the right person). So > I >

Re: Why cannot "last" be fast on vector?

2012-06-30 Thread Warren Lynn
undamental design principle of Clojure that, when given two > approaches, A and B, make primitive the one that could be used to build the > other. Clojure's "peek" and "last" might be useful to somebody building > the "last" that Warren wants. Warre

Re: Why cannot "last" be fast on vector?

2012-06-30 Thread Warren Lynn
e a better experience using it. That is my goal (obvious I hope). On Saturday, June 30, 2012 12:17:39 PM UTC-4, Craig Brozefsky wrote: > > Warren Lynn writes: > > >As I mentioned before, the issue here is not just a fast "last". The > >issue here is

Re: Why cannot "last" be fast on vector?

2012-06-30 Thread Warren Lynn
On Saturday, June 30, 2012 1:03:04 PM UTC-4, Las wrote: > > Warren, > > I think the issue is this: > > You claim there is sg. broken in clojure while admitting that you know > little about how the design decision was made. > > People that know clojure's implemen

[ANN] clj-cc lib

2012-06-30 Thread Warren Lynn
Available here: https://github.com/wrn/clj-cc This is a very simple lib (for now only three functions) that I created in response to people's suggestions in the following two threads: 1. Why cannot "last" be fast on vector?

Re: Protocol as an abstract data type

2012-06-30 Thread Warren Lynn
implementation which only supports one abstract protocol!) I don't feel strongly about last specifically, but if people wanted it to behave polymorphically, I'd be happy to volunteer to write the code. Thanks a lot for the detailed analysis and volunteering to write the code. Not surprisingly

Clojure type of Java array

2012-07-01 Thread Warren Lynn
Somebody asks me to add handling of Java array in clj-cc/last. But I am confused what will be the type of Java array in Clojure. Fox example: (type (.toCharArray "Clojure")) => [C ;; Note: it looks like garbage. but that is what I actually got (isa? (type (.toCharArray "Clojure")) j

Re: Clojure type of Java array

2012-07-01 Thread Warren Lynn
So if I want to extend a protocol to all Java arrays, is there a single type I can use? Sounds like not. So I need to extend the protocols to char arrays, int arrays and etc? On Sunday, July 1, 2012 12:20:19 PM UTC-4, dennis wrote: > > (type (.toCharArray "Clojure")) is a class, [C means an a

Re: Clojure type of Java array

2012-07-01 Thread Warren Lynn
u encounter them at runtime. > > http://dosync.posterous.com/51626638 > > David > > On Sun, Jul 1, 2012 at 1:17 PM, Warren Lynn wrote: > > > > So if I want to extend a protocol to all Java arrays, is there a single > type > > I can use? Sounds like not.

'last' on empty collections

2012-07-01 Thread Warren Lynn
Right now (last []) => nil (last [nil]) => nil So there is no way to differentiate these two (except with some emptiness checking). In my opinion (last []) should throw an exception, because that's when last does not apply. From another point of view, there are two cases: 1. The local semantics

Re: Why cannot "last" be fast on vector?

2012-07-01 Thread Warren Lynn
I promised I won't post more on this thread. But Rich is here and I think I can grant myself an excuse to post just one more. End of it, I promise. :-) First, although Rich does not think so, I myself feel this topic is very important as it is not just about "last", It touches some fundamental

Re: 'last' on empty collections

2012-07-01 Thread Warren Lynn
On Sunday, July 1, 2012 4:21:02 PM UTC-4, Dennis Haupt wrote: > > i'd do (actually, i did) it like this: > (my-special-last coll) -> returns the last element or throws an > exception if there is none > (my-special-last coll if-empty) -> in case of an empty collections, > ifEmpty is returned >

Re: 'last' on empty collections

2012-07-01 Thread Warren Lynn
That would be horribly inconsistent with the rest of Clojure, IMO: Sure it will be. That is why I said this is an academic one, and I don't expect any change to current one. > Warren, this and some of your other issues with how Clojure works > makes me curious about your language

Protocol specific type hierarchy

2012-07-02 Thread Warren Lynn
When I re-read the thread "defrecord with inheritance" https://groups.google.com/forum/?fromgroups#!searchin/clojure/inherit/clojure/mr-o9sRyiZ0/oM4zRz4dXYsJ I am thinking: conceptually, for code reuse, is it a good idea to have protocol specific type hierarchy? I mean something like this: (defr

Re: Protocol specific type hierarchy

2012-07-03 Thread Warren Lynn
On Tuesday, July 3, 2012 4:18:44 AM UTC-4, Vinzent wrote: > > I believe the protocol's analogue for get-method would be enough. > > > If here you mean we just need to use get-method to directly reuse a protocol method anywhere, I think that is not adequate. We need to maintain the hierarchy s

Re: Protocol specific type hierarchy

2012-07-03 Thread Warren Lynn
On Tuesday, July 3, 2012 12:40:24 PM UTC-4, Vinzent wrote: > > Well, as far as I understand, protocols was made as they were on purpose, > so inability to create hierarchies is a "feature" (like it or not), while > the lack of `get-method`-like thing is clearly a defect (in my mind). > > Anyway

Understand extends? result

2012-07-03 Thread Warren Lynn
In the following example: (defprotocol testp (foo[this])) (extend-protocol testp clojure.lang.PersistentVector (foo [this] "PersistentVector impl")) (extend-protocol testp clojure.lang.Seqable (foo [this] "Seqable impl")) (foo []) => "PersistentVector impl" (foo '()) => "Seqable impl" (extends?

Re: Understand extends? result

2012-07-03 Thread Warren Lynn
On Tuesday, July 3, 2012 2:33:52 PM UTC-4, Ambrose Bonnaire-Sergeant wrote: > > Hi Warren, > > You could use "extenders" to get all Classes that extend to the protocol > and then iterate over them, testing with isa?. > > (some #(isa? MyClass %) (extenders MyP

Re: Understand extends? result

2012-07-03 Thread Warren Lynn
Is it possible that "satisfies?" is a better predicate to use than "extends?"? > > But it only works on instances, not types. -- 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 tha

Re: Protocol specific type hierarchy

2012-07-03 Thread Warren Lynn
hink > it'd > > be a good idea to implement proof-of-concept of what you have in mind > and > > publish it on Github, so people could try it and compare to what they > > already have. > > > > вторник, 3 июля 2012 г., 21:13:27 UTC

Re: Protocol specific type hierarchy

2012-07-05 Thread Warren Lynn
Ok, it seems I cannot make it work unless the "get-method" for protocol is available, The reason is, in the example by Michal, the return value from "(get-in IFoo [:impls user.Bar :foo])" is a Java function, not a true Clojure function with true dynamic typing. So, take the same example: (def

mutual reference in FP style

2012-07-06 Thread Warren Lynn
Can someone help me figure out how I can have two data structures to refer to each other in functional programing style? I mean something like double linked list, or in a tree where each node keeps a reference to its parent and children. What puzzles me is, as soon as you update the reference in

  1   2   >