Re: Clojure library
Hello Fernando, Please correct me if I've misunderstood. If you want to install one of your libraries locally and are running leiningen just execute: lein install This way you can reference it in other projects just like you would a library from clojars.org. Regards, Kalle Den 2 apr. 2016 02:19 skrev "William la Forge" : > OOps. Here's the link: https://github.com/aatree/aautil/ > > On Friday, April 1, 2016 at 8:19:01 PM UTC-4, William la Forge wrote: >> >> Here is a sample library which works the way you are asking. It uses >> boot, but then you didn't specify what build tool you wanted to use. :-) >> >> On Friday, April 1, 2016 at 9:33:45 AM UTC-4, Fernando Abrao wrote: >>> >>> Hello all, >>> >>> What is the best way to create a lib for internal propose, that generate >>> a jar file with .clj sources instead of .class, like it is in the libs from >>> clojars? My idea is to create a lib (jar) common for all projects. Another >>> idea is welcome. >>> >>> Regards, >>> >>> Fernando >>> >> -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Clojure library
OK, here is an older library project that uses lein: https://github.com/laforge49/aatree So I guess that covers all the bases. Personally I find boot to be amazing. And easy to use. Bill On Friday, April 1, 2016 at 8:19:46 PM UTC-4, William la Forge wrote: > > OOps. Here's the link: https://github.com/aatree/aautil/ > > On Friday, April 1, 2016 at 8:19:01 PM UTC-4, William la Forge wrote: >> >> Here is a sample library which works the way you are asking. It uses >> boot, but then you didn't specify what build tool you wanted to use. :-) >> >> On Friday, April 1, 2016 at 9:33:45 AM UTC-4, Fernando Abrao wrote: >>> >>> Hello all, >>> >>> What is the best way to create a lib for internal propose, that generate >>> a jar file with .clj sources instead of .class, like it is in the libs from >>> clojars? My idea is to create a lib (jar) common for all projects. Another >>> idea is welcome. >>> >>> Regards, >>> >>> Fernando >>> >> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Clojure library
OOps. Here's the link: https://github.com/aatree/aautil/ On Friday, April 1, 2016 at 8:19:01 PM UTC-4, William la Forge wrote: > > Here is a sample library which works the way you are asking. It uses boot, > but then you didn't specify what build tool you wanted to use. :-) > > On Friday, April 1, 2016 at 9:33:45 AM UTC-4, Fernando Abrao wrote: >> >> Hello all, >> >> What is the best way to create a lib for internal propose, that generate >> a jar file with .clj sources instead of .class, like it is in the libs from >> clojars? My idea is to create a lib (jar) common for all projects. Another >> idea is welcome. >> >> Regards, >> >> Fernando >> > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Clojure library
Here is a sample library which works the way you are asking. It uses boot, but then you didn't specify what build tool you wanted to use. :-) On Friday, April 1, 2016 at 9:33:45 AM UTC-4, Fernando Abrao wrote: > > Hello all, > > What is the best way to create a lib for internal propose, that generate a > jar file with .clj sources instead of .class, like it is in the libs from > clojars? My idea is to create a lib (jar) common for all projects. Another > idea is welcome. > > Regards, > > Fernando > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Live rendering of AsciiDoc and MarkDown files in Chrome browser (Github Flavored!)
*UPDATE: AsciiDoc vs MarkDown format:* I have been trying to edit some MarkDown files on GitHub, and it seems that the Google Chrome extension AsciiDoctor.js no longer renders MarkDown, only AsciiDoc. Not to worry, however! I just found a similar Chrome extension that does live rendering of Markdown format: Markdown Preview Plus ** Another nice tip: Both Asciidoctor.js and Markdown Preview Plus have an Options panel which allows you to choose "GitHub" styling.very nice! ** Alan On Wednesday, September 2, 2015 at 12:06:23 PM UTC-7, Alan Thompson wrote: > > Hey, > > As you all know, the README files on Github, etc can be formatted using > the either AsciiDoc (my favorite) or the older MarkDown format. However, > it is a pain to edit these files in just a plain text editor without a good > way of seeing the final, rendered format until you commit and push your > latest changes up to GH. > > If you haven't seen it yet, there is a Chrome extension named > "Asciidoctor.js" that will render both AsciiDoc *and* MarkDown files into > HTML right in your browser. It even features automatic reloading of > changes (~2 sec delay) whenever you make a change to the source file. > > If you are not already using this or a similar tool, you should give it a > try. Enjoy! > > Alan > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Stable clojure.xml/parse
Are you sure that it changes the child element order? It hasn't in my experience. Example: (clojure.xml/parse (io/input-stream (.getBytes "" "UTF-8"))) => {:tag :a, :attrs nil, :content [{:tag :b1, :attrs nil, :content nil} {:tag :a1, :attrs nil, :content nil} {:tag :a2, :attrs nil, :content nil} {:tag :a3, :attrs nil, :content nil} {:tag :a4, :attrs nil, :content nil}]} Do you have a counter-example? Or are you talking about attribute nodes maybe? Also the only parser included with clojure.xml already uses SAX: it just supplies a content handler that builds the clojure structures clojure.xml/parse returns. On Friday, April 1, 2016 at 10:39:10 AM UTC-5, Olek wrote: > > Hi! > > I need a stable clojure.xml/parse. > Unfortunately current implementation changes the order of child elements > in a node. > I use xml as a form of language for DSL. Please don't suggest switching to > clojure structures because non-clojure programmers (actually analysts) are > editing it and also there are such business requirements. > Do you know how to achieve that (do I have write SAX parser?! ;-( )? It > would be good if the outputting data structure was the same as for > clojure.xml/parse (or I will just transform it to desired form). > > Thanks in advance! > Olek > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: defmulti is a defonce?
Pure genius. :) And once I have the method working as I want I can swap in the code. Thx! -kt On Fri, Apr 1, 2016 at 12:15 PM, Gary Trakhman wrote: > I usually work around this by putting the dispatch in a separate def and > referencing the var within defmulti. > > (defmulti my-multi #'my-dispatch) > > It's barely slower for the extra var dereference and very convenient for > development. > > On Fri, Apr 1, 2016 at 12:10 PM hiskennyness wrote: > >> I just killed two hours trying to figure out why my tweaks to the >> dispatch function of defmulti did not work. Finally got the feeling I had >> found a bug in Clojure, but then I found a comment somewhere saying it is a >> feature, effectively a defonce (and, yes, looking at the source I see it >> does not do anything if it is already defined). >> >> Shucks, could we get a warning or some doc on this? >> >> But I am a Lisper, I am used to this. The classic is the initform to a >> class-allocated variable in defclass. :) >> >> -kt >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to a topic in the > Google Groups "Clojure" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/clojure/FDH6Tx1Gl8w/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Kenneth Tilton Founder/Developer TiltonTec 54 Isle of Venice Dr Fort Lauderdale, FL 33301 k...@tiltontec.com http://tiltontec.com @tiltonsalgebra 646-269-1077 "In a class by itself." *-Macworld* -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: defmulti is a defonce?
I usually work around this by putting the dispatch in a separate def and referencing the var within defmulti. (defmulti my-multi #'my-dispatch) It's barely slower for the extra var dereference and very convenient for development. On Fri, Apr 1, 2016 at 12:10 PM hiskennyness wrote: > I just killed two hours trying to figure out why my tweaks to the dispatch > function of defmulti did not work. Finally got the feeling I had found a > bug in Clojure, but then I found a comment somewhere saying it is a > feature, effectively a defonce (and, yes, looking at the source I see it > does not do anything if it is already defined). > > Shucks, could we get a warning or some doc on this? > > But I am a Lisper, I am used to this. The classic is the initform to a > class-allocated variable in defclass. :) > > -kt > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
defmulti is a defonce?
I just killed two hours trying to figure out why my tweaks to the dispatch function of defmulti did not work. Finally got the feeling I had found a bug in Clojure, but then I found a comment somewhere saying it is a feature, effectively a defonce (and, yes, looking at the source I see it does not do anything if it is already defined). Shucks, could we get a warning or some doc on this? But I am a Lisper, I am used to this. The classic is the initform to a class-allocated variable in defclass. :) -kt -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Mutual Recursion Doesn't Compile
Yeah.. protocols are more right answer to this problem , rather than using declare. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Stable clojure.xml/parse
Hi! I need a stable clojure.xml/parse. Unfortunately current implementation changes the order of child elements in a node. I use xml as a form of language for DSL. Please don't suggest switching to clojure structures because non-clojure programmers (actually analysts) are editing it and also there are such business requirements. Do you know how to achieve that (do I have write SAX parser?! ;-( )? It would be good if the outputting data structure was the same as for clojure.xml/parse (or I will just transform it to desired form). Thanks in advance! Olek -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Question about how lazy sequences are held/released/garbage collected
I think this is an example of locals-clearing at work: https://groups.google.com/forum/#!topic/clojure/FLrtjyYJdRU My guess is that the compiler clears the references 'at the point of last reference', but in this case s2 has no last reference. On Fri, Apr 1, 2016 at 9:07 AM John Jacobsen wrote: > The problem of correctly handling large lazy sequences so they don't blow > up in memory came up at work this week. > > I thought I would try to explain the following simple case to our Monday > afternoon study group, and I realized I don't understand it 100%: > > (def n 1e8) > > (let [s1 (range n) > s2 (map identity s1)] > (count s2)) > > ;;=> 1 > > > (let [s1 (range n) > s2 (map identity s1)] > (count s1)) > > ;;=> GC overhead limit exceeded > > For the first case, I get that in consuming s2, elements of both s1 and s2 > are consumed and garbage-collected; and that in the second case, clearly s1 > can't be released as it's consumed because s2 might still need it (even > though we never realize s2). My question is, as s1 is consumed in the > second case, how does it "know" that s2 still holds a reference to it, and > that it therefore should keep the realized values? What is the relevant > difference between these two examples? And where in the Clojure/core code > are the relevant details? > > Thanks in advance! > 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/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Clojure library
Hello all, What is the best way to create a lib for internal propose, that generate a jar file with .clj sources instead of .class, like it is in the libs from clojars? My idea is to create a lib (jar) common for all projects. Another idea is welcome. Regards, Fernando -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Question about how lazy sequences are held/released/garbage collected
The problem of correctly handling large lazy sequences so they don't blow up in memory came up at work this week. I thought I would try to explain the following simple case to our Monday afternoon study group, and I realized I don't understand it 100%: (def n 1e8) (let [s1 (range n) s2 (map identity s1)] (count s2)) ;;=> 1 (let [s1 (range n) s2 (map identity s1)] (count s1)) ;;=> GC overhead limit exceeded For the first case, I get that in consuming s2, elements of both s1 and s2 are consumed and garbage-collected; and that in the second case, clearly s1 can't be released as it's consumed because s2 might still need it (even though we never realize s2). My question is, as s1 is consumed in the second case, how does it "know" that s2 still holds a reference to it, and that it therefore should keep the realized values? What is the relevant difference between these two examples? And where in the Clojure/core code are the relevant details? Thanks in advance! 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/d/optout.
Re: Functions referenced in macro-expansions cannot be internal?
On condp, case etc. Alex Miller wrote a blog post on their performance a while ago: http://insideclojure.org/2015/04/27/poly-perf/ Erik. -- i farta > Den 1. apr. 2016 kl. 13.03 skrev Kenneth Tilton : > > > >> On Fri, Apr 1, 2016 at 2:41 AM, Erik Assum wrote: >> Not at all answering your question, but I would strongly suggest to at least >> deref `me` before calling the function, so it’s definition would be more >> like: >> >> (defn svr [me slot] >>(when-let [sval (slot me)] >>(if (jz-ref sval) >> (condp type @sval) > > Oooh, condp! I like it. :) Does it have some advantage over case in this bit > of code? > >> :jzi (:val @sval) >> :jzf ((:rule @sval) me) >> (error “jz-ref? type unknown”)) >> sval))) >> >> And I’d probably extract the body of if into a separate function >> >> (defn- body-of-if [me sval] >> (if (jz-ref sval) >> (condp type sval) >>:jzi (:val sval) >>:jzf ((:rule sval) me) >> (error “jz-ref? type unknown”)) >> sval)) >> >> so that your svr would end up something like >> >> (defn svr [slot me] >> (when-let [sval (slot me)] >>(body-of-if me @sval)) >> >> and then you’d call svr as >> >> (svr @me slot) > > Well, I am still getting used to this functional state game, but the way the > library works is that cells get brought up to date with a new model input > JIT, so simply reading a cell-manged attribute could force the map > impleneting "me" to be regenerated, in which case I need the ref so I can > ref-set it. But... > > I just realized every cell has to be a ref. There are *is* at least one > internal model attribute that changes (the status as nascent, alive, dying, > or dead) but that could be a ref... I will look at whether I even need models > to be refs. > > Parallelized cells? That would be cool, though for my applications > single-threaded has been more than fast enough. > > Thx for the input! > > -kt > > >> >> This way, your functions don’t need to know that their arguments happen to >> be atoms/refs, and they fit nicely in with eg >> >> (swap! atom-that-contains-me svr slot) >> >> But I do agree with Timothy that you should probably try to keep your data >> structure free of atoms, and just use one atom to hold your data structure. >> >> >> Erik. >> >> >> > On 1. apr. 2016, at 07.37, hiskennyness wrote: >> > >> > With Jellz (ne Cells in CL) I want to make reading an attribute of an >> > object seem like a normal function call, but reading a cell actually looks >> > like this: >> > >> > (defn- svr [slot me] ;; svr = slot-value-read, me = short version of "self" >> > (when-let [sval (slot @me)] >> > (cond >> > (jz-ref? sval) >> > (case (type @sval) >> >:jzi (:val @sval) >> >:jzf ((:rule @sval) me) >> >(error "jz-ref? type unknown" )) >> > :else sval))) >> > >> > svr is internal because I plan to hide it. Instead of coding (svr :mass >> > kenny) I want to code (mass kenny). And instead of hand-coding: >> > >> > (defn mass [me] (svr :mass me)) >> > >> > ...I want to code (jz/def-jzo-slot :mass). >> > >> > (defmacro def-jzo-slot [slot] >> > `(defn ~(symbol (subs (str slot) 1)) [~'me] >> > (com.tiltontec.jellz.api/svr ~slot ~'me))) >> > >> > That worked fine until I moved my testing hacks into a proper test file in >> > the test hierarchy and Clojure complained that svr was internal (I forget >> > the exact language). >> > >> > I broke down and made it defn instead of defn-, but was something else >> > going on? I am used to Common Lisp which sees what I am up to and worries >> > about the symbol being defined in the Cells package, not the package into >> > which the macroexpansion will be happening. >> > >> > I always thought that was very clever and classically XWIW (exactly what I >> > want), btw. >> > >> > This is not a big deal, but did I miss some way of keeping svr internal? >> > >> > -kt >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "Clojure" group. >> > To post to this group, send email to clojure@googlegroups.com >> > Note that posts from new members are moderated - please be patient with >> > your first post. >> > To unsubscribe from this group, send email to >> > clojure+unsubscr...@googlegroups.com >> > For more options, visit this group at >> > http://groups.google.com/group/clojure?hl=en >> > --- >> > You received this message because you are subscribed to the Google Groups >> > "Clojure" group. >> > To unsubscribe from this group and stop receiving emails from it, send an >> > email to clojure+unsubscr...@googlegroups.com. >> > For more options, visit https://groups.google.com/d/optout. >> >> -- >> 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 mem
Re: Functions referenced in macro-expansions cannot be internal?
On Fri, Apr 1, 2016 at 2:41 AM, Erik Assum wrote: > Not at all answering your question, but I would strongly suggest to at > least deref `me` before calling the function, so it’s definition would be > more like: > > (defn svr [me slot] >(when-let [sval (slot me)] >(if (jz-ref sval) > (condp type @sval) > Oooh, condp! I like it. :) Does it have some advantage over case in this bit of code? > :jzi (:val @sval) > :jzf ((:rule @sval) me) > (error “jz-ref? type unknown”)) > sval))) > > And I’d probably extract the body of if into a separate function > > (defn- body-of-if [me sval] > (if (jz-ref sval) > (condp type sval) >:jzi (:val sval) >:jzf ((:rule sval) me) > (error “jz-ref? type unknown”)) > sval)) > > so that your svr would end up something like > > (defn svr [slot me] > (when-let [sval (slot me)] >(body-of-if me @sval)) > > and then you’d call svr as > > (svr @me slot) > Well, I am still getting used to this functional state game, but the way the library works is that cells get brought up to date with a new model input JIT, so simply reading a cell-manged attribute could force the map impleneting "me" to be regenerated, in which case I need the ref so I can ref-set it. But... I just realized every cell has to be a ref. There are *is* at least one internal model attribute that changes (the status as nascent, alive, dying, or dead) but that could be a ref... I will look at whether I even need models to be refs. Parallelized cells? That would be cool, though for my applications single-threaded has been more than fast enough. Thx for the input! -kt > This way, your functions don’t need to know that their arguments happen to > be atoms/refs, and they fit nicely in with eg > > (swap! atom-that-contains-me svr slot) > > But I do agree with Timothy that you should probably try to keep your data > structure free of atoms, and just use one atom to hold your data structure. > > > Erik. > > > > On 1. apr. 2016, at 07.37, hiskennyness wrote: > > > > With Jellz (ne Cells in CL) I want to make reading an attribute of an > object seem like a normal function call, but reading a cell actually looks > like this: > > > > (defn- svr [slot me] ;; svr = slot-value-read, me = short version of > "self" > > (when-let [sval (slot @me)] > > (cond > > (jz-ref? sval) > > (case (type @sval) > >:jzi (:val @sval) > >:jzf ((:rule @sval) me) > >(error "jz-ref? type unknown" )) > > :else sval))) > > > > svr is internal because I plan to hide it. Instead of coding (svr :mass > kenny) I want to code (mass kenny). And instead of hand-coding: > > > > (defn mass [me] (svr :mass me)) > > > > ...I want to code (jz/def-jzo-slot :mass). > > > > (defmacro def-jzo-slot [slot] > > `(defn ~(symbol (subs (str slot) 1)) [~'me] > > (com.tiltontec.jellz.api/svr ~slot ~'me))) > > > > That worked fine until I moved my testing hacks into a proper test file > in the test hierarchy and Clojure complained that svr was internal (I > forget the exact language). > > > > I broke down and made it defn instead of defn-, but was something else > going on? I am used to Common Lisp which sees what I am up to and worries > about the symbol being defined in the Cells package, not the package into > which the macroexpansion will be happening. > > > > I always thought that was very clever and classically XWIW (exactly what > I want), btw. > > > > This is not a big deal, but did I miss some way of keeping svr internal? > > > > -kt > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To post to this group, send email to clojure@googlegroups.com > > Note that posts from new members are moderated - please be patient with > your first post. > > To unsubscribe from this group, send email to > > clojure+unsubscr...@googlegroups.com > > For more options, visit this group at > > http://groups.google.com/group/clojure?hl=en > > --- > > You received this message because you are subscribed to the Google > Groups "Clojure" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to clojure+unsubscr...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to a topic in the > Google Groups "Clojure" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/clojure/nQ