Re: Difference between defrecord and extend
Chas, thank you for the explanation, it confirmed my vague thoughts I had after quick review of Clojure source code and inspection of values in prototype maps before and after the change. I understand the difference, however I think there are three points to consider from Clojure design point of view. 1) If you target both Clojure and ClojureScipt, you cannot write #'foo, because variables are not first class citizens in CLJS (yet). 2) Functional code is a lot about passing functions to functions making functions (for example wonderful reducers library). Does it mean we should always pass around variable instead of methods (because we cannot foresee if a programmer extending our code will use defrecord or extend)? 3) The point is the inconsistency in `defrecord` and `extend` implementation. I always thought about defrecord and extend as a "syntactic sugar" to achieve same goal. If there are two ways how to implement a protocol, they should lead to same results and side effects otherwise it could backfire on us and result in hard to discover bugs. For example, if defprotocol is implemented in namespace A, transmogrify and foo* in namespace B and FooRec and BarRec were implemented in namespace C, I get different results if I load namespaces in sequence A-B-C and A-C-B. This is very dangerous indeed. For me the real issue is point 3) as it crosses the boundary of principle of least surprise. There are two ways how to implement a protocol in a record and your code may or may not throw an exception under different conditions. So my recommendation would be to unify defrecord and extend implementation. Dan On Sunday, June 24, 2012 4:35:10 AM UTC+2, Chas Emerick wrote: > > Dan, > > This difference is due to the subtleties around how protocols are > implemented, and between passing a var vs. capturing a var's state at a > particular time. > > If you change `transmogrify` to this (note the #'), the `(foo* (BarRec.))` > succeeds: > > (*def* foo* (transmogrify #'foo "Bar")) > > Protocol implementations are largely tracked by a map held in a var > corresponding to the protocol's name (in this case, FooProto). Prior to > using `extend`, the #'FooProto var contains this map: > > {:on-interface user.FooProto, :on user.FooProto, :sigs {:foo {:doc "Make a > foo", :arglists ([X Y]), :name foo}}, :var #'user/FooProto, :method-map > {:foo :foo}, :method-builders {#'user/foo # user$eval1287$fn__1288@610f7612>}} > > After using `extend`, it contains this map (note the `:impls` slot): > > {:impls {user.BarRec {:foo # user$eval1321$fn__1322@1e384de>}}, :on-interface user.FooProto, :on > user.FooProto, :sigs {:foo {:doc "Make a foo", :arglists ([X Y]), :name > foo}}, :var #'user/FooProto, :method-map {:foo :foo}, :method-builders > {#'user/foo #}} > > The implementation of protocol functions is such that they retain > optimized (fixed) call paths for each type extended to their protocol. > Thus, when you pass the value of `foo` to `transmogrify`, the un-extended > protocol's "configuration" goes with it. However, if you pass the var > #'foo instead, all calls through #'foo are guaranteed to utilize the most > up-to-date protocol function, and therefore the most up-to-date protocol > type extensions. In any case, calling `(foo …)` always works, because that > call implicitly goes through #'foo anyway. > > The fine difference between capturing a var's value vs. passing or calling > through the var itself is a frequent tripping hazard, but understanding it > is especially important in ensuring maximum productivity and enjoyment in > the REPL (as you've found out). FWIW, we talk about this issue with some > simpler examples illustrating the subtleties in chapter 10 of the book (in > a subsection of REPL-Oriented Programming, ~page 416, 'Understand when > you’re capturing a value instead of dereferencing a var'). > > Hope this helps, > > - Chas > > -- > http://cemerick.com > [Clojure Programming from O'Reilly](http://www.clojurebook.com) > > On Jun 23, 2012, at 7:45 PM, Daniel Skarda wrote: > > Hi, > > I have discovered strange difference between methods implemented directly > in defrecord and methods added later using extend (extend-type). > > I simplified the issue to code example listed bellow. Both records FooRec > and BarRec implement simple protocol FooProto with method foo. There is > also evil function transmogrify, which takes a function F and returns new > function which calls F. I use transmogrify to produce function foo* > > If you call foo method directly, everything works as expected. When you > call foo*, FooRec method is OK, but BarRec fails with following exception > > No implementation of method: :foo of protocol: #'user/FooProto found for > class: user.BarRec > > > Which looks weird because you can call foo directly... > > I expect that defrecord and extend use different approach to extending the > type and foo* ends up with a reference to old version
How to convert a python list to clojure?
I have this list in python: cc = list() for i in range(256): cc.append(ctf.GetColor(float(i) / 255.0)) And I would know if this is correct conversion in clojure? (def cc [(for [i (range 256)] (.. ctf GetColor (/ i 255.0)))]) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to convert a python list to clojure?
Take a look at my pyclj library, which could dump/loads clojure literal to python data structures. https://github.com/sunng87/pyclj You can dump you cc and use read-string to load it into clojure. import clj print clj.dumps(cc) On 06/24/2012 06:05 PM, Antonio Recio wrote: I have this list in python: cc = list() for i in range(256): cc.append(ctf.GetColor(float(i) / 255.0)) And I would know if this is correct conversion in clojure? (def cc [(for [i (range 256)] (.. ctf GetColor (/ i 255.0)))]) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to convert a python list to clojure?
Antonio Recio: > And I would know if this is correct conversion in clojure? > (def cc > [(for [i (range 256)] > (.. ctf GetColor (/ i 255.0)))]) It is correct in the sense that it will do the same thing. If you have a collection and need to calculate a value for every element in it and return the list of results, this is what clojure.core/map is for: (map (fn [i] (.getColor ctf (/ i 255.0))) (range 256)) or (defn color-for [i] (.getColor ctf (/ i 255.0))) (map color-for (range 256)) Keep in mind that both range and map return lazy sequences. You can force their evaluation by wrapping the entire thing into (doall …). More examples at http://clojuredocs.org/clojure_core/clojure.core/map MK mich...@defprotocol.org signature.asc Description: Message signed with OpenPGP using GPGMail
Re: How to convert a python list to clojure?
I think versions with `for` is a hell more readable. I vote for this: (def cc (for [i (range 256)] (.GetColor ctf (/ i 255.0 воскресенье, 24 июня 2012 г., 16:15:14 UTC+6 пользователь Michael Klishin написал: > > Antonio Recio: > > > And I would know if this is correct conversion in clojure? > > (def cc > > [(for [i (range 256)] > > (.. ctf GetColor (/ i 255.0)))]) > > It is correct in the sense that it will do the same thing. If you have a > collection and need to calculate > a value for every element in it and return the list of results, this is > what clojure.core/map is for: > > (map (fn [i] (.getColor ctf (/ i 255.0))) (range 256)) > > or > > (defn color-for > [i] > (.getColor ctf (/ i 255.0))) > > (map color-for (range 256)) > > Keep in mind that both range and map return lazy sequences. You can force > their evaluation by wrapping > the entire thing into (doall ...). > > More examples at http://clojuredocs.org/clojure_core/clojure.core/map > > MK > > mich...@defprotocol.org > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Difference between defrecord and extend
Dan, Re: (2), yes, using higher-order functions effectively is a big part of functional programming. But, no, passing a var to HOFs in every case instead of dereferencing its value is not a good blanket policy. You need to have a clear notion of what you want to happen and what the contract of a given HOF is, i.e. they generally only do accept values, and usually don't accept identities such as vars. (Since vars implement IFn, and can freely be used in function position with calls being delegated to the function (assumed to be) contained therein, vars containing functions are the one case where passing a var and passing a function value is equivalent, at least with respect to the expectations of a receiving HOF.) Whether you pass a var or a value to a HOF depends entirely on whether you want the HOF to use the current value of the var (very important if you want to have later changes to propagate to functions returned from a HOF) or the value of the var at a particular point in time; both are valid options in different circumstances. In practice, I've not found this distinction to be important with regard to protocols; I think this is largely due to my generally not defining the result of a HOF in a top-level, as you're doing with `transmogrify`. My impression is that doing so is fairly rare, though that may be due to my personal tastes and whatever universe of code I happen to frequent. Re: (3), the semantics of `extend` vs. inline implementations of a protocol within defrecord (or deftype) are absolutely different, and unlikely to be unified. The former uses the Clojure-specific polymorphism provided in protocols and manifested by the re-definition of protocol functions based on the value of the protocol map as discussed in my last message. The latter defines a JVM class that implements the JVM interface corresponding to the named protocol; in these cases, calling a protocol function with a e.g. defrecord instance results in a call to that method directly, without regard to the current state of the protocol. So: => (defprotocol P (x [t])) P => (defrecord A [] P (x [_])) user.A => (defrecord B []) user.B => (extend-type B P (x [_])) nil A is an instance of the user.P interface, but B is not: => (instance? user.P (B.)) false => (instance? user.P (A.)) true A has an `x` method implementation, while B does not: => (.x (A.)) nil => (.x (B.)) IllegalArgumentException No matching field found: x for class user.B (This is why `foo*` worked for you with a defrecord instance: protocol functions, regardless of their method of execution (i.e. directly or via a var), always first check if the first argument implements the protocol's interface; if so, the corresponding method is called directly, without referring to the protocol's map.) Finally, the implementation of `x` for an existing instance of `B` can be changed, while that is not possible for an instance of `A`: => (def a (A.)) #'user/a => (def b (B.)) #'user/b => (extend-type B P (x [_] "hi, B!")) nil => (x b) "hi, B!" => (extend-type A P (x [_] "hi, A!")) IllegalArgumentException class user.A already directly implements interface user.P for protocol:#'user/P The tl;dr of all this is that defrecord and deftype define JVM classes, which optionally contain interface (and therefore, protocol) implementations which cannot be changed. defrecord and deftype actually don't contain any special support or consideration for protocols; they can be used to implement interface methods, and protocols just happen to (conveniently, and by design) generate an interface corresponding to their namespace and name. Thus, the differences between such inline implementations and uses of `extend` isn't an inconsistency — they're just different beasts, definitionally. This all means that `extend` et al. are actually more flexible; it is the var or not-var issue that tripped you up, along with the fuzziness around the correspondence between protocols and interfaces. Cheers, - Chas -- http://cemerick.com [Clojure Programming from O'Reilly](http://www.clojurebook.com) On Jun 24, 2012, at 5:32 AM, Daniel Skarda wrote: > Chas, > > thank you for the explanation, it confirmed my vague thoughts I had after > quick review of Clojure source code and inspection of values in prototype > maps before and after the change. > I understand the difference, however I think there are three points to > consider from Clojure design point of view. > > 1) If you target both Clojure and ClojureScipt, you cannot write #'foo, > because variables are not first class citizens in CLJS (yet). > > 2) Functional code is a lot about passing functions to functions making > functions (for example wonderful reducers library). Does it mean we should > always pass around variable instead of methods (because we cannot foresee if > a programmer extending our code will use defrecord or extend)? > > 3) The point is the inconsisten
Re: [ANN] milieu - the environmentally friendly configuration tool (version 0.5.0)
Funny, We implemented something similar using zookeeper (thanks to David for zookeeper-clj). We store data as Clojure expressions. This was a move to have a cluster unified view of configuration data and go away from alien representations (we used Yaml in several places). I can't see the added value of using an alien format except if you intend to share it with an environment where Clojure is not available. We decided to bridge the gap by calling Clojure to access configuration from either JRuby or Java when needed. In both cases, map and collection interfaces saves us the translation. Luc > Hi Robert, > > Everything looks good, thanks for sharing the library. A philosophical > > question, why YAML and not JSON or raw clj? > > Cheers, Jay > > On Jun 22, 2012, at 7:30 PM, Robert Levy wrote: > > > It is my pleasure to announce the 0.5.0 release of milieu, a library for > > > environment-based application configuration that I have developed and > > > actively maintain at Draker in Burlington, Vermont. Having made use of > > > it in our day-to-day work for several months now, we have found this > > > library to be very useful for managing configuration in our proprietary > > > time-series data acquisition back-end systems (also all written in > > > Clojure of course). I think this library will add value to applications > > > in any domain. > > > > The source can be found at https://github.com/drakerlabs/milieu and the > > > > leiningen / maven dependency information is at > > > > http://clojars.org/milieu. Issues/feedback and pull requests are of > > > > course welcome! > > > > milieu > > The environmentally friendly configuration tool. > > > > Build status: > > > > Features: > > Set up environment-specific configuration for your Clojure application, > > using the popular YAML file format. > > > > Access config values: > > > > Specifying config values: > > > > (config/value :my :config :value) > > This will access the value in > > > > dev|test|...: > > my: > > config: > > value: > > Specifying config values as optional: > > > > (config/value| :my :config :value) ; same as config/value except > > > > doesn’t warn if it’s not found > > (config/value| [:my :config :value] "alternate value") ; provide alternate > > value > > Optionally auto-load config file. > > > > using the default filename of "configure.yml" enables autoload > > any other config file name can be specified by calling load-config > > Bind the environment within a calling context using with-env. > > > > (config/with-env env > > (when (config/value :some :setting) ... )) > > Specify the default environment using the MILIEU_ENV system variable. > > > > Override environment-specific settings using arguments to your > > > > command-line application. > > > > (config/commandline-overrides! args) > > (config/with-env env > > ... ) > > In cases where the environment can be variable, code evaluation can by > > restricted in with-env or only-env, or more generally conditional using > > if-env and when-env. > > > > ;; If env is prod, the code in the body will not be exercised, > > ;; an exception is thrown instead: > > (defn -main [env & args] > > (config/with-env [env :only [:test :dev]] ,,,)) > > Alternatively (for example if you aren't in the context of a with-env)... > > > > ;; If env is prod, the code in the body will not be exercised, > > ;; an exception is thrown instead: > > (config/only-env [:test :dev] ,,,) > > The following forms are general purpose conditionals (not assertions of > > environment restrictions). > > > > (config/if-env :test "hello" "goodbye") > > (config/when-env :dev ,,,) > > Helpful info / warnings that can be turned off with MILIEU_QUIET system > > variable: > > > > WARNING: system variable MILIEU_ENV was not set. Default value will be > > > > "dev" > > > > WARNING: requested config setting [:fou :barre] not found! > > > > INFO: to enable auto-load, name your config-file configure.yml. > > > > Use > > Installation > > > > http://clojars.org/milieu > > > > Getting Started > > > > (ns example.core > > (:require [milieu.config :as config])) > > Example > > > > (defn -main [env & args] > > (config/commandline-overrides! args) > > (config/with-env env > > (when (config/value| :some :setting) ,,, > > Command-line Override > > > > $ myprogram prod --fou.barre Fred --some.setting 127.0.0.1 > > License > > Author: Robert Levy / @rplevy-draker > > > > Acknowledgments: @alanpeabody, @S11001001, @AlexBaranosky > > > > Copyright © 2012 Draker Labs > > > > Distributed under the Eclipse Public License, the same as Clojure. > > > > -- > > You received this message because you are subscribed to the > > > > Google > > Groups "Clojure" group. > > To post to this group, send email to clojure@googlegroups.com > > Note that posts from new members are moderated - please be patient with > > your first post. > > To unsubscribe from this group, send email to > > clojure+unsubscr...@googlegroups.com
Trying to scrape multiple files in parallel using proxies and agents
Hey Everyone, I've been using lamina channels to create queues to download files/web pages in parallel. I'm using clj-http as my client as it supports proxies. So basically I create a channel, then use map* to fetch process and queue up pages in the channel. My fetch-url-with-proxy function, displayed below, takes a proxy-agent (an agent with a vector containing the ip and port of a proxy) and then fetches the url. The problem I'm having is that this does not actually appear to run in parallel. The process seems to hang 10 to 15 url's in. Anyone have any ideas? Regards, Folcon (defn fetch-url "If you give a wrong url it returns nil" ([url] (fetch-url url nil nil)) ([url host port] (. java.lang.Thread sleep (rand 1000)) (try-times 3 (try (printf (str url "\n")) (if (or (nil? host) (nil? port)) (html/html-resource (java.io.StringReader. (:body (client/get url (html/html-resource (java.io.StringReader. (:body (client/get url {:proxy-host host :proxy-port port}) (catch java.net.MalformedURLException e) (defn fetch-url-with-proxy [url] (try (try-times 3 (letfn [(fetch-fn [host-port url result] (let [[host port] host-port] (deliver result (fetch-url url host port)) (printf (str "Retrieved: " url "\n")) host-port))] (let [result (promise)] (send-off (agent-from-pool proxy-pool) fetch-fn url result) @result))) (catch java.lang.Exception e (to-log :error (str "Exception with url: " url " trace: " e) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ClojureScript instead of CoffeeScript for complete web app development?
On Saturday, June 23, 2012 12:43:38 AM UTC+2, wingie wrote: > > Since you love FP I wanted to mention another option: > > LiveScript > > > http://gkz.github.com/LiveScript/blog/functional-programming-in-javascript-using-livescript-and-prelude-ls.html > http://gkz.github.com/LiveScript > http://gkz.github.com/prelude-ls/ > > It's a script that compiles down to JavaScript. Inspired by CoffeeScript > but Haskell and F# as well. > > Read the blog about it's FP capabilities. > > It fits with all JS/CS projects. > > Hope it helps. > Hi wingie, and thanks for commeting. I indeed had a look at LiveScript, it's a very interesting project. What finally drove me far from it was: - Small community (for now, I understand everything has to start somewhere), so in terms of being able to solve doubts, long term future of the language, or look at other code it would be harder. - With Clojure & ClojureScript I learn a language which has many more applications than a JS one, and which is having a lot of effort behind it. Of the languages in the style of CoffeScript, Roy, etc... LiveScript was the one that I liked the most and I think is a great project. But I was preferring something more widespreaded. I really am liking learning Clojure... we'll see how this all plays out when the time to write some web apps comes around. I'll keep this group posted ;). Thanks! Cheers! -- 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
Anyone using Sublime Text 2 + SumblimeREPL with Windows?
Hi there, My current development environment is that: Sublime Text 2 editor with the fabulous SublimeREPL plugin to be able to copy code into the Clojure REPL. As absurd as it may seem... I can't find the combination of keys to send functions or selected code to the REPL. It's supposed to be there, but of all the keybindings that I've found, those are usually for Mac, and haven't found the way to "translate" that to Windows. Let's see if anyone here uses this odd environment and can help me out. Thanks a lot. Cheers! -- 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
struggling with two simple list of lists operations
Hi, I am looking for two seemingly simple operations which require adding to the list: (( 1 2 ) ( 20 30) (40)) 50 => (( 1 2 ) ( 20 30) (40 50)) and (( 1 2 ) ( 20 30) (40 50)) 60 => (( 1 2 ) ( 20 30) (40 50) (60)) Basically it is appending an element as a list to the list ... Any simple ideas? Thx, Andy -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: struggling with two simple list of lists operations
I guess you should use vectors, since you can't effectively add an element to the end of list. понедельник, 25 июня 2012 г., 0:46:24 UTC+6 пользователь Andy C написал: > > Hi, > > I am looking for two seemingly simple operations which require adding > to the list: > > (( 1 2 ) ( 20 30) (40)) 50 => (( 1 2 ) ( 20 30) (40 50)) > > and > > (( 1 2 ) ( 20 30) (40 50)) 60 => (( 1 2 ) ( 20 30) (40 50) > (60)) > > > Basically it is appending an element as a list to the list ... > > Any simple ideas? > > > Thx, > Andy > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: struggling with two simple list of lists operations
Yeah, this becomes much more straightforward using vectors. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
How I can convert this python line to clojure?
I have this python line that gives the number "1" as result print vtkDataObject.FIELD_ASSOCIATION_CELLS ;=> 1 And I would like to convert it to clojure.I have tried this 3 way, but I think they are incorrect. Which is the correct way? (println (vtkDataSetAttributes.SCALARS)) ;=> # (println vtk.vtkDataSetAttributes/SCALARS) ;=> # (println (vtk.vtkDataSetAttributes/SCALARS)) ;=> # -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How I can convert this python line to clojure?
The python line that I have rote before is not the one that I want to convert. The correct python line is this, and the result is "0". How I can convert it to clojure? print vtkDataSetAttributes.SCALARS ;=> 0 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: struggling with two simple list of lists operations
I know, but this is list :-) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Difference between defrecord and extend
Chas, once again thank you for very detailed explanation :) I have not seen all the implications of language implementation on top of JVM. I spent some time thinking about the issue and now I see all design choices and trade-offs, especially when type/prototype system must be fast and thread safe for parallel execution. For example I was puzzled why dispatch map is stored in prototype and not in record definition "as usual". Now I understand that it would be much worse if record instance missed protocol implementation because it was created before record was extended and referenced old dispatch table. Etc. "transmogrify" function performed curry-like operation and you are right that probably it this was not good pattern (looking back it was not that much useful). It seems that sometimes you have to shoot yourself in the leg to fully understand (and appreciate) language design choices :) Thanks, Dan On Sun, Jun 24, 2012 at 2:46 PM, Chas Emerick wrote: > Dan, > > Re: (2), yes, using higher-order functions effectively is a big part of > functional programming. But, no, passing a var to HOFs in every case > instead of dereferencing its value is not a good blanket policy. You need > to have a clear notion of what you want to happen and what the contract of > a given HOF is, i.e. they generally only do accept values, and usually > don't accept identities such as vars. (Since vars implement IFn, and can > freely be used in function position with calls being delegated to the > function (assumed to be) contained therein, vars containing functions are > the one case where passing a var and passing a function value is > equivalent, at least with respect to the expectations of a receiving HOF.) > Whether you pass a var or a value to a HOF depends entirely on whether you > want the HOF to use the current value of the var (very important if you > want to have later changes to propagate to functions returned from a HOF) > or the value of the var at a particular point in time; both are valid > options in different circumstances. > > In practice, I've not found this distinction to be important with regard > to protocols; I think this is largely due to my generally not defining the > result of a HOF in a top-level, as you're doing with `transmogrify`. My > impression is that doing so is fairly rare, though that may be due to my > personal tastes and whatever universe of code I happen to frequent. > > Re: (3), the semantics of `extend` vs. inline implementations of a > protocol within defrecord (or deftype) are absolutely different, and > unlikely to be unified. The former uses the Clojure-specific polymorphism > provided in protocols and manifested by the re-definition of protocol > functions based on the value of the protocol map as discussed in my last > message. The latter defines a JVM class that implements the JVM interface > corresponding to the named protocol; in these cases, calling a protocol > function with a e.g. defrecord instance results in a call to that method > directly, without regard to the current state of the protocol. So: > > => (*defprotocol* *P* (x [t])) > P > => (*defrecord* *A* [] > *P* (x [_])) > user.A > => (*defrecord* *B* []) > user.B > => (*extend-type* *B* > *P* (x [_])) > nil > > A is an instance of the user.P interface, but B is not: > > => (instance? *user.P* (*B.*)) > false > => (instance? *user.P* (*A.*)) > true > > A has an `x` method implementation, while B does not: > > => (*.x* (*A.*)) > nil > => (*.x* (*B.*)) > IllegalArgumentException No matching field found: x for class user.B > > (This is why `foo*` worked for you with a defrecord instance: protocol > functions, regardless of their method of execution (i.e. directly or via a > var), always first check if the first argument implements the protocol's > interface; if so, the corresponding method is called directly, without > referring to the protocol's map.) > > Finally, the implementation of `x` for an existing instance of `B` can be > changed, while that is not possible for an instance of `A`: > > => (*def* a (*A.*)) > #'user/a > => (*def* b (*B.*)) > #'user/b > => (*extend-type* *B* > *P* (x [_] "hi, B!")) > nil > => (x b) > "hi, B!" > => (*extend-type* *A* > *P* (x [_] "hi, A!")) > IllegalArgumentException class user.A already directly implements > interface user.P for protocol:#'user/P > > The tl;dr of all this is that defrecord and deftype define JVM classes, > which optionally contain interface (and therefore, protocol) > implementations which cannot be changed. defrecord and deftype actually > don't contain any special support or consideration for protocols; they can > be used to implement interface methods, and protocols just happen to > (conveniently, and by design) generate an interface corresponding to their > namespace and name. Thus, the differences between such inline > implementations and uses of `extend` isn't an inconsistency — they're just > different beasts, definitionally. >
Re: struggling with two simple list of lists operations
I discovered partition-all and came up with this function: (fn [l x] (concat (butlast l) (partition-all 2 (concat (last l) [x] user> ((fn [l x] (concat (butlast l) (partition-all 2 (concat (last l) [x] '() 10) ((10)) user> ((fn [l x] (concat (butlast l) (partition-all 2 (concat (last l) [x] '(( 1 2 ) ( 20 30) (40)) 50) ((1 2) (20 30) (40 50)) user> ((fn [l x] (concat (butlast l) (partition-all 2 (concat (last l) [x] '(( 1 2 ) ( 20 30) (40 50)) 60) ((1 2) (20 30) (40 50) (60)) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re:struggling with two simple list of lists operations
Andy Coolware writes: > Hi, > > I am looking for two seemingly simple operations which require adding > to the list: > > (( 1 2 ) ( 20 30) (40)) 50 => (( 1 2 ) ( 20 30) (40 50)) > > and > > (( 1 2 ) ( 20 30) (40 50)) 60 => (( 1 2 ) ( 20 30) (40 50) (60)) > > > Basically it is appending an element as a list to the list ... > > Any simple ideas? > > > Thx, > Andy This is a terrible slow implementation: --8<---cut here---start->8--- (defn foo [lst x] (let [[a b] (last lst)] (if b (concat lst (list (list x))) (concat (butlast lst) (list (list a x)) --8<---cut here---end--->8--- You could use zippers here, but it would propably be slower. Cheers, Moritz -- Moritz Ulrich -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: struggling with two simple list of lists operations
Or even shorter, but maybe not as fast because it flattens the given list, then pairs it up again. Thus it also assumes the resulting list should consist ENTIRELY of pairs and singletons, not just the last or penultimate element: (fn [l x] (partition-all 2 (concat (flatten l) [x]))) On Jun 24, 2:54 pm, Tyler Perkins wrote: > I discovered partition-all and came up with this function: > (fn [l x] (concat (butlast l) (partition-all 2 (concat (last l) > [x] > > user> ((fn [l x] (concat (butlast l) (partition-all 2 (concat (last l) > [x] > '() > 10) > ((10)) > user> ((fn [l x] (concat (butlast l) (partition-all 2 (concat (last l) > [x] > '(( 1 2 ) ( 20 30) (40)) > 50) > ((1 2) (20 30) (40 50)) > user> ((fn [l x] (concat (butlast l) (partition-all 2 (concat (last l) > [x] > '(( 1 2 ) ( 20 30) (40 50)) > 60) > ((1 2) (20 30) (40 50) (60)) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Anyone using Sublime Text 2 + SumblimeREPL with Windows?
On Sun, Jun 24, 2012 at 11:20 AM, Jacobo Polavieja wrote: > Hi there, > > My current development environment is that: Sublime Text 2 editor with > the fabulous SublimeREPL plugin to be able to copy code into the Clojure > REPL. > > As absurd as it may seem... I can't find the combination of keys to send > functions or selected code to the REPL. It's supposed to be there, but of > all the keybindings that I've found, those are usually for Mac, and haven't > found the way to "translate" that to Windows. > > Let's see if anyone here uses this odd environment and can help me out. I'm on OS X, but the key combinations seem pretty platform-agnostic. >From your editor tab, with the cursor at the end of a line of clojure code, hit F2, then "l" (lowercase "L"). That should evaluate the line of code and display the result in SublimeREPL. F2 followed by "f" should send the entire contents of the editor tab over to the REPL for evaluation. Is that what you're looking for? If not, let me know and I'll see what I can dig up. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. -- 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
Could not locate clojure/contrib/string__init.class or clojure/contrib/string.clj on classpath:
hi i need help!!! i have a project to finish but i keep on hitting this error: Could not locate clojure/contrib/string__init.class or clojure/contrib/string.clj on classpath: i tried everything i know (which is not much) and i read tons of metiral in the net, but i still cant figure out how to deal with this! i am knew to clojure and i cant continue my project! i would be happy if someone could guide me thoroughly... thenks... -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re:Could not locate clojure/contrib/string__init.class or clojure/contrib/string.clj on classpath:
omer writes: > hi i need help!!! > i have a project to finish but i keep on hitting this error: > Could not locate clojure/contrib/string__init.class or > clojure/contrib/string.clj on classpath: > i tried everything i know (which is not much) and i read tons of metiral in > the net, but i still > cant figure out how to deal with this! > i am knew to clojure and i cant continue my project! > i would be happy if someone could guide me thoroughly... > thenks... If you're just starting Clojure, I'd use Clojure 1.4. clojure.contrib.string has moved to the namespace clojure.data.string. May I ask you if and what libraries you try to use? You might need to update to newer versions if one of these use clojure.contrib, as it isn't supported with 1.4 anymore. -- Moritz Ulrich -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Anyone using Sublime Text 2 + SumblimeREPL with Windows?
On Sunday, June 24, 2012 11:27:44 PM UTC+2, Charlie Griefer wrote: > > On Sun, Jun 24, 2012 at 11:20 AM, Jacobo Polavieja > wrote: > > Hi there, > > > > My current development environment is that: Sublime Text 2 editor with > > the fabulous SublimeREPL plugin to be able to copy code into the Clojure > > REPL. > > > > As absurd as it may seem... I can't find the combination of keys to send > > functions or selected code to the REPL. It's supposed to be there, but > of > > all the keybindings that I've found, those are usually for Mac, and > haven't > > found the way to "translate" that to Windows. > > > > Let's see if anyone here uses this odd environment and can help me out. > > I'm on OS X, but the key combinations seem pretty platform-agnostic. > > From your editor tab, with the cursor at the end of a line of clojure > code, hit F2, then "l" (lowercase "L"). That should evaluate the line > of code and display the result in SublimeREPL. > > F2 followed by "f" should send the entire contents of the editor tab > over to the REPL for evaluation. > > Is that what you're looking for? If not, let me know and I'll see what > I can dig up. > > -- > Charlie Griefer > http://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love > my wife. And I wish you my kind of success. > Hi! In fact, those are some of the many ones I've tried, without success. When I press that combination it just writes the lowercase "L", as if I wasn't pressing the F2 button. I've tried it with both my notebook and an external keyboard (just in case there was some wird malfunctioning with the "Fx" keys in either one). My Default.sublime-keymap in the config/Clojure dir of the SublimeREPL package looks like this: http://pastebin.com/teSjR3zB But hitting Ctrl+F12+c+s or something like doesn't work either. I've tried to ask for help in the thread about SublimeREPL in the Sublime Text forum... but after some days there was still no answer. It's weird and maybe I'm not looking to where the real problem might be. Thanks a lot for helping! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Anyone using Sublime Text 2 + SumblimeREPL with Windows?
On Sun, Jun 24, 2012 at 2:54 PM, Jacobo Polavieja wrote: > In fact, those are some of the many ones I've tried, without success. When I > press that combination it just writes the lowercase "L", as if I wasn't > pressing the F2 button. I've tried it with both my notebook and an external > keyboard (just in case there was some wird malfunctioning with the "Fx" keys > in either one). > > My Default.sublime-keymap in the config/Clojure dir of the SublimeREPL > package looks like this: http://pastebin.com/teSjR3zB > But hitting Ctrl+F12+c+s or something like doesn't work either. > > I've tried to ask for help in the thread about SublimeREPL in the Sublime > Text forum... but after some days there was still no answer. It's weird and > maybe I'm not looking to where the real problem might be. Just to confirm... you're hitting F2, releasing F2, and _then_ hitting the "l" key, correct? Not both keys simultaneously? -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re:Could not locate clojure/contrib/string__init.class or clojure/contrib/string.clj on classpath:
I'm trying to use contrib.string and i'm currently using clojure 1.3... Basiclly i need the fuctionalty of . String as split, and such... On 25 בJun 2012 00:53, "Moritz Ulrich" wrote: > > omer writes: > > > hi i need help!!! > > i have a project to finish but i keep on hitting this error: > > Could not locate clojure/contrib/string__init.class or > > clojure/contrib/string.clj on classpath: > > i tried everything i know (which is not much) and i read tons of metiral > in > > the net, but i still > > cant figure out how to deal with this! > > i am knew to clojure and i cant continue my project! > > i would be happy if someone could guide me thoroughly... > > thenks... > > If you're just starting Clojure, I'd use Clojure > 1.4. clojure.contrib.string has moved to the namespace > clojure.data.string. > > May I ask you if and what libraries you try to use? You might need to > update to newer versions if one of these use clojure.contrib, as it > isn't supported with 1.4 anymore. > > -- > Moritz Ulrich > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Could not locate clojure/contrib/string__init.class or clojure/contrib/string.clj on classpath:
Try clojure.string: http://clojuredocs.org/clojure_core/clojure.string It's available in 1.3 and replaces clojure.contrib.string. You can also access all methods of java.lang.String via java interop. On Mon, Jun 25, 2012 at 12:12 AM, עומר כהן wrote: > I'm trying to use contrib.string and i'm currently using clojure 1.3... > Basiclly i need the fuctionalty of . String as split, and such... > > On 25 בJun 2012 00:53, "Moritz Ulrich" wrote: >> >> >> omer writes: >> >> > hi i need help!!! >> > i have a project to finish but i keep on hitting this error: >> > Could not locate clojure/contrib/string__init.class or >> > clojure/contrib/string.clj on classpath: >> > i tried everything i know (which is not much) and i read tons of metiral >> > in >> > the net, but i still >> > cant figure out how to deal with this! >> > i am knew to clojure and i cant continue my project! >> > i would be happy if someone could guide me thoroughly... >> > thenks... >> >> If you're just starting Clojure, I'd use Clojure >> 1.4. clojure.contrib.string has moved to the namespace >> clojure.data.string. >> >> May I ask you if and what libraries you try to use? You might need to >> update to newer versions if one of these use clojure.contrib, as it >> isn't supported with 1.4 anymore. >> >> -- >> Moritz Ulrich >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- Moritz Ulrich -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Anyone using Sublime Text 2 + SumblimeREPL with Windows?
On Monday, June 25, 2012 12:05:17 AM UTC+2, Charlie Griefer wrote: > > On Sun, Jun 24, 2012 at 2:54 PM, Jacobo Polavieja > wrote: > > > In fact, those are some of the many ones I've tried, without success. > When I > > press that combination it just writes the lowercase "L", as if I wasn't > > pressing the F2 button. I've tried it with both my notebook and an > external > > keyboard (just in case there was some wird malfunctioning with the "Fx" > keys > > in either one). > > > > My Default.sublime-keymap in the config/Clojure dir of the SublimeREPL > > package looks like this: http://pastebin.com/teSjR3zB > > But hitting Ctrl+F12+c+s or something like doesn't work either. > > > > I've tried to ask for help in the thread about SublimeREPL in the > Sublime > > Text forum... but after some days there was still no answer. It's weird > and > > maybe I'm not looking to where the real problem might be. > > Just to confirm... you're hitting F2, releasing F2, and _then_ hitting > the "l" key, correct? Not both keys simultaneously? > > -- > Charlie Griefer > http://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love > my wife. And I wish you my kind of success. > I've tried both options, hehe! Same result... When I press F2 it seems like nothing happens... there's no message in the status bar and seems to have no effect in anything. I've also tried with F12 and some other combinations. Pretty weird. I've also used a stable release as well as a dev one... with no change. Any idea? 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
Re: Anyone using Sublime Text 2 + SumblimeREPL with Windows?
On Sun, Jun 24, 2012 at 3:59 PM, Jacobo Polavieja wrote: > On Monday, June 25, 2012 12:05:17 AM UTC+2, Charlie Griefer wrote: >> Just to confirm... you're hitting F2, releasing F2, and _then_ hitting >> the "l" key, correct? Not both keys simultaneously? > > I've tried both options, hehe! Same result... When I press F2 it seems like > nothing happens... there's no message in the status bar and seems to have no > effect in anything. I've also tried with F12 and some other combinations. > Pretty weird. I've also used a stable release as well as a dev one... with > no change. > > Any idea? Thanks! I get no status bar message either when I press F2, so that's not (necessarily) indicative of a problem. Can you try highlighting the code that you want to have SublimeREPL evaluate and then hit the F2 -> L sequence? On OS X it used to be that you had to highlight the code, but an update changed that so as long as the cursor was on the same line, that line gets evaluated. Not sure if the Windows version has the same functionality. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Anyone using Sublime Text 2 + SumblimeREPL with Windows?
On Monday, June 25, 2012 1:05:42 AM UTC+2, Charlie Griefer wrote: > > On Sun, Jun 24, 2012 at 3:59 PM, Jacobo Polavieja > wrote: > > On Monday, June 25, 2012 12:05:17 AM UTC+2, Charlie Griefer wrote: > >> Just to confirm... you're hitting F2, releasing F2, and _then_ hitting > >> the "l" key, correct? Not both keys simultaneously? > > > > I've tried both options, hehe! Same result... When I press F2 it seems > like > > nothing happens... there's no message in the status bar and seems to > have no > > effect in anything. I've also tried with F12 and some other > combinations. > > Pretty weird. I've also used a stable release as well as a dev one... > with > > no change. > > > > Any idea? Thanks! > > I get no status bar message either when I press F2, so that's not > (necessarily) indicative of a problem. Can you try highlighting the > code that you want to have SublimeREPL evaluate and then hit the F2 -> > L sequence? On OS X it used to be that you had to highlight the code, > but an update changed that so as long as the cursor was on the same > line, that line gets evaluated. Not sure if the Windows version has > the same functionality. > > -- > Charlie Griefer > http://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love > my wife. And I wish you my kind of success. > If I highlight it, the highlighted text gets substituted by the "L". It's like F2 makes no difference in the behaviour of the program... Apart from being new to Clojure I'm also new to Sublime... I'll look for other functionality provided with F1, F2, etc combinations and see if they work properly or not. Thank you so much! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Anyone using Sublime Text 2 + SumblimeREPL with Windows?
On Sun, Jun 24, 2012 at 4:15 PM, Jacobo Polavieja wrote: > > On Monday, June 25, 2012 1:05:42 AM UTC+2, Charlie Griefer wrote: >> >> On Sun, Jun 24, 2012 at 3:59 PM, Jacobo Polavieja >> wrote: >> > On Monday, June 25, 2012 12:05:17 AM UTC+2, Charlie Griefer wrote: >> >> Just to confirm... you're hitting F2, releasing F2, and _then_ hitting >> >> the "l" key, correct? Not both keys simultaneously? >> > >> > I've tried both options, hehe! Same result... When I press F2 it seems >> > like >> > nothing happens... there's no message in the status bar and seems to >> > have no >> > effect in anything. I've also tried with F12 and some other >> > combinations. >> > Pretty weird. I've also used a stable release as well as a dev one... >> > with >> > no change. >> > >> > Any idea? Thanks! >> >> I get no status bar message either when I press F2, so that's not >> (necessarily) indicative of a problem. Can you try highlighting the >> code that you want to have SublimeREPL evaluate and then hit the F2 -> >> L sequence? On OS X it used to be that you had to highlight the code, >> but an update changed that so as long as the cursor was on the same >> line, that line gets evaluated. Not sure if the Windows version has >> the same functionality.> > > If I highlight it, the highlighted text gets substituted by the "L". It's > like F2 makes no difference in the behaviour of the program... > > Apart from being new to Clojure I'm also new to Sublime... I'll look for > other functionality provided with F1, F2, etc combinations and see if they > work properly or not. Unfortunately, I'm not sure what else to suggest as far as SublimeREPL. But since you're new to Sublime, I'll assume you're not that heavily invested in it yet? If you simply can't get SublimeREPL up and running, there are other choices to look at. Counterclockwise (http://code.google.com/p/counterclockwise/) is a Clojure plugin for Eclipse. If you're at all familiar with the Eclipse world, that might well be the easiest route to go in order to have a REPL running within your IDE. There's also La Clojure (http://plugins.intellij.net/plugin/?id=4050) for JetBrains. And of course... vi or Emacs :) There are lots of options available. While you may be inclined to ask people to chime in with their favorites, I'd strongly urge you to not go that route. That particular debate/discussion can get pretty heated :) Plus, if you search the group archives, you'll see that the conversation has been had. A couple of times. I do personally like Sublime Text, but I'm starting to look at Emacs, as it seems to be what a lot of (most of?) Clojurians use. Suggesting the other options isn't meant to be a slight against Sublime... but the fact of the matter is that if you simply can't get the REPL running within the editor, it might be worth taking the time to look at some of the other options and seeing if any of them click for you. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. -- 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
{ANN} Project Docs and Examples ... at the Alcove
Hi all, I was looking for a way to: * encourage folks to write docs for their Clojure projects * make usage examples available (like clojuredocs.org has, but for general Clojure-related projects) * help semi-standardize how Clojure projects are documented So I made this: http://www.unexpected-vortices.com/alcove/index.html ("The Alcove" seemed like a nice name for a quiet place to read docs and examples.) There are only a few projects listed there so far. If you know of others you think would benefit from being there (or if you'd like to write some examples for a project), let me know and I'll add them. Pages at the alcove are generated from: * project README.md (if present) and doc/*.md files (if present) * user-submitted examples (.md files in a separate repository --- one .md file for each project) Some benefits of this approach: * most projects will not have to change they way they set up their project (most already at least have a README.md file) * Markdown is a handsome and easy markup format that the Clojure community seems to have embraced (used in READMEs; Marginalia uses it; my understanding is that autodoc may eventually support it). * Most folks already know Markdown (it's what github, reddit, and stackoverflow use), or can pick it up in a few minutes. * doesn't tie the community to any one system. You're simply encouraging authors to create a flat directory of text files in a top-level doc directory. * The alcove-examples repository is just one text file per project. Nothing that ties anyone to "The Alcove" site. * examples files on github means people can see who contributed which examples; it's fun to see your name in lights. :) * the alcove uses Pandoc to render markdown, and so supports some things that github's markdown does not, such as tables, definition lists, LaTeX math, and a few other features. Drawbacks: * currently only supports projects on github * currently, additions/updates are done manually (via a couple of scripts and rsync). * currently not many projects have a doc directory present * currently hosted on my tiny shared hosting site Questions: * do contrib projects belong on the Alcove? * will users benefit very much from having example code for projects? * will users contribute examples? Possibilities: * possible cooperation with clojuredocs.org? (ex. "www.clojuredocs.org/alcove/..." ?) * possible hosting elsewhere? Perhaps on a more clojure-specific domain? * perhaps switch to a more general github username instead of my own? Opinions? Concerns? Wild praise? Searing complaints? General disinterest? 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
Re: {ANN} Project Docs and Examples ... at the Alcove
John Gabriele: > Opinions? Concerns? Wild praise? Searing complaints? General disinterest? This is a great initiative but so far it seems to focus only on the API reference part of documentation. I personally think that documentation guides are just as important [1]. For clojurewerkz.org projects, we put doc guides first: http://clojuremongodb.info http://clojureriak.info http://clojureneo4j.info and so on. It would be nice to see Alcove address that part, too. 1. http://jacobian.org/writing/great-documentation/ MK mich...@defprotocol.org signature.asc Description: Message signed with OpenPGP using GPGMail
Re: {ANN} Project Docs and Examples ... at the Alcove
It's a great initiative indeed, but I found the project pretty useless in its current state. Forking the repo and sending a pull request just to add an example is painful. Also, I can read rendered readme on github (and have the source code at hand), so why go to another site? I think what would be really good is the possibility to add user projects to clojuredocs.org. Every user who has an account should be allowed to add his own project, which will reuse all the clojuredocs infrastructure (comments, examples, links to the source). Readme and stuff like links to clojars and github pages could be displayed on the project's main page. However, there is a little problem with that: clojuredocs is written in RoR, AFAIK. What about rewriting it in clojure+clojurescript, anybody? :) As for non-API part of documentation, I think github's wiki is pretty good for this purpose. I'd personally won't use another site which provides similar functionality just because it was created specifically for clojure projects. понедельник, 25 июня 2012 г., 9:32:17 UTC+6 пользователь John Gabriele написал: > > Hi all, > > I was looking for a way to: > > * encourage folks to write docs for their Clojure projects > * make usage examples available (like clojuredocs.org has, but for > general Clojure-related projects) > * help semi-stanordize how Clojure projects are documented > > So I made this: > > http://www.unexpected-vortices.com/alcove/index.html > > ("The Alcove" seemed like a nice name for a quiet place to read docs > and examples.) > > There are only a few projects listed there so far. If you know of > others you think would benefit from being there (or if you'd like to > write some examples for a project), let me know and I'll add them. > > Pages at the alcove are generated from: > > * project README.md (if present) and doc/*.md files (if present) > * user-submitted examples (.md files in a separate repository --- > one .md file for each project) > > Some benefits of this approach: > > * most projects will not have to change they way they set up their > project (most already at least have a README.md file) > > * Markdown is a handsome and easy markup format that the Clojure > community seems to have embraced (used in READMEs; Marginalia uses it; > my understanding is that autodoc may eventually support it). > > * Most folks already know Markdown (it's what github, reddit, and > stackoverflow use), or can pick it up in a few minutes. > > * doesn't tie the community to any one system. You're simply > encouraging authors to create a flat directory of text files in a > top-level doc directory. > > * The alcove-examples repository is just one text file per project. > Nothing that ties anyone to "The Alcove" site. > > * examples files on github means people can see who contributed > which examples; it's fun to see your name in lights. :) > > * the alcove uses Pandoc to render markdown, and so supports some > things that github's markdown does not, such as tables, definition > lists, LaTeX math, and a few other features. > > Drawbacks: > > * currently only supports projects on github > * currently, additions/updates are done manually (via a couple of > scripts and rsync). > * currently not many projects have a doc directory present > * currently hosted on my tiny shared hosting site > > Questions: > > * do contrib projects belong on the Alcove? > * will users benefit very much from having example code for projects? > * will users contribute examples? > > Possibilities: > > * possible cooperation with clojuredocs.org? (ex. > "www.clojuredocs.org/alcove/..." ?) > * possible hosting elsewhere? Perhaps on a more clojure-specific domain? > * perhaps switch to a more general github username instead of my own? > > Opinions? Concerns? Wild praise? Searing complaints? General disinterest? > > 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
Re: {ANN} Project Docs and Examples ... at the Alcove
On Jun 25, 12:14 am, Michael Klishin wrote: > John Gabriele: > > > Opinions? Concerns? Wild praise? Searing complaints? General disinterest? > > This is a great initiative but so far it seems to focus only on the API > reference part of documentation. I'd think that autogenerated docstring docs would be api-focused. The Alcove only has doc/*.md docs (plus examples) --- not necessarily API docs at all. > I personally think that documentation guides are just as important [1]. I agree. My thought is that authors would put their guides into doc/ *.md files. ---John > For clojurewerkz.org projects, we put doc guides first: > > http://clojuremongodb.infohttp://clojureriak.infohttp://clojureneo4j.info Certainly handsome docs. :) ---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
Re: {ANN} Project Docs and Examples ... at the Alcove
On Jun 25, 12:52 am, Vinzent wrote: > It's a great initiative indeed, but I found the project pretty useless in > its current state. Forking the repo and sending a pull request just to add > an example is painful. Hm. Thanks for the feedback. > Also, I can read rendered readme on github (and have > the source code at hand), so why go to another site? 1. centralized location for docs (easy to find your way to other project docs) 2. the examples 3. more featureful rendering (I'm using Pandoc for the alcove, and so it supports extra markdown syntax for things like tables, definition lists, LaTeX math, and a few other goodies.) > I think what would be really good is the possibility to add user projects > to clojuredocs.org. That would be nice. > Every user who has an account should be allowed to add > his own project, which will reuse all the clojuredocs infrastructure > (comments, examples, links to the source). Readme and stuff like links to > clojars and github pages could be displayed on the project's main page. > > However, there is a little problem with that: clojuredocs is written in > RoR, AFAIK. What about rewriting it in clojure+clojurescript, anybody? :) I'm also curious about this. > As for non-API part of documentation, I think github's wiki is pretty good > for this purpose. I'd personally won't use another site which provides > similar functionality just because it was created specifically for clojure > projects. That's true. The github wiki's could be used for example code too. Though, I don't see it used much for that. Perhaps a dedicated site like the alcove would encourage more contributions of example code? Also, I think there's something to be said for having all the examples in one place --- one repo that anyone can grab and have the full collection. (Though, perhaps clojuredocs.org could support that too.) If clojuredocs.org were to be extended to support adding 3rd-party projects, would users prefer to put example code there, or in the project's github wiki? Thanks for the feedback. ---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
Re: {ANN} Project Docs and Examples ... at the Alcove
One thing I forgot to mention: it'd be nice to have Marginalia support, since it can be used not only for annotated source code, but also for documentation with embedded tests (although, two-column layout doesn't fit very well for this purpose, but it's another question). > That's true. The github wiki's could be used for example code too. > Though, I don't see it used much for that. Perhaps a dedicated site > like the alcove would encourage more contributions of example code? > Sure, if every visitor would see a big red button titled "Add an example!" there'd be much more chances that some examples will be contributed :) Also, I think there's something to be said for having all the examples > in one place --- one repo that anyone can grab and have the full > collection. (Though, perhaps clojuredocs.org could support that too.) > For me personally it doesn't matter; maybe someone else would find it useful. > If clojuredocs.org were to be extended to support adding 3rd-party > projects, would users prefer to put example code there, or in the > project's github wiki? > I think authors who prefer github's wiki would rather continue use it, but the important thing that anybody interested would have the right place to add snippets, comments, etc. Honestly, what I'd really appreciate is a full-blown community site, kind of mix between clojure-toolbox, clojuredocs and emacswiki. -- 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