Re: Clojure Performance For Expensive Algorithms
I updated my answer on SO, with a deftype-based one that gives me an additional 30% boost. On Tue, Feb 19, 2013 at 6:38 PM, Geo ggrigor...@gmail.com wrote: What about the call to .equals? On Tuesday, February 19, 2013 12:20:28 PM UTC-5, Marko Topolnik wrote: The difference between String[] and Object[] is that a member of the former doesn't need a checked cast to String, but the latter does need one. In the code under consideration, however, nothing specific to String is used, so even in the Java code you can freely replace String[] with Object[] and everything still works. If, on the other hand, you needed to invoke say *substring*, you'd see a small penalty due to the checked cast operation. On Tuesday, February 19, 2013 5:52:31 PM UTC+1, Andy Fingerhut wrote: ^objects is a Clojure synonym for ^[Ljava.lang.Object;. Note that there are such synonyms for only a few Java types, not everything, e.g. there is no ^strings. What you are hinting is that a1 and a2 are Java arrays of objects. I think this might speed up (aget a1 i) expressions, since it is known that a1 is an array of objects, but I'm not sure about that. I believe under the hood in the JVM all arrays of Objects are treated the same, regardless of whether those Objects are String, Integer, java.awt.Color, etc. Andy On Feb 19, 2013, at 8:46 AM, Geo wrote: One thing I don't get is that switching the type hints from [#^[Ljava.lang.String; a1 #^[Ljava.lang.String; a2] to [^objects a1 ^objects a2] didn't seem to have any negative impact on performance. Can anyone explain why hinting ^objects is just as good as specifying that it's an array of Strings? What are you hinting with ^objects that Clojure doesn't already know? -- -- 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/groups/opt_out. -- On Clojure http://clj-me.cgrand.net/ Clojure Programming http://clojurebook.com Training, Consulting Contracting http://lambdanext.eu/ -- -- 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/groups/opt_out.
Re: Create map from vector of keywords and other items
Thank you all for your valuable input. I'll look into these soon. take-nthis definitely a function to keep in mind. Stefan -- -- 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/groups/opt_out.
Re: does lein2 use repositories defined in ~/.m2/settings.xml?
On Feb 21, 2013, at 4:28 AM, Michael Klishin wrote: 2013/2/21 James Xu xumingming64398...@gmail.com Thanks! But it sounds odd to me that lein does not use ~/.m2/settings.xml, why this decision? I wasn't the one who's made this decision but here's my understanding. Leiningen 2 uses Aether for dependency management. Aether doesn't use ~/.m2/settings.xml by default. Aether actually has no facilities for consuming settings.xml AFAIK — that's entirely part of the mvn toolchain, not the underlying libraries. - Chas -- -- 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/groups/opt_out.
Re: ANN Welle 1.4.0 is released
2013/2/21 Josh Kamau joshnet2...@gmail.com I like your work on various libraries. Just wondering, do you plan to do a library for HBase ? Not at the moment. There will be a new column-oriented data store client release in a couple of months. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- 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/groups/opt_out.
Re: Clojure Performance For Expensive Algorithms
Ah, yes, thought it was wrong somewhere! Stephen Compall stephen.comp...@gmail.com writes: On Feb 20, 2013 5:55 AM, Phillip Lord phillip.l...@newcastle.ac.uk wrote: (do (assoc curr (inc j) 0) (recur (inc j) max-len))) Here you're discarding the result of assoc, a pure function, which changes the code's nature significantly. (do (assoc! curr (inc j) 0) (recur (inc j) max-len))) Nor is it safe to discard the result of calling assoc!; see how assoc! is used in other online examples. -- -- 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/groups/opt_out.
Re: Google Summer of Code 2013
Hi Ambrose The general Idea is called deductive typing. In Qi you write your types by giving logical rules if a symbol is of your type. This logical rules are then used to typecheck the programm (Typecheck as a proof using depth-first search with chronoligical backtracking). The reason for this is the following: You get a turing complete language for defining types. This enables the type system to check for far more errors at compile time, which is the goal of every type system. For example you could write a type of an array with at most N elements to have array bound checks at compile time. I could also imagine, in the case of say ring defining types that represent the ring spec and generate an error at compile time when a specific non-optional key is omitted or one value has a wrong type. I think it would best be build on top of core.typed (I don't know how much of it it does already), using clojure (logic) code for defining types and utilizing core.logic for typechecking. I could be far off with my predictions because I don't know much about core.typed and core.logic internals. If you want to hear more of this please contact me and I will do further research to write a specification of the idea to see if it is applicable. Or you tell me what I wrote above is nonsense ... On Wed, Feb 20, 2013 at 5:20 PM, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: Interesting idea, but the specifics of the project are not clear to me. Could you flesh out what you're trying to achieve in particular? Would you build on top of core.logic and core.typed? Thanks, Ambrose On Thu, Feb 21, 2013 at 12:13 AM, Maik Schünemann maikschuenem...@gmail.com wrote: given the current position of core.logic and core.typed I wonder if it would be in range of a gsoc project to implement something similar to Qis type system for clojure (here is a link to an example of using Qis type system http://programmingkungfuqi.blogspot.de/2006/04/qi-and-magic-prime-type.html and it is documented in detail in the official qi book http://www.lambdassociates.org/Book/page000.htm) If something like this is possible I'w be happy to give it a try On Sat, Feb 16, 2013 at 2:43 PM, Daniel Solano Gómez cloj...@sattvik.com wrote: These sound like some good ideas. Feel free to add a core.matrix category to the project ideas page. Thanks, Daniel On Sat Feb 16 01:02 2013, Mikera wrote: Awesome stuff! core.matrix has a lot of great opportunities to work on something meaningful, and I'd be happy to mentor one or more students in this area. Top of my list would be: - Extending core.matrix support to Incanter (medium, needs collaboration with Incanter team) - A full NumPy style NDArray implementation in Clojure (large, quite advanced) - core.matrix support for data tables (e.g. database resultsets, statistical datasets etc.) (medium) Will post a proposal along these lines. On Friday, 15 February 2013 02:03:58 UTC+8, Daniel Solano Gómez wrote: Hello, all, It's official: Google Summer of Code 2013 is on. Last year, Clojure was able to get four students who worked on projects like Typed Clojure, Clojure on Android, Clojure and Lua, and Overtone, and I'd love to see Clojure be a mentoring organisation again this year. I have created a GSoC 2013 page on the Clojure community wiki http://dev.clojure.org/display/community/Google+Summer+of+Code+2013 . Here you will be able to find the latest information about what's going on with Clojure's GSoC 2013 effort and how to get involved. Here's some ways you can help: * Let people in your local user groups or university know about Clojure and GSoC. * If you're going to Clojure/West, attend the GSoC unsession. For students * Start researching project ideas and get involved with the relevant communities to find mentors. For developers: Does your open source project have a backlog of features to implement? GSoC is a great way to draw new contributors to your project. * Post it to the project idea page and become a mentor. * Let people know about GSoC on your project mailing list. I'd like to thank everyone in advance for helping with our GSoC 2013 project. Sincerely, Daniel -- -- 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
documentation for clojure core extension points - multimethods and protocols?
Does anyone have a good source of summary documentation for core clojure extension points My this I mean either defined multi-methods that are intended to be extended, such as print-method, or Protocols that are intended to be re-used? Is there similar for clojurescript? just curious at the moment. ta Dave -- -- 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/groups/opt_out.
Re: how would you implement sending out a verification email?
Hey James, That works as long as there is only one thing with side-effects. In the above example I could e.g have the sending of the email logged and so I can no longer use this method. What I'd like to see is whether the top-level construct -wrapping the sending of the email by an agent in a transaction that also updates the database record and potentially logs the fact- is the ideal one here or we can do better. Thank you. On Thursday, February 21, 2013 3:46:24 AM UTC+1, James Reichley wrote: I can't find the reference now, but either in a screencast or a discussion I read it was mentioned that if you have a single thing that performs side-effects, you can perform this function last in the transaction without worrying about any issues. The reasoning here is that if anything before it fails, the side-effect action was never attempted and if the side-effect action itself fails then the transaction rolls back like always. On Wednesday, February 20, 2013 9:32:14 AM UTC-5, Balint Erdi wrote: Hey, So yesterday we discussed concurrency at our meetup ( http://www.meetup.com/Budapest-Clojure-User-Group/) and a question occurred to me. Suppose we have a classic web application. (I'm not currently building such a web app in Clojure, so that's a theoretical question). When the user signs up, a verification email has to be sent and the database entry related to the user has to be updated (or a new datom created ;) ) to reflect the fact that we've sent out the email to the user. First, we want this to be consistent so that the verification_sent_out db field reflects whether the email has really been sent out or not. Secondly, we also want the email to only be sent out once. My first idea was to use a transaction but if the transaction retries, the email could be sent out several times. A fellow Clojurian advised the sending of the email to be performed by an agent. The agent is transaction aware so if the wrapping transaction is retried several times it only sends out the email when the transaction successfully runs. Is this how this actually works? Is there another, simpler and/or more robust solution? In the languages I come from (e.g Ruby) I'd use a library that handles the queueing and consumption of tasks. Is this how you'd do it in Clojure or it's one of these cases where Clojure itself suffices where other languages are lacking? Thank you for your answer, -- Balint -- -- 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/groups/opt_out.
Re: Faster lein
The byte cache avenue is one, allowing for AOT compilation of artifacts in the local repo on disk is another one. Here we use archiva so reloading dependencies does not even require internet. Still need to see how can this come to play with lein's dependency checking an avoid resyncing the local repo after changes to the artifacts. Phil, I can understand why you think it might be an issue, you probably play with different clojure versions on a daily basis. My work flow here is kind of different. Moving to a different Clojure version requires planning and a significant effort, it must be staged in time when we see a smooth spot in the planning were this can be done. In prod, a full AOT version would speed up startups. I have this issue with reply, just cranking up the engine is slow when doing maintenance. Luc Herwig Hochleitner writes: I understand not delivering AOT libs through maven not knowing the target environment but having a tuning tool to speed up loading by avoiding compilation would help with all the tooling starting to appear. How about a lein-bytecache plugin, that can AOT compile and manage the .class files of released jars in the ~/.cache directory. When that's up and running, leiningen could make use of it for the leiningen jar itself. Unless you want to clear the cache manually every time your dependencies change, you'd have to make a parallel tree of jars for each version of Clojure you plan on using. I think the simplest way to do this would be with a proxying repository that also cross-compiled jars to new artifacts with added classifiers as they came through. You'd also need a bit of magic on the Leiningen side with some middleware in a plugin to add classifiers to every Clojure dependency. But I have no idea how you would easily tell apart Clojure jars from Java jars without opening them up to inspect their contents, which could add a startup time penalty. Anyway, it can certainly be done. I suspect you'd get more bang for your buck by just compiling it once and not doing a clean, but protocols kind of throw a wrench in that plan when it comes to AOT. -Phil -- -- 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/groups/opt_out. -- Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad! -- -- 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/groups/opt_out.
Re: how would you implement sending out a verification email?
On 2013-02-20, at 9:32 AM, Balint Erdi balint.e...@gmail.com wrote: In the languages I come from (e.g Ruby) I'd use a library that handles the queueing and consumption of tasks. Is this how you'd do it in Clojure or it's one of these cases where Clojure itself suffices where other languages are lacking? This is how I've done it. I know this is largely a theoretical question about side-effects and STM in Clojure, but… In the end, there's always the chance that you'll send duplicate emails, all you can do is try to minimize that. There's also the chance that you never actually successfully send the email, if for no other reason than there's no way to ensure the email is received or to know if it was received. Not to mention spam filters. Using specialist email services is something to seriously consider, it'll make your job much easier, all you have to do is make sure the email request is received by the service -- there's a protocol for that. A decent service will do much better than you can do at making sure the email is sent. Cheers, Bob -- -- 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/groups/opt_out.
Re: nREPL + Emacs: How to get new definitions to load reliably?
For what it's worth, I tried using tools.namespace but if I (refresh) code that doesn't compile, then suddenly the refresh symbol is out of scope and I'm back to square one. You can still recover from this: just call 'refresh' by its fully-qualified name: (clojure.tools.namespace.repl/refresh) I use a (hackish) Emacs helper function to do this in nREPL: http://bit.ly/WUqLE4 -S -- -- 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/groups/opt_out.
assertion-forms inside macros without using eval?
Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim -- -- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.com wrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/**group/clojure?hl=enhttp://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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com . For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 --- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
I tried this and it works, but I need 2 backticks and I'm essentially generating the assert-form when the macro is called...I'd like to generate only the def-form at run-time... (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) it looks ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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 mailto: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 mailto:clojure%2bunsubscr...@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 mailto:clojure%2bunsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 --- 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/groups/opt_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 --- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
= (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(do (assert (component? ~co) Not a valid IComponent) (def ~name ~co) ) ) #'runtime.q/defcomponent = (defcomponent a (str a)) AssertionError Assert failed: Not a valid IComponent (runtime.q/component? (str a)) runtime.q/eval6570 (NO_SOURCE_FILE:1) = (defcomponent a a) AssertionError Assert failed: Not a valid IComponent (runtime.q/component? a) runtime.q/eval6572 (NO_SOURCE_FILE:1) = (defcomponent a 1) #'runtime.q/a = (defcomponent a (+ 1 3)) #'runtime.q/a On Thu, Feb 21, 2013 at 3:11 PM, AtKaaZ atk...@gmail.com wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.com wrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/**group/clojure?hl=enhttp://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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com . For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 --- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
that one doesn't actually work, maybe, not sure why exactly but the assert is ignored = (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) #'runtime.q/defcomponent = (defcomponent a a) #'runtime.q/a The `(do ...) one works though, = (defmacro a [] `(println 1) `(println 2) ) #'runtime.q/a = (a) 2 nil = (defmacro a [] `(do (println 1) (println 2) ) ) #'runtime.q/a = (a) 1 2 nil On Thu, Feb 21, 2013 at 3:14 PM, Jim foo.bar jimpil1...@gmail.com wrote: I tried this and it works, but I need 2 backticks and I'm essentially generating the assert-form when the macro is called...I'd like to generate only the def-form at run-time... (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) it looks ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.com wrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 --- 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/groups/opt_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 --- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 --- 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
Re: assertion-forms inside macros without using eval?
aaa I see! How can I be so naive some times? ;) Jim On 21/02/13 14:15, AtKaaZ wrote: = (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(do (assert (component? ~co) Not a valid IComponent) (def ~name ~co) ) ) #'runtime.q/defcomponent = (defcomponent a (str a)) AssertionError Assert failed: Not a valid IComponent (runtime.q/component? (str a)) runtime.q/eval6570 (NO_SOURCE_FILE:1) = (defcomponent a a) AssertionError Assert failed: Not a valid IComponent (runtime.q/component? a) runtime.q/eval6572 (NO_SOURCE_FILE:1) = (defcomponent a 1) #'runtime.q/a = (defcomponent a (+ 1 3)) #'runtime.q/a On Thu, Feb 21, 2013 at 3:11 PM, AtKaaZ atk...@gmail.com mailto:atk...@gmail.com wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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 mailto: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 mailto:clojure%2bunsubscr...@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 mailto:clojure%2bunsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 --- 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/groups/opt_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 --- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
I settled for: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c# Not a valid IComponent)) (def ~name c#))) Jim On 21/02/13 14:18, AtKaaZ wrote: that one doesn't actually work, maybe, not sure why exactly but the assert is ignored = (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) #'runtime.q/defcomponent = (defcomponent a a) #'runtime.q/a The `(do ...) one works though, = (defmacro a [] `(println 1) `(println 2) ) #'runtime.q/a = (a) 2 nil = (defmacro a [] `(do (println 1) (println 2) ) ) #'runtime.q/a = (a) 1 2 nil On Thu, Feb 21, 2013 at 3:14 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: I tried this and it works, but I need 2 backticks and I'm essentially generating the assert-form when the macro is called...I'd like to generate only the def-form at run-time... (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) it looks ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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 mailto: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 mailto:clojure%2bunsubscr...@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 mailto:clojure%2bunsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 mailto: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 mailto: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 mailto:clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_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 mailto: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 mailto:clojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You
Re: assertion-forms inside macros without using eval?
that's much better, evaluated only once, thanks. On Thu, Feb 21, 2013 at 3:20 PM, Jim foo.bar jimpil1...@gmail.com wrote: I settled for: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c# Not a valid IComponent)) (def ~name c#))) Jim On 21/02/13 14:18, AtKaaZ wrote: that one doesn't actually work, maybe, not sure why exactly but the assert is ignored = (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) #'runtime.q/defcomponent = (defcomponent a a) #'runtime.q/a The `(do ...) one works though, = (defmacro a [] `(println 1) `(println 2) ) #'runtime.q/a = (a) 2 nil = (defmacro a [] `(do (println 1) (println 2) ) ) #'runtime.q/a = (a) 1 2 nil On Thu, Feb 21, 2013 at 3:14 PM, Jim foo.bar jimpil1...@gmail.com wrote: I tried this and it works, but I need 2 backticks and I'm essentially generating the assert-form when the macro is called...I'd like to generate only the def-form at run-time... (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) it looks ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.comwrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 --- 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/groups/opt_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 --- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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
Re: assertion-forms inside macros without using eval?
oops major typo! the correct is: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) Not a valid IComponent) (def ~name c#))) However, this doesn't work! Something weird with the assertion...If I comment it out it works as expected, otherwise the var is unbound at the end! strange stuffI may end up using 'eval' as I used to... Jim On 21/02/13 14:20, Jim foo.bar wrote: I settled for: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c# Not a valid IComponent)) (def ~name c#))) Jim On 21/02/13 14:18, AtKaaZ wrote: that one doesn't actually work, maybe, not sure why exactly but the assert is ignored = (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) #'runtime.q/defcomponent = (defcomponent a a) #'runtime.q/a The `(do ...) one works though, = (defmacro a [] `(println 1) `(println 2) ) #'runtime.q/a = (a) 2 nil = (defmacro a [] `(do (println 1) (println 2) ) ) #'runtime.q/a = (a) 1 2 nil On Thu, Feb 21, 2013 at 3:14 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: I tried this and it works, but I need 2 backticks and I'm essentially generating the assert-form when the macro is called...I'd like to generate only the def-form at run-time... (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) it looks ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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 mailto: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 mailto:clojure%2bunsubscr...@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 mailto:clojure%2bunsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 mailto: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 mailto: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 mailto:clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,
Re: assertion-forms inside macros without using eval?
(defmacro defcomponent [name co] `(do (def ~name ~co) (set-validator! (var ~name) component?))) Maybe like this? (Untested) Kind regards 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 --- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
with eval it may not work as you expected + the double evaluation (def component? nil?) = (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co) ) #'runtime.q/defcomponent = (defcomponent a (println a)) a a #'runtime.q/a = (let [aa a] (defcomponent a (println aa)) ) CompilerException java.lang.InstantiationException: runtime.q$eval10641$eval10642__10643, compiling:(NO_SOURCE_PATH:2:3) = (let [aa a] (defcomponent a aa) ) CompilerException java.lang.UnsupportedOperationException: Can't eval locals, compiling:(NO_SOURCE_PATH:2:3) On Thu, Feb 21, 2013 at 3:29 PM, Jim foo.bar jimpil1...@gmail.com wrote: oops major typo! the correct is: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) Not a valid IComponent) (def ~name c#))) However, this doesn't work! Something weird with the assertion...If I comment it out it works as expected, otherwise the var is unbound at the end! strange stuffI may end up using 'eval' as I used to... Jim On 21/02/13 14:20, Jim foo.bar wrote: I settled for: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c# Not a valid IComponent)) (def ~name c#))) Jim On 21/02/13 14:18, AtKaaZ wrote: that one doesn't actually work, maybe, not sure why exactly but the assert is ignored = (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) #'runtime.q/defcomponent = (defcomponent a a) #'runtime.q/a The `(do ...) one works though, = (defmacro a [] `(println 1) `(println 2) ) #'runtime.q/a = (a) 2 nil = (defmacro a [] `(do (println 1) (println 2) ) ) #'runtime.q/a = (a) 1 2 nil On Thu, Feb 21, 2013 at 3:14 PM, Jim foo.bar jimpil1...@gmail.com wrote: I tried this and it works, but I need 2 backticks and I'm essentially generating the assert-form when the macro is called...I'd like to generate only the def-form at run-time... (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) it looks ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.comwrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 --- 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/groups/opt_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
Creating a hash-map with conditional keys
Hello, I am trying to figure out how to make the following elegantly in clojure. I have a hash-map which has some key-value pairs and I would like to append to that hash-map a couple more key-value pairs IF some specific condition is met. For example, the create-map creates the main hash-map but i would like *to merge* the map with the value returned from create-key-value, if the condition inside that function is met. (defn create-key-value [value] (when (some-condition-true) {:extra-key extra-value)) (defn create-map [] {:foo a :bar b}) The final, merged, map should look like this *if* create-key-value returned the :extra-key {:foo a, :bar b, :extra-key extra-value} ...or if it didn't to return this: {:foo a, :bar b} I did find a proposed solution on a stackoverflow posthttp://stackoverflow.com/questions/8992997/initializing-elements-of-a-map-conditionally-in-clojure, but I am not sure if that's the most elegant way. Thank you for your time. Regards, Ryan -- -- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
I think the assert is working but either something eats up the thrown exception silently which would explain why def isn't reached, OR the defcomponent is never called, OR it is called with a different name param as you'd have expected. Try putting something before the assert to log if that point was ever reached. On Thu, Feb 21, 2013 at 3:29 PM, Jim foo.bar jimpil1...@gmail.com wrote: oops major typo! the correct is: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) Not a valid IComponent) (def ~name c#))) However, this doesn't work! Something weird with the assertion...If I comment it out it works as expected, otherwise the var is unbound at the end! strange stuffI may end up using 'eval' as I used to... Jim On 21/02/13 14:20, Jim foo.bar wrote: I settled for: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c# Not a valid IComponent)) (def ~name c#))) Jim On 21/02/13 14:18, AtKaaZ wrote: that one doesn't actually work, maybe, not sure why exactly but the assert is ignored = (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) #'runtime.q/defcomponent = (defcomponent a a) #'runtime.q/a The `(do ...) one works though, = (defmacro a [] `(println 1) `(println 2) ) #'runtime.q/a = (a) 2 nil = (defmacro a [] `(do (println 1) (println 2) ) ) #'runtime.q/a = (a) 1 2 nil On Thu, Feb 21, 2013 at 3:14 PM, Jim foo.bar jimpil1...@gmail.com wrote: I tried this and it works, but I need 2 backticks and I'm essentially generating the assert-form when the macro is called...I'd like to generate only the def-form at run-time... (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) it looks ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.comwrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 --- 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/groups/opt_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 --- You received this message because you are
Re: assertion-forms inside macros without using eval?
Hi Meikel, This seems to work but returns nil and so you can't see that a new var has been defined! cluja.core= (defcomponent maxent-person maxent) nil cluja.core= maxent-person ;;was it defined? #NameFinderME opennlp.tools.namefind.NameFinderME@2019666a ;;yes it was! Jim On 21/02/13 14:42, Meikel Brandmeyer (kotarak) wrote: (defmacro defcomponent [name co] `(do (def ~name ~co) (set-validator! (var ~name) component?))) Maybe like this? (Untested) Kind regards 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 --- 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/groups/opt_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 --- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
Then simply add a (var ~name) as last statement in the do. Kind regards 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 --- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
Yes you're right, this does the trick...However now I've ended up unquoting 'name' 3 times! I'm pretty sure this not a good practice in general, is it? On the other hand I cannot use 'gensym' cos I want the name intact or later access...hmmm...I never expected this would be so confusing! Jim On 21/02/13 14:52, Meikel Brandmeyer (kotarak) wrote: Then simply add a (var ~name) as last statement in the do. Kind regards 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 --- 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/groups/opt_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 --- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
Moreover, now the exception thrown when the validation fails is not very informative! IllegalStateException Invalid reference state clojure.lang.ARef.validate (ARef.java:33) assert let's you speciy the message you want that is why I preferred it... Jim On 21/02/13 14:56, Jim foo.bar wrote: Yes you're right, this does the trick...However now I've ended up unquoting 'name' 3 times! I'm pretty sure this not a good practice in general, is it? On the other hand I cannot use 'gensym' cos I want the name intact or later access...hmmm...I never expected this would be so confusing! Jim On 21/02/13 14:52, Meikel Brandmeyer (kotarak) wrote: Then simply add a (var ~name) as last statement in the do. Kind regards 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 --- 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/groups/opt_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 --- 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/groups/opt_out.
Re: Creating a hash-map with conditional keys
Hi, merge works with nil. So (merge (create-map) (create-key-value some-value)) should work as you intend with the functions as they are defined now. Kind regards 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 --- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
this is what i'd use (def component? number?) *(defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) (str Not a valid IComponent passed:\nevaluated form: ` (pr-str c#) `\noriginal form: ` '~co `\nfull form: ` '~form ` \nlocation: ~(meta form) file: ~*file* )) (def ~name c#) ) )* = *assert* true = (defcomponent a (do a (str b))) AssertionError Assert failed: Not a valid IComponent passed: evaluated form: `b` original form: `(do a (str b))` full form: `(defcomponent a (do a (str b)))` location: {:column 1, :line 96} file: util\funxions.clj (util.funxions/component? c__33004__auto__) util.funxions/eval33010 (funxions.clj:96) (defcomponent a (do a (str b))) =* (defcomponent a (+ 1 2))* #'runtime.q/a = a 3 On Thu, Feb 21, 2013 at 3:51 PM, AtKaaZ atk...@gmail.com wrote: I think the assert is working but either something eats up the thrown exception silently which would explain why def isn't reached, OR the defcomponent is never called, OR it is called with a different name param as you'd have expected. Try putting something before the assert to log if that point was ever reached. On Thu, Feb 21, 2013 at 3:29 PM, Jim foo.bar jimpil1...@gmail.com wrote: oops major typo! the correct is: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) Not a valid IComponent) (def ~name c#))) However, this doesn't work! Something weird with the assertion...If I comment it out it works as expected, otherwise the var is unbound at the end! strange stuffI may end up using 'eval' as I used to... Jim On 21/02/13 14:20, Jim foo.bar wrote: I settled for: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c# Not a valid IComponent)) (def ~name c#))) Jim On 21/02/13 14:18, AtKaaZ wrote: that one doesn't actually work, maybe, not sure why exactly but the assert is ignored = (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) #'runtime.q/defcomponent = (defcomponent a a) #'runtime.q/a The `(do ...) one works though, = (defmacro a [] `(println 1) `(println 2) ) #'runtime.q/a = (a) 2 nil = (defmacro a [] `(do (println 1) (println 2) ) ) #'runtime.q/a = (a) 1 2 nil On Thu, Feb 21, 2013 at 3:14 PM, Jim foo.bar jimpil1...@gmail.comwrote: I tried this and it works, but I need 2 backticks and I'm essentially generating the assert-form when the macro is called...I'd like to generate only the def-form at run-time... (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) it looks ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.comwrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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
Re: assertion-forms inside macros without using eval?
I apologise...this works almost perfectly: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) Not a valid IComponent) (def ~name c#))) the only slight problem is the error thrown which has the gensym symbol in the flailing condition...Well, I can't have everything can I? :) Jim On 21/02/13 14:51, AtKaaZ wrote: I think the assert is working but either something eats up the thrown exception silently which would explain why def isn't reached, OR the defcomponent is never called, OR it is called with a different name param as you'd have expected. Try putting something before the assert to log if that point was ever reached. On Thu, Feb 21, 2013 at 3:29 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: oops major typo! the correct is: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) Not a valid IComponent) (def ~name c#))) However, this doesn't work! Something weird with the assertion...If I comment it out it works as expected, otherwise the var is unbound at the end! strange stuffI may end up using 'eval' as I used to... Jim On 21/02/13 14:20, Jim foo.bar wrote: I settled for: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c# Not a valid IComponent)) (def ~name c#))) Jim On 21/02/13 14:18, AtKaaZ wrote: that one doesn't actually work, maybe, not sure why exactly but the assert is ignored = (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) #'runtime.q/defcomponent = (defcomponent a a) #'runtime.q/a The `(do ...) one works though, = (defmacro a [] `(println 1) `(println 2) ) #'runtime.q/a = (a) 2 nil = (defmacro a [] `(do (println 1) (println 2) ) ) #'runtime.q/a = (a) 1 2 nil On Thu, Feb 21, 2013 at 3:14 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: I tried this and it works, but I need 2 backticks and I'm essentially generating the assert-form when the macro is called...I'd like to generate only the def-form at run-time... (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) it looks ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.com mailto:jimpil1...@gmail.com wrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want to assert on it...I cannot use 'defn' (it will cause 'name' to be evaluated) so my only option is a macro that forces eval on the second arg, yes? Jim -- -- 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 mailto: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 mailto:clojure%2bunsubscr...@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 mailto:clojure%2bunsubscr...@googlegroups.com.
Re: assertion-forms inside macros without using eval?
Hi, Am Donnerstag, 21. Februar 2013 16:08:36 UTC+1 schrieb Jim foo.bar: I apologise...this works almost perfectly: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) Not a valid IComponent) (def ~name c#))) the only slight problem is the error thrown which has the gensym symbol in the flailing condition...Well, I can't have everything can I? :) (defmacro defcomponent [name co] `(do (def ~name) (let [c# ~co] (assert (component? c#) Not a valid IComponent) (alter-var-root! (var ~name) (constantly c#))) (var ~name Since name is an argument to def it can only ever be a literal symbol. Kind regards 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 --- 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/groups/opt_out.
Re: Creating a hash-map with conditional keys
Thanks Meikel for your reply. It wasn't clear on my example, but I wish to use *merge *inside my create-map function. Do you think I should bind my hash-map to a let variable first and then apply merge, or do you have another proposal? What i mean is this: (defn create-key-value [value] (when (some-condition-true) {:extra-key value)) (defn create-map [] (let [my-map {:foo a :bar b}] (merge my-map (create-key-value some-value))) Is the above clojurish or is there a better way? For example if the my-map was a big hash-map, and not with just two pairs, wouldn't it be ugly with the above way? or..it's just fine and no better way is possible? Ryan On Thursday, February 21, 2013 5:02:21 PM UTC+2, Meikel Brandmeyer (kotarak) wrote: Hi, merge works with nil. So (merge (create-map) (create-key-value some-value)) should work as you intend with the functions as they are defined now. Kind regards 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 --- 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/groups/opt_out.
Re: a bit mystified by unchecked-multiply
Great, thanks! So if one is an object and one is a primitive is one of these not true? user= (type seed1) java.lang.Long user= (type 25214903917) java.lang.Long Cheers, John. On Wednesday, February 20, 2013 11:44:44 PM UTC, Herwig Hochleitner wrote: I agree that unchecked-multiply should do an unchecked multiply, even when faced with objects. Going to bring that up on clojure-dev. A workaround: (unchecked-multiply (long seed1) 0x5DEECE66D) -- -- 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/groups/opt_out.
Re: Creating a hash-map with conditional keys
I'd often just write it like this: (defn create-map [] (merge {:foo a :bar b ... many more keys} (when (some-condition-true) {:extra-key value))) Alex On Thu, Feb 21, 2013 at 7:27 AM, Ryan arekand...@gmail.com wrote: Thanks Meikel for your reply. It wasn't clear on my example, but I wish to use *merge *inside my create-map function. Do you think I should bind my hash-map to a let variable first and then apply merge, or do you have another proposal? What i mean is this: (defn create-key-value [value] (when (some-condition-true) {:extra-key value)) (defn create-map [] (let [my-map {:foo a :bar b}] (merge my-map (create-key-value some-value))) Is the above clojurish or is there a better way? For example if the my-map was a big hash-map, and not with just two pairs, wouldn't it be ugly with the above way? or..it's just fine and no better way is possible? Ryan On Thursday, February 21, 2013 5:02:21 PM UTC+2, Meikel Brandmeyer (kotarak) wrote: Hi, merge works with nil. So (merge (create-map) (create-key-value some-value)) should work as you intend with the functions as they are defined now. Kind regards 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 --- 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/groups/opt_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 --- 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/groups/opt_out.
Re: Creating a hash-map with conditional keys
Another alternative way, added in Clojure 1.5, can be nice if you have a lot of conditionally-added key-value pairs: (defn create-map [] (cond- {:base :map} (pred1) (assoc :extra-key1 value) (pred2) (assoc :extra-key2 value) (pred3) (assoc :extra-key3 value) (pred4) (assoc :extra-key4 value))) On Thu, Feb 21, 2013 at 7:41 AM, Alex Baranosky alexander.barano...@gmail.com wrote: I'd often just write it like this: (defn create-map [] (merge {:foo a :bar b ... many more keys} (when (some-condition-true) {:extra-key value))) Alex On Thu, Feb 21, 2013 at 7:27 AM, Ryan arekand...@gmail.com wrote: Thanks Meikel for your reply. It wasn't clear on my example, but I wish to use *merge *inside my create-map function. Do you think I should bind my hash-map to a let variable first and then apply merge, or do you have another proposal? What i mean is this: (defn create-key-value [value] (when (some-condition-true) {:extra-key value)) (defn create-map [] (let [my-map {:foo a :bar b}] (merge my-map (create-key-value some-value))) Is the above clojurish or is there a better way? For example if the my-map was a big hash-map, and not with just two pairs, wouldn't it be ugly with the above way? or..it's just fine and no better way is possible? Ryan On Thursday, February 21, 2013 5:02:21 PM UTC+2, Meikel Brandmeyer (kotarak) wrote: Hi, merge works with nil. So (merge (create-map) (create-key-value some-value)) should work as you intend with the functions as they are defined now. Kind regards 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 --- 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/groups/opt_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 --- 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/groups/opt_out.
Re: Creating a hash-map with conditional keys
Thanks for your input Alex. Do you think a macro would be appropriate if I use this more than once in my code? Ryan On Thursday, February 21, 2013 5:41:49 PM UTC+2, Alex Baranosky wrote: I'd often just write it like this: (defn create-map [] (merge {:foo a :bar b ... many more keys} (when (some-condition-true) {:extra-key value))) Alex On Thu, Feb 21, 2013 at 7:27 AM, Ryan areka...@gmail.com javascript:wrote: Thanks Meikel for your reply. It wasn't clear on my example, but I wish to use *merge *inside my create-map function. Do you think I should bind my hash-map to a let variable first and then apply merge, or do you have another proposal? What i mean is this: (defn create-key-value [value] (when (some-condition-true) {:extra-key value)) (defn create-map [] (let [my-map {:foo a :bar b}] (merge my-map (create-key-value some-value))) Is the above clojurish or is there a better way? For example if the my-map was a big hash-map, and not with just two pairs, wouldn't it be ugly with the above way? or..it's just fine and no better way is possible? Ryan On Thursday, February 21, 2013 5:02:21 PM UTC+2, Meikel Brandmeyer (kotarak) wrote: Hi, merge works with nil. So (merge (create-map) (create-key-value some-value)) should work as you intend with the functions as they are defined now. Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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 javascript:. For more options, visit https://groups.google.com/groups/opt_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 --- 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/groups/opt_out.
Bumi, a project for loading a git repo into a Titan graph database
https://github.com/zmaril/bumi Bumi loads a git repo into a Titan graph database[0]. You can then ask questions about the history of the project with Faunus[1]. I've successfully loaded the Linux kernel onto an AWS instance. I'm working now to start asking good questions and see if I can't find out anything neat. Any suggestions about paths of investigation to pursue would fall on open ears. I'm open sourcing this now in case anybody wants to play around with it. In theory, it should work with any git repo. In practice, I've only tested it on the Linux kernel so far. It's written in Clojure, using Hermes[2]. -Zack [0] http://thinkaurelius.github.com/titan/ [1] http://thinkaurelius.github.com/faunus/ [2] https://github.com/gameclosure/hermes -- -- 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/groups/opt_out.
Re: assertion-forms inside macros without using eval?
I'd actually use this myself: ;the following is inspired from http://blog.jayfields.com/2011/02/clojure-and.html (defmacro get-lexical-env [] = (let [a 1 b (+ 1 2)] (let [c (do \a\ \b\)] (q/get-lexical-env) ) ) {a 1, b 3, c \b\} (let [envkeys (keys env)] `(zipmap (quote ~envkeys) (list ~@envkeys)) ) ) (defmacro show-lexical-env [] `(prn (get-lexical-env)) ) (def component? number?) (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) (str Not a valid IComponent passed:\nevaluated form: ` (pr-str c#) `\noriginal form: ` '~co `\nfull form: ` '~form ` \nlocation: ~(meta form) file: ~*file* \ncurrent lexical env: (get-lexical-env) \n )) (def ~name c#) ) ) (defcomponent a (do a (str b))) AssertionError Assert failed: Not a valid IComponent passed: evaluated form: `b` original form: `(do a (str b))` full form: `(defcomponent a (do a (str b)))` location: {:column 1, :line 17} file: NO_SOURCE_PATH current lexical env: {c__38734__auto__ b} (util.funxions/component? c__38734__auto__) util.funxions/eval38740 (NO_SOURCE_FILE:17) On Thu, Feb 21, 2013 at 4:08 PM, AtKaaZ atk...@gmail.com wrote: this is what i'd use (def component? number?) * (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) (str Not a valid IComponent passed:\nevaluated form: ` (pr-str c#) `\noriginal form: ` '~co `\nfull form: ` '~form ` \nlocation: ~(meta form) file: ~*file* )) (def ~name c#) ) )* = *assert* true = (defcomponent a (do a (str b))) AssertionError Assert failed: Not a valid IComponent passed: evaluated form: `b` original form: `(do a (str b))` full form: `(defcomponent a (do a (str b)))` location: {:column 1, :line 96} file: util\funxions.clj (util.funxions/component? c__33004__auto__) util.funxions/eval33010 (funxions.clj:96) (defcomponent a (do a (str b))) =* (defcomponent a (+ 1 2))* #'runtime.q/a = a 3 On Thu, Feb 21, 2013 at 3:51 PM, AtKaaZ atk...@gmail.com wrote: I think the assert is working but either something eats up the thrown exception silently which would explain why def isn't reached, OR the defcomponent is never called, OR it is called with a different name param as you'd have expected. Try putting something before the assert to log if that point was ever reached. On Thu, Feb 21, 2013 at 3:29 PM, Jim foo.bar jimpil1...@gmail.comwrote: oops major typo! the correct is: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c#) Not a valid IComponent) (def ~name c#))) However, this doesn't work! Something weird with the assertion...If I comment it out it works as expected, otherwise the var is unbound at the end! strange stuffI may end up using 'eval' as I used to... Jim On 21/02/13 14:20, Jim foo.bar wrote: I settled for: (defmacro defcomponent [name co] `(let [c# ~co] (assert (component? c# Not a valid IComponent)) (def ~name c#))) Jim On 21/02/13 14:18, AtKaaZ wrote: that one doesn't actually work, maybe, not sure why exactly but the assert is ignored = (def component? number?) #'runtime.q/component? = (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) #'runtime.q/defcomponent = (defcomponent a a) #'runtime.q/a The `(do ...) one works though, = (defmacro a [] `(println 1) `(println 2) ) #'runtime.q/a = (a) 2 nil = (defmacro a [] `(do (println 1) (println 2) ) ) #'runtime.q/a = (a) 1 2 nil On Thu, Feb 21, 2013 at 3:14 PM, Jim foo.bar jimpil1...@gmail.comwrote: I tried this and it works, but I need 2 backticks and I'm essentially generating the assert-form when the macro is called...I'd like to generate only the def-form at run-time... (defmacro defcomponent [name co] `(assert (component? ~co) Not a valid IComponent) `(def ~name ~co)) it looks ugly doesn't it? Jim On 21/02/13 14:11, AtKaaZ wrote: or you could place the assert inside the backquote On Thu, Feb 21, 2013 at 3:10 PM, Jim foo.bar jimpil1...@gmail.comwrote: On 21/02/13 14:07, Jim foo.bar wrote: Hi all, I''d like to have a macro like the following but preferably without the 'eval' inside the assertion form: (defmacro defcomponent [name co] (assert (component? (eval co)) Not a valid IComponent) `(def ~name ~co)) If I don't use eval, everything works as long as I pass a var in...However if I pass in something like (String. jam) it is not being evaluated and thus is a list not an object...and it will never satisfy IComponent. any thoughts? thanks in advance :) Jim I could have phrased this better...One of my arguments has to NOT be evaluated (name) but the other needs to be evaluated (co) so I can assert whatever I want
Re: Bumi, a project for loading a git repo into a Titan graph database
On Feb 21, 2013, at 08:00, Zack Maril wrote: Bumi loads a git repo into a Titan graph database[0]. You can then ask questions about the history of the project with Faunus[1]. I've successfully loaded the Linux kernel onto an AWS instance. I'm working now to start asking good questions and see if I can't find out anything neat. Any suggestions about paths of investigation to pursue would fall on open ears. ... Rich Hickey's Codeq project http://blog.datomic.com/2012/10/codeq.html extracts both metadata and code quanta (semantically meaningful code snippets) from Git repos. This allows it to answer questions about (say) code churn and hot spots in terms of individual functions, etc. It also (implicitly) opens the door to other information sources (eg, dynamically harvested metadata). I would urge you to consider (a) what can be learned from Codeq and (b) whether any sort of cooperation and/or interoperability might be possible. -r -- http://www.cfcl.com/rdmRich Morin http://www.cfcl.com/rdm/resume r...@cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Software system design, development, and documentation -- -- 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/groups/opt_out.
Re: Creating a hash-map with conditional keys
A function could be appropriate, but a macro not appropriate, since everything you need here can be done with using macros. On Feb 21, 2013 7:53 AM, Ryan arekand...@gmail.com wrote: Thanks for your input Alex. Do you think a macro would be appropriate if I use this more than once in my code? Ryan On Thursday, February 21, 2013 5:41:49 PM UTC+2, Alex Baranosky wrote: I'd often just write it like this: (defn create-map [] (merge {:foo a :bar b ... many more keys} (when (some-condition-true) {:extra-key value))) Alex On Thu, Feb 21, 2013 at 7:27 AM, Ryan areka...@gmail.com wrote: Thanks Meikel for your reply. It wasn't clear on my example, but I wish to use *merge *inside my create-map function. Do you think I should bind my hash-map to a let variable first and then apply merge, or do you have another proposal? What i mean is this: (defn create-key-value [value] (when (some-condition-true) {:extra-key value)) (defn create-map [] (let [my-map {:foo a :bar b}] (merge my-map (create-key-value some-value))) Is the above clojurish or is there a better way? For example if the my-map was a big hash-map, and not with just two pairs, wouldn't it be ugly with the above way? or..it's just fine and no better way is possible? Ryan On Thursday, February 21, 2013 5:02:21 PM UTC+2, Meikel Brandmeyer (kotarak) wrote: Hi, merge works with nil. So (merge (create-map) (create-key-value some-value)) should work as you intend with the functions as they are defined now. Kind regards Meikel -- -- 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=enhttp://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/**groups/opt_outhttps://groups.google.com/groups/opt_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 --- 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/groups/opt_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 --- 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/groups/opt_out.
Re: Creating a hash-map with conditional keys
I got confused a bit with the reason that a macro would not be appropriate for this case. Can you please explain again? Ryan On Thursday, February 21, 2013 7:05:11 PM UTC+2, Alex Baranosky wrote: A function could be appropriate, but a macro not appropriate, since everything you need here can be done with using macros. On Feb 21, 2013 7:53 AM, Ryan areka...@gmail.com javascript: wrote: Thanks for your input Alex. Do you think a macro would be appropriate if I use this more than once in my code? Ryan On Thursday, February 21, 2013 5:41:49 PM UTC+2, Alex Baranosky wrote: I'd often just write it like this: (defn create-map [] (merge {:foo a :bar b ... many more keys} (when (some-condition-true) {:extra-key value))) Alex On Thu, Feb 21, 2013 at 7:27 AM, Ryan areka...@gmail.com wrote: Thanks Meikel for your reply. It wasn't clear on my example, but I wish to use *merge *inside my create-map function. Do you think I should bind my hash-map to a let variable first and then apply merge, or do you have another proposal? What i mean is this: (defn create-key-value [value] (when (some-condition-true) {:extra-key value)) (defn create-map [] (let [my-map {:foo a :bar b}] (merge my-map (create-key-value some-value))) Is the above clojurish or is there a better way? For example if the my-map was a big hash-map, and not with just two pairs, wouldn't it be ugly with the above way? or..it's just fine and no better way is possible? Ryan On Thursday, February 21, 2013 5:02:21 PM UTC+2, Meikel Brandmeyer (kotarak) wrote: Hi, merge works with nil. So (merge (create-map) (create-key-value some-value)) should work as you intend with the functions as they are defined now. Kind regards Meikel -- -- 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=enhttp://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/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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 javascript:. For more options, visit https://groups.google.com/groups/opt_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 --- 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/groups/opt_out.
Re: Bumi, a project for loading a git repo into a Titan graph database
codeq looks fantastic and I've looked into using it before. The project seems to have undergone a flurry of activity last October/November and then nothing has really happened with it since then. I haven't seen anybody actually do anything impressive with it, so I decided to write Bumi instead. If you can point me towards an example of someone doing something nontrivial with the project, then I'd happily reconsider starting another code analysis project in clojure. codeq looks fantastically powerful from the outside, but nobody has done anything yet with it that would actually exhibit this perceived power. Which worries me, since if it were so powerful, somebody would have easily done something neat with it by now and talked about it. The lack of results implies to me that it might not be as powerful or useful as people say. -Zack On Thursday, February 21, 2013 8:19:59 PM UTC+4, Rich Morin wrote: On Feb 21, 2013, at 08:00, Zack Maril wrote: Bumi loads a git repo into a Titan graph database[0]. You can then ask questions about the history of the project with Faunus[1]. I've successfully loaded the Linux kernel onto an AWS instance. I'm working now to start asking good questions and see if I can't find out anything neat. Any suggestions about paths of investigation to pursue would fall on open ears. ... Rich Hickey's Codeq project http://blog.datomic.com/2012/10/codeq.html extracts both metadata and code quanta (semantically meaningful code snippets) from Git repos. This allows it to answer questions about (say) code churn and hot spots in terms of individual functions, etc. It also (implicitly) opens the door to other information sources (eg, dynamically harvested metadata). I would urge you to consider (a) what can be learned from Codeq and (b) whether any sort of cooperation and/or interoperability might be possible. -r -- http://www.cfcl.com/rdmRich Morin http://www.cfcl.com/rdm/resume r...@cfcl.com javascript: http://www.cfcl.com/rdm/weblog +1 650-873-7841 Software system design, development, and documentation -- -- 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/groups/opt_out.
Re: Creating a hash-map with conditional keys
Macros should be avoided if you don't need them. Otherwise they drastically reduce code readability. In this case you just have some predicates and maps that need to be combined conditionally, so nothing macros do is needed. The real question here is why you would need a macro? Macros usage is, to me, a question of need, meaning I need to convince myself that you need it or I wouldn't sacrifice code readability for it. Things macros are good for: - delayed code evaluation - DSL creation - moving computation to compile time (comes up occasionally) - other metaprogramming, which I usually only consider worth it if it reduces duplication enough Alex On Thu, Feb 21, 2013 at 9:11 AM, Ryan arekand...@gmail.com wrote: I got confused a bit with the reason that a macro would not be appropriate for this case. Can you please explain again? Ryan On Thursday, February 21, 2013 7:05:11 PM UTC+2, Alex Baranosky wrote: A function could be appropriate, but a macro not appropriate, since everything you need here can be done with using macros. On Feb 21, 2013 7:53 AM, Ryan areka...@gmail.com wrote: Thanks for your input Alex. Do you think a macro would be appropriate if I use this more than once in my code? Ryan On Thursday, February 21, 2013 5:41:49 PM UTC+2, Alex Baranosky wrote: I'd often just write it like this: (defn create-map [] (merge {:foo a :bar b ... many more keys} (when (some-condition-true) {:extra-key value))) Alex On Thu, Feb 21, 2013 at 7:27 AM, Ryan areka...@gmail.com wrote: Thanks Meikel for your reply. It wasn't clear on my example, but I wish to use *merge *inside my create-map function. Do you think I should bind my hash-map to a let variable first and then apply merge, or do you have another proposal? What i mean is this: (defn create-key-value [value] (when (some-condition-true) {:extra-key value)) (defn create-map [] (let [my-map {:foo a :bar b}] (merge my-map (create-key-value some-value))) Is the above clojurish or is there a better way? For example if the my-map was a big hash-map, and not with just two pairs, wouldn't it be ugly with the above way? or..it's just fine and no better way is possible? Ryan On Thursday, February 21, 2013 5:02:21 PM UTC+2, Meikel Brandmeyer (kotarak) wrote: Hi, merge works with nil. So (merge (create-map) (create-key-value some-value)) should work as you intend with the functions as they are defined now. Kind regards Meikel -- -- 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=enhttp://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/**grou**ps/opt_outhttps://groups.google.com/groups/opt_out . -- -- 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=enhttp://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/**groups/opt_outhttps://groups.google.com/groups/opt_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 --- 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/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,
Re: Creating a hash-map with conditional keys
I think Alex is trying to say that a macro is almost never appropriate when a first-class function would do...therefore, there is no good reason for carrying the complexity of macros all over your code, given that in your case they do nothing special (like postponed evaluation) and can be replaced by functions. Jim On 21/02/13 17:11, Ryan wrote: I got confused a bit with the reason that a macro would not be appropriate for this case. Can you please explain again? Ryan On Thursday, February 21, 2013 7:05:11 PM UTC+2, Alex Baranosky wrote: A function could be appropriate, but a macro not appropriate, since everything you need here can be done with using macros. On Feb 21, 2013 7:53 AM, Ryan areka...@gmail.com javascript: wrote: Thanks for your input Alex. Do you think a macro would be appropriate if I use this more than once in my code? Ryan On Thursday, February 21, 2013 5:41:49 PM UTC+2, Alex Baranosky wrote: I'd often just write it like this: (defn create-map [] (merge {:foo a :bar b ... many more keys} (when (some-condition-true) {:extra-key value))) Alex On Thu, Feb 21, 2013 at 7:27 AM, Ryan areka...@gmail.com wrote: Thanks Meikel for your reply. It wasn't clear on my example, but I wish to use *merge *inside my create-map function. Do you think I should bind my hash-map to a let variable first and then apply merge, or do you have another proposal? What i mean is this: (defn create-key-value [value] (when (some-condition-true) {:extra-key value)) (defn create-map [] (let [my-map {:foo a :bar b}] (merge my-map (create-key-value some-value))) Is the above clojurish or is there a better way? For example if the my-map was a big hash-map, and not with just two pairs, wouldn't it be ugly with the above way? or..it's just fine and no better way is possible? Ryan On Thursday, February 21, 2013 5:02:21 PM UTC+2, Meikel Brandmeyer (kotarak) wrote: Hi, merge works with nil. So (merge (create-map) (create-key-value some-value)) should work as you intend with the functions as they are defined now. Kind regards Meikel -- -- 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 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/groups/opt_out https://groups.google.com/groups/opt_out. -- -- 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 javascript: 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 javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en 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 javascript:. For more options, visit https://groups.google.com/groups/opt_out https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post
Re: Creating a hash-map with conditional keys
Thank you both for your answers Regards, Ryan On Thursday, February 21, 2013 7:43:05 PM UTC+2, Jim foo.bar wrote: I think Alex is trying to say that a macro is almost never appropriate when a first-class function would do...therefore, there is no good reason for carrying the complexity of macros all over your code, given that in your case they do nothing special (like postponed evaluation) and can be replaced by functions. Jim On 21/02/13 17:11, Ryan wrote: I got confused a bit with the reason that a macro would not be appropriate for this case. Can you please explain again? Ryan On Thursday, February 21, 2013 7:05:11 PM UTC+2, Alex Baranosky wrote: A function could be appropriate, but a macro not appropriate, since everything you need here can be done with using macros. On Feb 21, 2013 7:53 AM, Ryan areka...@gmail.com wrote: Thanks for your input Alex. Do you think a macro would be appropriate if I use this more than once in my code? Ryan On Thursday, February 21, 2013 5:41:49 PM UTC+2, Alex Baranosky wrote: I'd often just write it like this: (defn create-map [] (merge {:foo a :bar b ... many more keys} (when (some-condition-true) {:extra-key value))) Alex On Thu, Feb 21, 2013 at 7:27 AM, Ryan areka...@gmail.com wrote: Thanks Meikel for your reply. It wasn't clear on my example, but I wish to use *merge *inside my create-map function. Do you think I should bind my hash-map to a let variable first and then apply merge, or do you have another proposal? What i mean is this: (defn create-key-value [value] (when (some-condition-true) {:extra-key value)) (defn create-map [] (let [my-map {:foo a :bar b}] (merge my-map (create-key-value some-value))) Is the above clojurish or is there a better way? For example if the my-map was a big hash-map, and not with just two pairs, wouldn't it be ugly with the above way? or..it's just fine and no better way is possible? Ryan On Thursday, February 21, 2013 5:02:21 PM UTC+2, Meikel Brandmeyer (kotarak) wrote: Hi, merge works with nil. So (merge (create-map) (create-key-value some-value)) should work as you intend with the functions as they are defined now. Kind regards Meikel -- -- 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/groups/opt_out. -- -- 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/groups/opt_out. -- -- 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 javascript: 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 javascript: 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 javascript:. For more options, visit https://groups.google.com/groups/opt_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 --- You received this message because you are subscribed
Re: does lein2 use repositories defined in ~/.m2/settings.xml?
James Xu writes: Thanks! But it sounds odd to me that lein does not use ~/.m2/settings.xml, why this decision? Leiningen never explicitly supported settings.xml; it was checked by accident as an implementation detail due to lein1 using maven-ant-tasks rather than Aether. But the better answer is that Leiningen isn't Maven, and supporting some subset of settings.xml without supporting all of it is confusing. Just wondering; if you want to specify an internal nexus repo in one place, can you specify it in ~/.lein/profiles.clj ? It's possible, but highly discouraged. If your project requires certain repositories in order to operate, you should declare them in project.clj. Specifying authentication for private repos in the user profile, on the other hand, is highly recommended. -Phil -- -- 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/groups/opt_out.
Re: does lein2 use repositories defined in ~/.m2/settings.xml?
Just wondering; if you want to specify an internal nexus repo in one place, can you specify it in ~/.lein/profiles.clj ? It's possible, but highly discouraged. If your project requires certain repositories in order to operate, you should declare them in project.clj. Specifying authentication for private repos in the user profile, on the other hand, is highly recommended. -Phil I can see it being an anti-pattern for open-source projects hosted on the internet, but the scenario that I am experimenting with is a single nexus server within an organisation, used to mirror clojars central, as well as act as a repository for internal closed-source components. Putting repos in profiles.clj seems to have the advantage that I'll be able to override all accesses to central / clojars / etc to go via the nexus proxy; and I won't have to start hacking at published project.cljs if infrastructure changes mean that the repo server moves or fragments or whatever. Does that sound reasonable? (I'm a noob at maven infrastructure). -- Dave -- -- 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/groups/opt_out.
Re: does lein2 use repositories defined in ~/.m2/settings.xml?
On Thu, Feb 21, 2013 at 12:44 PM, Phil Hagelberg p...@hagelb.org wrote: It's possible, but highly discouraged. If your project requires certain repositories in order to operate, you should declare them in project.clj. Just as a data point, we're currently using a profiles.clj on each of our build agents to declare our internal Nexus repos (including our mirrors of Maven Central and Clojars), because that is more maintainable for us than repeating the entire repo declaration in every one of our project.clj files. For Maven projects, we can use a parent pom, but there isn't any corresponding parent project concept for Leiningen, correct? I experimented a bit with trying to use a Lein middleware to supply the repo entries, but unless you install the middleware manually, that ends up begging the question, since Lein has to know where to get the middleware. -- Chris Jeris cje...@brightcove.com freenode/twitter/github: ystael -- -- 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/groups/opt_out.
Re: Current status of Clojure on Android?
I've been trying to figure out how to get started with Clojure on Android, and I'm thinking of using LibGDX. http://code.google.com/p/libgdx/ I've just been looking at a game called Bounce Away which was written almost entirely in Clojure with LibGDX. (Released in December.) https://play.google.com/store/apps/details?id=com.friendlyvillagers.ballzhl=en I'd like to use Eclipse/CCW, but as a newbie I haven't been able to find much info on getting started with Clojure/Android/LibGDX. There's a couple of posts here about Maven and dependencies... http://code.google.com/p/libgdx/issues/detail?id=1118 http://code.google.com/p/libgdx/wiki/MavenProjectSetup ...but I can't make much of it. I'd be glad of any hints in the right direction. On Monday, November 26, 2012 9:28:13 PM UTC, John Gabriele wrote: Hi, What is the current status of Clojure on Android? That is, for creating Android apps in Clojure. I found this http://dev.clojure.org/display/design/Android+Support , but it appears to have been last-updated Feb 2011. What are currently the main limitations in creating and running Clojure programs on Android? (Does some limited subset of Clojure work? Does the bytecode that Clojure produces run on Dalvik?) Is it currently possible to write your Android app in Java but then call out to app code written in Clojure? Thanks! ---John -- -- 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/groups/opt_out.
Insert to a database does not work with jar file.
So, i have function that looks something like this : (defn insert-to-db [some-list] (map #(db/with-connection pool (db/insert-records :courses %)) some-list)) some-list here is just a list of hashmaps I want to insert and I'm calling this function from -main This works perfectly with lein repl and lein run. But if I run lein uberjar and do a java -jar target/file.jar it doesnt do anything at all. I've doing other things like creating the db and printing out the rows from the db. They all work fine with the jar file. Also, inserting a single entry using insert-records works. It's really strange and I can't figure out what's happening 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/groups/opt_out.
how do I reference a var that is in my core namespace?
I wanted to have some functions run when an app starts, and I wanted this to be configurable, because I plan to use the same architecture for several apps. So I thought I could have the function names as strings inside of maps inside of a set (that I sort), in a config file. And I thought I could use ns-resolve *ns* symbol to turn the strings into references to the vars where the function definitions are stored. But somehow this is not working. I have this right now, in mpdv.core, which is the core namespace is an app I created with lein: (defn process-startup-hooks [] 2013-02-21- remember, each row in hooks is a map: {:order-of-events 1, :event-name 'connect-to-database'} (connect-to-database) (let [hooks (sort-by :order-of-events (:events-called-when-the-app-starts-hooks @um/interactions))] (doseq [x hooks] (let [event-as-symbol (symbol (:event-name x)) event (ns-resolve *ns* event-as-symbol)] (println what kind of var is this? ) (println *ns*) (println (type event-as-symbol)) (println event-as-symbol) (if-not (nil? event) (event)) event is always nil. One of the events listed in um/interactions is connect-to-database so, as a test, I hardcoded it here, to be sure it could run here, and it runs fine (first line after the comment). So the var for the function is known. But this: (ns-resolve *ns* event-as-symbol) returns nil, even when event-as-symbol is connect-to-database. When I println *ns* to the terminal output, I see the namespace is: #Namespace clojure.core Which surprises me somewhat. How do I get ns-resolve to look in mpdv.core for the var that I want it to find? -- -- 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/groups/opt_out.
Re: Insert to a database does not work with jar file.
2013/2/21 Roland Pinto rolandjpi...@gmail.com But if I run lein uberjar and do a java -jar target/file.jar it doesnt do anything at all clojure.core/map is lazy. REPL forces evaluation because it needs to print results to you. Wrap map in doall (if you need returned values) or dorun (if you only want side effects). That will force evaluation. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- 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/groups/opt_out.
Re: how do I reference a var that is in my core namespace?
I tend to have this at the top of most of my namespaces: (def ^:private my-ns *ns*) This evaluates *ns* at load/init time when it is bound to the namespace being loaded and then initializes my-ns with that value. Then I use my-ns throughout that namespace. *ns* is dynamically bound to whatever namespace is currently executing which is why it changes unexpectedly when you're trying to do something obvious with it. On Thu, Feb 21, 2013 at 10:30 AM, larry google groups lawrencecloj...@gmail.com wrote: I wanted to have some functions run when an app starts, and I wanted this to be configurable, because I plan to use the same architecture for several apps. So I thought I could have the function names as strings inside of maps inside of a set (that I sort), in a config file. And I thought I could use ns-resolve *ns* symbol to turn the strings into references to the vars where the function definitions are stored. But somehow this is not working. I have this right now, in mpdv.core, which is the core namespace is an app I created with lein: (defn process-startup-hooks [] 2013-02-21- remember, each row in hooks is a map: {:order-of-events 1, :event-name 'connect-to-database'} (connect-to-database) (let [hooks (sort-by :order-of-events (:events-called-when-the-app-starts-hooks @um/interactions))] (doseq [x hooks] (let [event-as-symbol (symbol (:event-name x)) event (ns-resolve *ns* event-as-symbol)] (println what kind of var is this? ) (println *ns*) (println (type event-as-symbol)) (println event-as-symbol) (if-not (nil? event) (event)) event is always nil. One of the events listed in um/interactions is connect-to-database so, as a test, I hardcoded it here, to be sure it could run here, and it runs fine (first line after the comment). So the var for the function is known. But this: (ns-resolve *ns* event-as-symbol) returns nil, even when event-as-symbol is connect-to-database. When I println *ns* to the terminal output, I see the namespace is: #Namespace clojure.core Which surprises me somewhat. How do I get ns-resolve to look in mpdv.core for the var that I want it to find? -- -- 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/groups/opt_out. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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/groups/opt_out.
Re: Insert to a database does not work with jar file.
I had a feeling this was due to laziness. Thanks for your help. It works now. On Thursday, February 21, 2013 1:35:19 PM UTC-5, Michael Klishin wrote: 2013/2/21 Roland Pinto roland...@gmail.com javascript: But if I run lein uberjar and do a java -jar target/file.jar it doesnt do anything at all clojure.core/map is lazy. REPL forces evaluation because it needs to print results to you. Wrap map in doall (if you need returned values) or dorun (if you only want side effects). That will force evaluation. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- 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/groups/opt_out.
Re: does lein2 use repositories defined in ~/.m2/settings.xml?
David Powell writes: Putting repos in profiles.clj seems to have the advantage that I'll be able to override all accesses to central / clojars / etc to go via the nexus proxy; and I won't have to start hacking at published project.cljs if infrastructure changes mean that the repo server moves or fragments or whatever. Sure; introducing mirrors is different from introducing entirely new repositories. Mirrors simply streamline and speed things up rather than providing entirely new artifacts, so they don't really change the semantics of what you end up with. -Phil -- -- 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/groups/opt_out.
Re: how do I reference a var that is in my core namespace?
That worked. I find it a little surprising that this is the correct way to do this, but it worked, so I am happy. Thank you. On Thursday, February 21, 2013 1:43:18 PM UTC-5, Sean Corfield wrote: I tend to have this at the top of most of my namespaces: (def ^:private my-ns *ns*) This evaluates *ns* at load/init time when it is bound to the namespace being loaded and then initializes my-ns with that value. Then I use my-ns throughout that namespace. *ns* is dynamically bound to whatever namespace is currently executing which is why it changes unexpectedly when you're trying to do something obvious with it. On Thu, Feb 21, 2013 at 10:30 AM, larry google groups lawrenc...@gmail.com javascript: wrote: I wanted to have some functions run when an app starts, and I wanted this to be configurable, because I plan to use the same architecture for several apps. So I thought I could have the function names as strings inside of maps inside of a set (that I sort), in a config file. And I thought I could use ns-resolve *ns* symbol to turn the strings into references to the vars where the function definitions are stored. But somehow this is not working. I have this right now, in mpdv.core, which is the core namespace is an app I created with lein: (defn process-startup-hooks [] 2013-02-21- remember, each row in hooks is a map: {:order-of-events 1, :event-name 'connect-to-database'} (connect-to-database) (let [hooks (sort-by :order-of-events (:events-called-when-the-app-starts-hooks @um/interactions))] (doseq [x hooks] (let [event-as-symbol (symbol (:event-name x)) event (ns-resolve *ns* event-as-symbol)] (println what kind of var is this? ) (println *ns*) (println (type event-as-symbol)) (println event-as-symbol) (if-not (nil? event) (event)) event is always nil. One of the events listed in um/interactions is connect-to-database so, as a test, I hardcoded it here, to be sure it could run here, and it runs fine (first line after the comment). So the var for the function is known. But this: (ns-resolve *ns* event-as-symbol) returns nil, even when event-as-symbol is connect-to-database. When I println *ns* to the terminal output, I see the namespace is: #Namespace clojure.core Which surprises me somewhat. How do I get ns-resolve to look in mpdv.core for the var that I want it to find? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 javascript: 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 javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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/groups/opt_out.
Re: a bit mystified by unchecked-multiply
Both are true. The type function doesn't have a primitive version, so its argument gets auto-boxed. -- -- 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/groups/opt_out.
Re: Current status of Clojure on Android?
Also: https://groups.google.com/forum/?fromgroups#!forum/clojure-android (Ah, only just noticed thatI'll start there...) -- -- 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/groups/opt_out.
Re: ANN Welle 1.4.0 is released
I will... My usecases require durability and strict consistency. Josh. On Thu, Feb 21, 2013 at 11:02 PM, Mark Phillips m...@basho.com wrote: Hey Josh, On Thu, Feb 21, 2013 at 2:18 AM, Josh Kamau joshnet2...@gmail.com wrote: Hi Clojurewerkz guys ; I like your work on various libraries. Just wondering, do you plan to do a library for HBase ? Regards. Josh Take Riak for a spin. :) Mark On Thu, Feb 21, 2013 at 12:49 PM, Michael Klishin michael.s.klis...@gmail.com wrote: Welle [1] is an expressive Clojure client for Riak with batteries included. 1.4.0 is a minor release that is *100% backwards-compatible* with 1.3.x. This version has been tested against Riak 1.2 as well as RCs of Riak 1.3. Release notes: http://blog.clojurewerkz.org/blog/2013/02/21/welle-1-dot-4-0-is-released/ 1. http://clojureriak.info -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- 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/groups/opt_out. ___ riak-users mailing list riak-us...@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.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 --- 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/groups/opt_out.
Re: nREPL + Emacs: How to get new definitions to load reliably?
Thanks for that helper function. I suppose that's as close as I'll get for the time being. On Thu, Feb 21, 2013 at 6:03 AM, Stuart Sierra the.stuart.sie...@gmail.com wrote: For what it's worth, I tried using tools.namespace but if I (refresh) code that doesn't compile, then suddenly the refresh symbol is out of scope and I'm back to square one. You can still recover from this: just call 'refresh' by its fully-qualified name: (clojure.tools.namespace.repl/refresh) I use a (hackish) Emacs helper function to do this in nREPL: http://bit.ly/WUqLE4 -S -- -- 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/groups/opt_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 --- 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/groups/opt_out.
Re: Clojure Performance For Expensive Algorithms
Man, this is exactly how I feel after all this tinkering! It was great for learning Clojure a bit more in depth, but in the end I am going to stick with the Java solution. Especially since it's so easy to mix Java and Clojure in the same project! I just specify :java-source-paths [src/java] in my project.clj and I just call that one method when I need it and the rest of the project is in Clojure. I think when performance if critical idiomatic Clojure is to just drop down to Java :) Christophe's second function actually achieves Java speed or very close (within 5-10%), but it's ugly and there's a bit more to my algorithm which would make it even uglier if I were to go that route. On Thursday, February 21, 2013 4:55:13 AM UTC-5, Marko Topolnik wrote: Whatever the final performance achieved, the fact remains that the original Java code was much cleaner, simpler, and more comprehensible than the big ball of mud the performant Clojure version is turning into. I have my own piece of performance-critical code that I used to maintain and improve over a timespan of many months. I finally gave in and recoded the thing in Java. It took only a couple of hours and the result was nice, clean, idiomatic Java code, with completely predictable performance characteristics, as opposed to the Clojure version where it took many hours of staring at ridiculuously counterintuitive stacktraces in VisualVM to find what to optimize and how. The amount of code is about the same at either end. On Thursday, February 21, 2013 10:41:55 AM UTC+1, Christophe Grand wrote: I updated my answer on SO, with a deftype-based one that gives me an additional 30% boost. On Tue, Feb 19, 2013 at 6:38 PM, Geo ggrig...@gmail.com wrote: What about the call to .equals? On Tuesday, February 19, 2013 12:20:28 PM UTC-5, Marko Topolnik wrote: The difference between String[] and Object[] is that a member of the former doesn't need a checked cast to String, but the latter does need one. In the code under consideration, however, nothing specific to String is used, so even in the Java code you can freely replace String[] with Object[] and everything still works. If, on the other hand, you needed to invoke say *substring*, you'd see a small penalty due to the checked cast operation. On Tuesday, February 19, 2013 5:52:31 PM UTC+1, Andy Fingerhut wrote: ^objects is a Clojure synonym for ^[Ljava.lang.Object;. Note that there are such synonyms for only a few Java types, not everything, e.g. there is no ^strings. What you are hinting is that a1 and a2 are Java arrays of objects. I think this might speed up (aget a1 i) expressions, since it is known that a1 is an array of objects, but I'm not sure about that. I believe under the hood in the JVM all arrays of Objects are treated the same, regardless of whether those Objects are String, Integer, java.awt.Color, etc. Andy On Feb 19, 2013, at 8:46 AM, Geo wrote: One thing I don't get is that switching the type hints from [#^[Ljava.lang.String; a1 #^[Ljava.lang.String; a2] to [^objects a1 ^objects a2] didn't seem to have any negative impact on performance. Can anyone explain why hinting ^objects is just as good as specifying that it's an array of Strings? What are you hinting with ^objects that Clojure doesn't already know? -- -- 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/groups/opt_out. -- On Clojure http://clj-me.cgrand.net/ Clojure Programming http://clojurebook.com Training, Consulting Contracting http://lambdanext.eu/ -- -- 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/groups/opt_out.
Leiningen repl dependency conflicts clj-http
Ran into some issues with the dependencies that Leiningen's repl adds to the my project. The issues I ran into are very similar to the issues discussed in https://github.com/technomancy/leiningen/issues/815 . Does anyone have any work arounds or possibly any info not already in the Github issue? -- -- 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/groups/opt_out.
Module For COM Objects
Does Clojure have a module that allows initializing, passing data to, and finalizing COM objects? I am asking, because I need to write a Clojure program to communicate with a COM toolkit. 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/groups/opt_out.
Re: Faster lein
2013/2/21 Phil Hagelberg p...@hagelb.org Unless you want to clear the cache manually every time your dependencies change, you'd have to make a parallel tree of jars for each version of Clojure you plan on using. Ah yes, I forgot that clojure code may compile differently, depending on the clojure version it is used with. I think the simplest way to do this would be with a proxying repository that also cross-compiled jars to new artifacts with added classifiers as they came through. You'd also need a bit of magic on the Leiningen side with some middleware in a plugin to add classifiers to every Clojure dependency. But I have no idea how you would easily tell apart Clojure jars from Java jars without opening them up to inspect their contents, which could add a startup time penalty. I would imagine that as an opt in solution, where either the library writers and/or users specify that the byte cache should be used for a library. Then the middleware would only need to look if there is ~/.cache/bytecache/org/example/lib/0.2/clj-1.4/ and add it to the classpath, if available. -- -- 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/groups/opt_out.
Re: Clojure Performance For Expensive Algorithms
This thread made me realize there's quite a bit of low hanging compatibility fruit between Clojure ClojureScript, so as of this changeset http://github.com/clojure/clojurescript/compare/4652498035...3c0fb6ef5f We can now compile Christophe's example code in ClojureScript w/ exactly 4 minor changes. We could imagine handling these differences with feature expressions: (deftype F [^:unsynchronized-mutable ^ints curr ^:unsynchronized-mutable ^ints prev] IFn ; = CHANGED (invoke [_ a1 a2] (let [^objects a1 a1 ^objects a2 a2] (areduce a1 i max-len 0 (let [m (areduce a2 j max-len max-len ; = CHANGED (let [match-len (if (identical? (aget a1 i) (aget a2 j)) ; = CHANGED (unchecked-inc (aget prev j)) 0)] (aset curr (unchecked-inc j) match-len) ; = CHANGED (if ( match-len max-len) match-len max-len))) bak curr] (set! curr prev) (set! prev bak) m) (defn my-lcs2 [^objects a1 a2] (let [n (inc (alength a1)) f (F. (int-array n) (int-array n))] (f a1 a2))) Running under the Google V8 JS engine I see an execution time of ~2.2 seconds using the same benchmark on the StackOverflow question. This is compared to a ~1s running time for the JVM. This is nearly within 2X of the JVM! The pretty printed Closure advanced optimized code for the important bits: Sg.prototype.call = function(a, b, c) { for(var a = this, d = 0, f = 0;;) { if(d b.length) { var h = d + 1, i; i = g; a: { i = 0; for(var k = f;;) { if(i c.length) { var f = i + 1, p = b[d] === c[i] ? a.gb[i] + 1 : 0; a.cb[i + 1] = p; k = p k ? p : k; i = f }else { i = k; break a } } i = g } d = a.cb; a.cb = a.gb; a.gb = d; d = h; f = i }else { return f } } }; That looks like some highly optimized JS to me ;) I think I'll stick with writing my fast code in Clojure thank you very much. David On Thu, Feb 21, 2013 at 4:49 PM, David Nolen dnolen.li...@gmail.com wrote: On Thu, Feb 21, 2013 at 4:55 AM, Marko Topolnik marko.topol...@gmail.comwrote: Whatever the final performance achieved, the fact remains that the original Java code was much cleaner, simpler, and more comprehensible than the big ball of mud the performant Clojure version is turning into. To my eyes the deftype version is about as clean, simple, comprehensible, as the Java version. But I've been doing Clojure for a while now. Christophe's version also has the advantage that it can pretty much compile down to efficient JavaScript via ClojureScript and probably an efficient ClojureCLR program as well. This may or may not matter to you. David -- -- 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/groups/opt_out.
Re: [ANN] Javelin, spreadsheet-like FRP for ClojureScript
For those interested in comparing Javelin with other ClojureScript approaches to building rich applications on the clientside, there are several implementations of the infamous todo list applications here: https://github.com/lynaghk/todoFRP/tree/master/todo And, of course, if you're missing the wonderful world of imperative programming and mutable state, you can check out dozens of plain JavaScript implementations in the original project: http://addyosmani.github.com/todomvc/ On Tuesday, February 19, 2013 11:33:56 PM UTC-8, Alan Dipert wrote: Hi all, We recently released a ClojureScript library for FRP called Javelin. Links of interest: * Release announcement: http://tailrecursion.com/blog/2013/02/15/introducing-javelin-an-frp-library-for-clojurescript/ * Demos (more on the way): http://tailrecursion.com/~alan/javelin-demos/ * GitHub project: https://github.com/tailrecursion/javelin In a nutshell, Javelin is an abstract spreadsheet that encourages working with concrete values instead of abstract event streams a la FRP. It supports discrete propagation, which most FRP implementations provide as the event stream, via the ability to toggle cells between discrete/continuous propagation modes. Cell mutation semantics are those of ClojureScript atoms. We have ported Javelin's core to a ref-based Clojure implementation capable of parallel propagation and hope to release it soon. Among other things, our hope is to use it to process Prismatic graph [1] -compatible workflows reactively. If you are using graph or flow [2] and are interested in reactive processing, and wouldn't mind helping us with performance testing, drop me a line. Thanks for giving Javelin a look! I look forward to your feedback and collaboration. Alan 1. https://github.com/Prismatic/plumbing 2. https://github.com/stuartsierra/flow -- -- 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/groups/opt_out.
Re: Module For COM Objects
The are a few tools for doing interop with COM from the JVM. They all kind of suck. We use com4j at work with Clojure. Com4j generates JVM stubs for COM libraries. On Feb 21, 2013 3:53 PM, octopusgrabbus octopusgrab...@gmail.com wrote: Does Clojure have a module that allows initializing, passing data to, and finalizing COM objects? I am asking, because I need to write a Clojure program to communicate with a COM toolkit. 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/groups/opt_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 --- 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/groups/opt_out.
Re: Module For COM Objects
There is an example here of using JACOB: http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Talking_to_Excel (I think this only works for IDispatch stuff?) On Fri, Feb 22, 2013 at 1:02 AM, Kevin Downey redc...@gmail.com wrote: The are a few tools for doing interop with COM from the JVM. They all kind of suck. We use com4j at work with Clojure. Com4j generates JVM stubs for COM libraries. On Feb 21, 2013 3:53 PM, octopusgrabbus octopusgrab...@gmail.com wrote: Does Clojure have a module that allows initializing, passing data to, and finalizing COM objects? I am asking, because I need to write a Clojure program to communicate with a COM toolkit. 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/groups/opt_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 --- 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/groups/opt_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 --- 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/groups/opt_out.