question about clojure.lang.LazySeq.toString()

2013-03-21 Thread Razvan Rotaru
Hi, I'm curious, why doesn't toString of clojure.lang.LazySeq return the entire sequence as a String, and returns the Java pointer instead? I find it annoying when I do this: user> (str (map + [1 2 3])) "clojure.lang.LazySeq@7861" What's the reason behind this decision? Shouldn't toString tr

Re: mixins/multiple inheritance

2012-02-06 Thread Razvan Rotaru
Thanks, This works, but there's a problem: the labeledtextfield is not a textfield anymore, it's a label. Therefore it does not behave like a textfield (which implements other protocols as well). I need multiple inheritance, in one way or another. I've been trying to find a way to implement with m

mixins/multiple inheritance

2012-02-05 Thread Razvan Rotaru
Hi, I found some posts about this topic, but they did not clarify things in my head well enough, so I have to start my own... :) I'm basically craving for multiple inheritance or mixins, at least with my current way of thinking. I haven't really gone deep enough with multimethods or protocols, so

filter out null values

2012-02-02 Thread Razvan Rotaru
Hi, What's the clojure way to filter out null values from a sequence? I have following code: (filter identity (map myfun myseq)) Is there a better/faster way? Thanks, Razvan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, s

Re: proxy with dynamic

2012-01-28 Thread Razvan Rotaru
Yes, it's more clear now. 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 fr

Re: weird quote/unquote usage

2011-12-25 Thread Razvan Rotaru
Thanks. Razvan -- 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

Re: proxy with dynamic

2011-12-25 Thread Razvan Rotaru
On Dec 25, 1:17 pm, Meikel Brandmeyer wrote: > Hi, > > Wiring to classes happens in the bytecode and hence have to be known at > compile time. You either have to use eval or refrain from doing things at > runtime. Is the class transferred into your program at runtime without > knowing it up-fro

Re: proxy with dynamic

2011-12-25 Thread Razvan Rotaru
On Dec 25, 12:01 pm, Alan Malloy wrote: > > Presumably you just tried it and found it doesn't work, so I'm not > sure what more you're looking for here. How would you even fill in the > body of the proxy? "I don't know what class this is, but I know > exactly what methods I need to override"? Prob

weird quote/unquote usage

2011-12-25 Thread Razvan Rotaru
Hi, Consider following code: (defprotocol WithOptions (getOptions [this] "All options") (getOption [this option] "One option")) (defn- gen-proxy [klass opts] `(proxy [~klass WithOptions] [] (getOptions [~'_] ~opts) (getOption [~'thi

proxy with dynamic

2011-12-25 Thread Razvan Rotaru
Hi, Is it possible to give the class as value at runtime to proxy? (defn create-proxy [clazz] (proxy [clazz] )) I know this can be done with a macro, but my question is whether it can be done as function. Thanks, Razvan -- You received this message because you are subscribed to the G

Re: multiple return values

2011-12-24 Thread Razvan Rotaru
On Dec 23, 5:08 am, Alan Malloy wrote: > > It turns out even this is not true, becauseproxyuses some kind of > deep JVM magic called (appropriately)ProxyClasses. So every time you > write (proxy[Object] (...anything at all...)), you get an instance of > the same class, initialized with a differe

Re: multiple return values

2011-12-22 Thread Razvan Rotaru
On Dec 14, 5:33 pm, Tom Faulhaber wrote: > Razvan, > > I believe that proxy actually only creates a new class per call site, > not per instance. However, I can't completely swear to this. > > Anyone with more detailed knowledge than I have want to comment? > > Assuming I'm right,, you should be fi

Re: unquote-splicing when calling macro

2011-12-17 Thread Razvan Rotaru
kind of sequence, it does the splicing that I want. Razvan On Dec 17, 6:32 pm, Razvan Rotaru wrote: > Great. Thanks. > > On Dec 17, 6:08 pm, Baishampayan Ghose wrote: > > > > > > > > > > This may sound a bit weird, but can I "unquote-splice" so

Re: unquote-splicing when calling macro

2011-12-17 Thread Razvan Rotaru
Great. Thanks. On Dec 17, 6:08 pm, Baishampayan Ghose wrote: > > This may sound a bit weird, but can I "unquote-splice" something when > > calling a macro. Here's an attempt to do this with hiccup: > > > (defn get-header > >   [[:link {:type "text/css" ...}] > >    [:script {:type "text/javascrip

unquote-splicing when calling macro

2011-12-17 Thread Razvan Rotaru
Hi, This may sound a bit weird, but can I "unquote-splice" something when calling a macro. Here's an attempt to do this with hiccup: (defn get-header [[:link {:type "text/css" ...}] [:script {:type "text/javascript" ...}]]) (html [:head (get-header) ...] [:body ...]) The result of get-h

Re: multiple return values

2011-12-15 Thread Razvan Rotaru
per instance. However, I can't completely swear to this. > > > Anyone with more detailed knowledge than I have want to comment? > > > Assuming I'm right,, you should be fine to have lots of instances. > > > HTH, > > > Tom > > > On Dec 13, 1

Re: letrec

2011-12-14 Thread Razvan Rotaru
an On Dec 14, 11:09 pm, David Nolen wrote: > Do you have a minimal example of what you are trying to do? > > On Wed, Dec 14, 2011 at 3:53 PM, Razvan Rotaru wrote: > > > > > > > > > letfn defines functions. I'm just defining some values. The values > &g

Re: letrec

2011-12-14 Thread Razvan Rotaru
2:53 PM, Razvan Rotaru wrote: > > > I don't quite understand why people are saying this. Anyway, It's not > > enough for me. > > What can't you solve your problem with what was suggested? > > David -- You received this message because you are subscribed to

Re: letrec

2011-12-14 Thread Razvan Rotaru
I don't quite understand why people are saying this. Anyway, It's not enough for me. On Dec 14, 9:13 pm, Kevin Downey wrote: > lazy-seq and letfn should cover anything you would need letrec for > > > > > > > > > > On Wed, Dec 14, 2011 at 11:09 AM, Razv

letrec

2011-12-14 Thread Razvan Rotaru
Hi, Is there a reliable implementation of letrec in clojure? Anybody using it? I have found a post from 2008, with an implementation which I don't understand (and it's said to be slow), and which I don't know whether to trust.(It's also supposed to be slow). Thanks, Razvan -- You received this

Re: multiple return values

2011-12-13 Thread Razvan Rotaru
Thanks. I don't know how this hashmap works, but at the first glance there seems to be one problem: the two values don't get garbage collected at the same time. I'll look more into it, thanks. On Dec 13, 3:10 am, Stephen Compall wrote: > On Mon, 2011-12-12 at 10:54 -0800, R

Re: multiple return values

2011-12-13 Thread Razvan Rotaru
I don't want to change the interface i'm exposing to the outer world. May be that I'm thinking too javaish, but what I miss here is a possibility to extend the base class. :) On Dec 12, 9:31 pm, James Reeves wrote: > On 12 December 2011 18:54, Razvan Rotaru wrote: > >

Re: multiple return values

2011-12-13 Thread Razvan Rotaru
/clojure/blob/1f11ca3ef9cd0585abfbe4a9e7609... > > The rest of that module is an abomination that was written when I was > still under the influence of CLOS & O-O. > > Hope that helps, > > Tom > > On Dec 12, 5:10 pm, Stephen Compall wrote: > > > > > > > &g

multiple return values

2011-12-12 Thread Razvan Rotaru
Hi, I read that there's no such thing as lisp-like multiple values return in clojure. We can use vectors, and the destructuring feature helps also. However, for what I'm trying to do I need to emulate somehow the following behavior: - function returns a value which is a java instance (not possibl

Re: java reflection during macro

2011-12-09 Thread Razvan Rotaru
Thanks. I was missing the call to resolve. (let [klass (resolve c)] ) With it it works. Razvan On Dec 8, 11:39 pm, Stuart Sierra wrote: > Not sure if it helps, but here's my example of using reflection in a macro: > > http://stuartsierra.com/2010/12/16/single-abstract-method-macro > > -S

java reflection during macro

2011-12-08 Thread Razvan Rotaru
Hi, I'm trying to write some macros for java object instanciation. Here's the code: (defn- gen-object-method [my-class id option value] (let [method (some (java-methods option) (map #(.getName %) (.getMethods my-class)))] (when (not method) (throw (new java.lang.Illega

Re: on lisp and scheme macros

2011-12-03 Thread Razvan Rotaru
gt; Scheme style macros in Clojure:https://github.com/qbg/syntax-rules > > Scott > > On Sat, Dec 3, 2011 at 1:20 PM, Razvan Rotaru wrote: > > > > > > > > > Hi everyone, > > > I was searching the web these days trying to find out more about these

on lisp and scheme macros

2011-12-03 Thread Razvan Rotaru
Hi everyone, I was searching the web these days trying to find out more about these two macro systems and understand their differences, and why one is preferable over the other (or not). I'd like to share with you some ideas, and hopefully get some opinions back as well. Coming from the lisp side,

keyword arguments

2011-11-27 Thread Razvan Rotaru
Hi, This may be a question without hope, but I'm thinking that asking never hurts. So here goes: The closest thing to keyword arguments that I have found is destructuring with a map: (defn myfun [& {:keys [arg1 arg2 arg3] :or {arg1 "default-value"} :as args}] ...) When I

Re: appengine-magic + servlets

2011-11-07 Thread Razvan Rotaru
Yes, I tried that but did not work. appengine-magic/serve expects an "appengine-application", which is a map that among others contains the ring handler. The serve function turns this handler into a servlet and maps it to the root path "/" (or "/*", I haven't figured that out yet). Whatever i write

Re: appengine-magic + servlets

2011-11-06 Thread Razvan Rotaru
you have integrated it with > appengine-magic? > >  - Mark > > > > > > > > On Sun, Nov 6, 2011 at 11:41 AM, Razvan Rotaru > wrote: > > I want integration of servlet in appengine-magic. > > > Documentation describes that you use a ring handler t

Re: appengine-magic + servlets

2011-11-06 Thread Razvan Rotaru
isting Java servlet that you want to handle some url > pattern, and you want to integrate that into your appengine-magic app? > > > > > > > > On Sun, Nov 6, 2011 at 5:08 AM, Razvan Rotaru wrote: > > Hi, > > > appengine-magic (https://github.com/gcv/appen

Re: problems of a newbie

2011-11-06 Thread Razvan Rotaru
I remember having the same frustrations some time ago. Not that they are gone now. :) It obviously depends on the tool, and these code analysis you describe you get only in IDEs. I don't know what tool you are using now, but you have them all described in the Getting Started page (http:// dev.cloju

appengine-magic + servlets

2011-11-06 Thread Razvan Rotaru
Hi, appengine-magic (https://github.com/gcv/appengine-magic) uses ring- handlers to turn into servlets that are accepted by GAE. Does anybody know how to use servlets directly with appengine-magic? I'm not using ring, I have a servlet which I need to feed to appengine-magic. Thanks, Razvan -- Y

Re: shortcut for anonymous function literal and syntax quote

2011-11-01 Thread Razvan Rotaru
Yeah, you are probably right. But I figured asking never hurts... Thanks for the reply. Razvan On Oct 19, 10:50 pm, Alan Malloy wrote: > Not really. In _Let Over Lambda_'s section on reader macros, he > creates a reader macro #`(foo bar a1 a2) that expands to (lambda (a1 > a2) `(foo bar ,a1 ,a2)

shortcut for anonymous function literal and syntax quote

2011-10-19 Thread Razvan Rotaru
Hi, I'm just wondering is there a nicer way to write this: (defmacro my-macro [& body] (map (fn[x] `(my-fun ~x)) body)) I'd like to use the anonymous function literall #(), but this won't work: (defmacro my-macro [& body] (map #(`(my-fun ~%)) body)) So if you have some suggestion, I'd

Re: "Can't eval locals problem"

2011-10-19 Thread Razvan Rotaru
Thanks for your suggestion. I finally decided to find a way around the problem. :) This is cutting too deep for me to handle with my current clojure knowledge. I also talked to Constantine Vetoshev (the author of appengine-magic) and he anknowledged it as an issue which could have a solution by cha

Re: how to use record as a value

2011-10-06 Thread Razvan Rotaru
This is what I'm looking for. Thanks. I have not seen this kind of expression before: ->foo. Is is created by defrecord or is it implemented at reader level? I realize now that I can also keep a generating function in the variable stuff: (let [stuff #(car. %1 %2)] (stuff 1982 "Mercedes") (stu

Re: how to use record as a value

2011-10-06 Thread Razvan Rotaru
manufacturer "Mercedes"})] >   ...) > > or if you must > > (let [foo #user.car{:year 1982 :manufacturer "Mercedes"}] >   ...) > > Cheers, > > Aaron Bedra > -- > Clojure/corehttp://clojure.com > > On 10/06/2011 01:27 PM, Razvan Rotaru wrote: > > > >

how to use record as a value

2011-10-06 Thread Razvan Rotaru
Hi, I want to instantiate a record, but having the record type as value at runtime. Example: (defrecord car [year manufacturere]) (defrecord bike [year manufacturere]) (defrecord boat [year manufacturer]) I want to do (new stuff 1982 "Mercedes"), but having the record type kept in the variable "

"Can't eval locals problem"

2011-10-03 Thread Razvan Rotaru
Ok, so I'm stuck. If any of you more seasoned clojurians have a hint that could get me out, I will be forever gratefull to him/her: I'm trying execute a query against google app engine datastore, using appengine-magic, with the filter dynamically generated from a map. Here's the closest code I hav

metadata for records

2011-10-01 Thread Razvan Rotaru
Hi, Is there a way to attach metadata to defrecord ? Razvan -- 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 f

get keys from defrecord

2011-08-29 Thread Razvan Rotaru
Hi, Assuming I have: (defrecord myrecord [:a :b :c]) is there a way to get the list of keys from the record definition? Thanks, Razvan -- 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 No

Cyclic load dependency

2011-07-16 Thread Razvan Rotaru
Hi, I'm trying to use r0man / appengine-clj, and when :use-ing the datastore namespace I get a "cyclic load dependency". Doesn't clojure allow such cyclic references? (use 'appengine.datastore) Cyclic load dependency: [ /appengine/datastore/entities ]->/appengine/ datastore/query->[ /appengine/d

Re: bug in partition?

2011-06-14 Thread Razvan Rotaru
Thanks for the hint. And don't worry about the meaning of this function. :) Name parameter has no use. And the regex stuff's for the url. Razvan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups

Re: Vim Nailgun setup - access to REPL from outside Vim

2011-06-14 Thread Razvan Rotaru
You may also want to have a look at slimv. http://www.vim.org/scripts/script.php?script_id=2531 It performs quite nice (can't compare it with vimclojure though, 'cause I don't know vimclojure). Razvan -- You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: bug in partition?

2011-06-13 Thread Razvan Rotaru
Thanks. But still I don't get something. Shouldn't partition return a sequence? Shouldn't every sequence end with nil? Razvan -- 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 post

bug in partition?

2011-06-13 Thread Razvan Rotaru
Hi, Not sure if this is a novice thing or a real bug. Here's what I encountered: I'm calling a Java method which returns a String[], which I then pass to partition to get a list of lists (I know, sequence, but list is a shorter word). What happens then, is I loop over my list of lists with (loop .