Re: CLJS: experiencing "callback envy" re closures as DOM event handlers

2017-10-11 Thread hiskennyness
lower? Thx! > > On 11 October 2017 at 18:20, hiskennyness <kent...@gmail.com > > wrote: > >> I am cobbling together my own little CLJS web framework and it is going >> well but I am stumped by one bit of interop: supporting event handlers that >> close over l

Re: CLJS: experiencing "callback envy" re closures as DOM event handlers

2017-10-11 Thread hiskennyness
On Wednesday, October 11, 2017 at 1:23:36 PM UTC-4, James Reeves wrote: > > If you output your HTML as DOM nodes, rather than a string, you can just > attach the function directly to the attribute. > Aha! I have only ever mucked with innerHTML, I will have to look into this approach.

CLJS: experiencing "callback envy" re closures as DOM event handlers

2017-10-11 Thread hiskennyness
I am cobbling together my own little CLJS web framework and it is going well but I am stumped by one bit of interop: supporting event handlers that close over lexical variables. It seems to be a piece of cake for, inter alia, Reagent. Here is an excerpt from the "simple" example, hacked a bit

Re: Code Review -- Testing truthiness twice

2017-10-03 Thread hiskennyness
On Sunday, October 1, 2017 at 5:11:55 PM UTC-4, Scott Barrett wrote: > > Clojure noob, here. I'm very excited to be learning about this language > and becoming a part of this community :) I'm writing a function that works > well, but seems just a bit wrong to me, stylistically speaking. I was

Re: How to try/catch Let bindings?

2017-10-02 Thread hiskennyness
On Saturday, September 30, 2017 at 6:14:33 PM UTC-4, Didier wrote: > > I'm curious how others handle this use case, which I feel should be pretty > common. > > Given you have a series of business process steps, where the flow is too > complex for the arrow macros, and you also like to name the

Re: beginning to learn Clojure after imperative programming my whole life

2017-08-10 Thread hiskennyness
On Wednesday, August 9, 2017 at 2:43:20 PM UTC-4, Andy wrote: > > This feels like a different world. > Yep. > > Has anyone experienced a sharp increase in their problem solving abilities > after switching to Clojure? > Not sure about problem-solving per se, but better tools do seem to take

Re: Control Break in Report

2017-07-15 Thread hiskennyness
Two thoughts: 1. Use an atom. 2. Use loop instead of doseq, so you can maintain a bit of state as you go. -kt On Saturday, July 15, 2017 at 6:18:10 PM UTC-4, Kevin Kleinfelter wrote: > > How does one detect a change in a doseq? > > I'm trying to do what data processing people would call a

Re: Simple clojure example improvements sought

2017-01-10 Thread hiskennyness
On Tuesday, January 10, 2017 at 2:37:22 PM UTC-5, Beau Fabry wrote: > > With specter: > > (map-indexed (fn [i name] (sp/transform sp/MAP-VALS #(nth % i) optij)) > (:name optij)) > => ({:name :tom, :age 1, :tone :do} {:name :dick, :age 2, :tone :re} > {:name :harry, :age 3, :tone :mi}) > One

Re: Simple clojure example improvements sought

2017-01-10 Thread hiskennyness
On Tuesday, January 10, 2017 at 1:59:05 PM UTC-5, Francis Avila wrote: > > > > On Tuesday, January 10, 2017 at 9:27:24 AM UTC-6, hiskennyness wrote: >> >> Whenever I code something like this I get the feeling a clojure guru >> could do it more simply, and I love l

Simple clojure example improvements sought

2017-01-10 Thread hiskennyness
Whenever I code something like this I get the feeling a clojure guru could do it more simply, and I love learning new tricks. Here is my simple (real-world, btw) problem and solution. Is there a better way? ;; Problem: given optimized* json maps (* to avoid duplicating keys): (def optij {:name

interop method confusion?

2016-10-19 Thread hiskennyness
This code excerpt (most significantly the createProducer call) works swimmingly: (defn t-prod [ct] > (with-open [client (PulsarClient/create "http://localhost:8080;)] > (pln :client (bean client)) > (with-open [prod (.createProducer client >

Re: Java interop: dealing with Java implementation instances vs interfaces

2016-10-16 Thread hiskennyness
er says it returns, and you'll be ok. > > Erik. > -- > i farta > > Den 16. okt. 2016 kl. 08.42 skrev hiskennyness <kent...@gmail.com > >: > > Not sure if this is a Java question or Clojure question, but I think it is > the latter. > > I am trying to use th

Java interop: dealing with Java implementation instances vs interfaces

2016-10-16 Thread hiskennyness
Not sure if this is a Java question or Clojure question, but I think it is the latter. I am trying to use the Yahoo pulsar library https://mvnrepository.com/artifact/com.yahoo.pulsar/pulsar-client/1.14 from Clojure. It is going OK in general, but a couple times now trying to replicate Java

Re: Newbie question

2016-09-05 Thread hiskennyness
On Sunday, September 4, 2016 at 4:58:34 PM UTC-4, Charlie wrote: > > I'm going through the Do Things: A Clojure Crash Course, and the following > example (in REPL) is presented: > > (defn recursive-printer > ([] > (recursive-printer 0)) > ([iteration] > (println iteration) >

Re: Why is this not considered to be in a go block?

2016-08-26 Thread hiskennyness
Doesn't work in a FOR loop either. Thank god for LOOP! :) -kt On Thursday, August 25, 2016 at 7:21:20 PM UTC-4, hiskennyness wrote: > > I am getting an error about >! not being in a go block with this code: > > (go-loop [state :nl > column 0 >

Why is this not considered to be in a go block?

2016-08-25 Thread hiskennyness
I am getting an error about >! not being in a go block with this code: (go-loop [state :nl column 0 last-ws nil buff ""] (let [line-out (fn [c b] (>! out (apply str b (repeat (- col-width (count b ))

A Cells port of David's core.async webinar on avoiding Callback Hell

2016-07-25 Thread hiskennyness
As I watched David Nolen's compelling core.async web client webinar (http://go.cognitect.com/core_async_webinar_recording) I started to wonder if CSP was not another metaphor for Cells (the spreadsheet being another, and in FRP we have a time series or stream or something). So I went ahead and

Re: async-webinar vs. lein-cljsbuild vs nooby

2016-07-22 Thread hiskennyness
On Thursday, July 21, 2016 at 7:38:27 PM UTC-4, hiskennyness wrote: > > This cemo of channels in a web client works great. > >https://github.com/cognitect/async-webinar/blob/master/project.clj > > It uses plugin: > > [lein-cljsbuild "1.0.4-SNAPSHOT"] >

async-webinar vs. lein-cljsbuild vs nooby

2016-07-21 Thread hiskennyness
This cemo of channels in a web client works great. https://github.com/cognitect/async-webinar/blob/master/project.clj It uses plugin: [lein-cljsbuild "1.0.4-SNAPSHOT"] While trying to extend the webinar with my Cells library https://github.com/kennytilton/rube (which loads nicely from

ClojureScript + qooxdoo mobile + Cells, Part III

2016-06-20 Thread hiskennyness
We complete porting the qx.Mobile "hello world" to CLJS+Cells+Cordova+Android, and towards the end I digress for quite a while on what Cells does for development: https://github.com/kennytilton/rube/wiki/Intro-3:-Replicating-the-qx.Mobile-starter-app-with-ClojureScript Now running also on iOS

qooxdoo mobile + ClojureScript Rizing

2016-06-18 Thread hiskennyness
Parts 1 & 2 of a three-part series introducing Qxia, a framework for programming qooxdoo mobile via ClojureScript (with dataflow/reactive Cells beneath your wings): 1.

Re: why is it so annoying to run clojure code

2016-06-13 Thread hiskennyness
I do not know if I have the right direction*, but qooxdoo was the low-hanging fruit for me because I have a ton of experience wrapping its so-called "Desktop" variant (Web RIAs) so... it is now pretty easy to build a mobile** app in CLJS/qx.Mobile***. * I will look at ReactNative next, though

Re: why is it so annoying to run clojure code

2016-06-13 Thread hiskennyness
On Saturday, June 11, 2016 at 6:19:06 AM UTC-4, Cornelius Goh wrote: > > Just for curiosity. What mobile phone (Android or iOS) did you port your > CommonLisp libraries onto ? I did Andoid since Cordova said it could not build for iOS on Linux, but up soon on my do-list is dusting off my Mac

Re: why is it so annoying to run clojure code

2016-06-09 Thread hiskennyness
On Thursday, June 9, 2016 at 12:08:39 PM UTC-4, Jiacai Liu wrote: > > I started learning clojure recently, and I am annoyed at the way to run > it (aka. lein run). why clojure script can't be run like python,ruby or > scala, like python .py > Having just gotten into Clojure, I have the same

Re: Clojurescript macros evaluate?

2016-06-01 Thread hiskennyness
On Wednesday, June 1, 2016 at 4:25:31 PM UTC-4, David Nolen wrote: > > Nothing to do with macros, that wouldn't work in Clojure either, the > problem is only the namespaced keyword - ::tiltontec.qxia.base/m.Composite > > Note the leading double colon, :: > > The :: indicates that

Clojurescript macros evaluate?

2016-06-01 Thread hiskennyness
Am I right that the following reflects a difference in Clojure macros from Common Lisp macros, and if so, am I missing a workaround? The context is my trying to create a cljs wrapper for the qooxdoo js library, leveraging my model/cell dataflow framework written in all cljc. It is going well

Re: Is there an apply-able new?

2016-05-31 Thread hiskennyness
a shot. This keeps coming up where qooxdoo decides some things should be constructor params instead of properties. -kt > > On Friday, May 27, 2016 at 10:24:12 AM UTC-7, hiskennyness wrote: >> >> qooxdoo lets us supply oft-used widget parameters to the constructor. For >>

Is there an apply-able new?

2016-05-27 Thread hiskennyness
qooxdoo lets us supply oft-used widget parameters to the constructor. For example, a button can specify its label and icon at new time. And this works fine from cljs: (new qx.ui.mobile.form.Button "Go!") ;; label is the first arg But I am wrapping qooxdoo in something more concise and want

Re: Avoiding nested ifs...

2016-05-27 Thread hiskennyness
On Thursday, May 26, 2016 at 10:50:24 AM UTC-4, John Szakmeister wrote: > > I'm very much a fan of bailing out early in imperative > programming as it helps to avoid a bunch of nested if conditions > that are to follow and read. This typically comes up when > checking arguments to ensure

Re: Cells aka Dataflow aka FRP now pure CLJC

2016-05-26 Thread hiskennyness
On Wednesday, May 25, 2016 at 2:00:14 AM UTC-4, Keith Irwin wrote: > > I remember you from the olden days as a colorful personality on > comp.lang.lisp. > We sure had some fun over there. Still the best tech forum I know of. > > Having spent this time with Clojure the language, and the

Cells aka Dataflow aka FRP now pure CLJC

2016-05-24 Thread hiskennyness
Last week was supposed to be a port from a Clojure version to a CLJS version but for the heck of it I did it all in CLJC and (OMG) I now have my cherished little project running either way: https://github.com/kennytilton/rube Yes, that is my third and last home for the beast. Clojure: lein

Re: reader conditional not handling defmacro?

2016-05-20 Thread hiskennyness
Thanks, Sean. (My follow-up fix request went out just as your fix came in.) -kt On Friday, May 20, 2016 at 2:16:47 PM UTC-4, hiskennyness wrote: > > > > On Friday, May 20, 2016 at 1:34:43 PM UTC-4, hiskennyness wrote: >> >> My next problem with .cljc (which is going very

Re: reader conditional not handling defmacro?

2016-05-20 Thread hiskennyness
On Friday, May 20, 2016 at 1:34:43 PM UTC-4, hiskennyness wrote: > > My next problem with .cljc (which is going very very well overall!) has to > do with macros. > snip > > ps. I will try the old trick of having a helper defn with-defobserver and > with-whatever to

reader conditional not handling defmacro?

2016-05-20 Thread hiskennyness
My next problem with .cljc (which is going very very well overall!) has to do with macros. Should I mention that I am building under Figwheel? This toolchain stuff has this old Lisper's head spinning. Without a conditional, code using this macro compiles fine (the key bit being where I offer

atoms not working same in cljs as in clj?

2016-05-20 Thread hiskennyness
I see here https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure that "Atoms work as in Clojure.", but I think I see a difference: 1. I am using a custom type hierarchy in a namespace tiltontec.modeller.cell_types: (defonce ia-types (-> (make-hierarchy)

It's Alive! answers the question "What's alive?"

2016-05-17 Thread hiskennyness
Ok, the Clojure port of my Cells library now has models aka objects, pretty much just maps of Cells with an option of typing them, but arranged in a tree so we can implement a universe of interdependent objects (kinda like the real world):

Re: changing metadata questions

2016-05-13 Thread hiskennyness
> > > OK, I am working with refs, let's do it!: > > (let [x (with-meta (ref {:a 42}) >> {:raw 17})] >>(alter-meta! x #(update-in % [:raw] inc)) >>(meta x)) > > > Nope. IRef cannot be cast to IObj. ...google...google... Hunh? The :meta > option on ref? > > [1] Why the

changing metadata questions

2016-05-12 Thread hiskennyness
It occurred to me that the game I was playing shunting initargs off into a "raw" key of one name or another before converting them into a map might more comprehensibly be done by treating the raw values (and other attributes I use to manage these beasts) as metadata. But I need to update the

Re: understanding a clojuredocs merge example

2016-05-12 Thread hiskennyness
On Thursday, May 12, 2016 at 9:33:29 AM UTC-4, Michael Willis wrote: > > As long as we're cutting out unnecessary code, this is also equivalent: > > (defn baz [options] >(merge {:opt1 "default-1" :opt2 "default-2"} options)) > > Heh-heh, I was going to point that out. And now baz is a

Re: apply madness

2016-05-12 Thread hiskennyness
On Thursday, May 12, 2016 at 4:10:39 AM UTC-4, Michael Gardner wrote: > > There's no need to avoid `apply` altogether, IMO. You could do something > like this: > > (let [raw (list :a 1 :b 2 :c 3)] > (into {:raw raw} > (filter (comp even? second) > (apply hash-map

Re: apply madness

2016-05-12 Thread hiskennyness
On Thursday, May 12, 2016 at 3:59:10 AM UTC-4, dennis wrote: > > A try: > > (let [raw (list :a 1 :b 2 :c 3)] > (->> raw >(partition 2) >(filter #(even? (second %))) >(map vec) >(into {}) >(merge {:raw raw}))) > > => {:b 2, :raw (:a 1 :b 2 :c 3)} >

apply madness

2016-05-12 Thread hiskennyness
This does what I want but feels nooby-ish, as in "in a month I will do this without APPLY": (let [raw (list :a 1 :b 2 :c 3)] > (apply assoc {} > :raw raw > (apply concat >(filter #(even? (second %)) >(apply hash-map raw) >

understanding a clojuredocs merge example

2016-05-12 Thread hiskennyness
I do not understand something this example: https://clojuredocs.org/clojure.core/merge#example-54c7b859e4b0e2ac61831cdf Specifically: (defn baz [& options] >(let [options (merge {:opt1 "default-1" :opt2 "default-2"} > (first options))] > options)) > (baz

Re: [ANN] CIDER 0.12 (Seattle)

2016-04-18 Thread hiskennyness
Pardon a noob question, but I just installed 0.12 and when I did C-x C-f intending to visit a new file Emacs insisted on opening an existing file that did not even match. eg, I typed a.clj and it opened evaluate.clj. I was trying to create cells_test.clj, typed that, and it opened (and showed

defmulti is a defonce?

2016-04-01 Thread hiskennyness
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

Functions referenced in macro-expansions cannot be internal?

2016-03-31 Thread hiskennyness
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?

No *print-depth* in Clojure? How about recursive data structures?

2016-03-31 Thread hiskennyness
In porting my modelling library Cells to Clojure I managed to get a stack overflow when the printer tried to print a recursive data structure* I have used in the Common Lisp version. * Basically, a ref holds a map in which some values are maps in which some values are the ref. In Lisp we have

Re: How manage this state problem The Clojure Way?

2016-03-27 Thread hiskennyness
ry orders everything so no two updates can run concurrently, but something like megarefs could let me relax that yet retain much consistency. Thank for the input. -kenneth > > - James > > On 26 March 2016 at 12:07, hiskennyness <kent...@gmail.com > > wrote: > >>

Re: How manage this state problem The Clojure Way?

2016-03-26 Thread hiskennyness
Follow-up question: how do I test that I am collision-proof? Perhaps: 1. Kick off two threads (call them 1st and 2nd) 100ms apart 2. Have them update the same ref 3. Have 1st do the initial reset! to the ref then sleep for 200ms 4. 2nd just charges ahead 5. Check that each took

How manage this state problem The Clojure Way?

2016-03-25 Thread hiskennyness
*Background* I am starting on a port of my Common Lisp Cells dataflow hack (much akin to Javelin in surface semantics) to Clojure and am struggling to wrap my head around Clojure state-handling, deftype, and defrecord.

getting started: generated address-book directory does not match tutorial

2016-01-29 Thread hiskennyness
[Also posted in the Hoplon github issues area.] I have been working thru the https://github.com/hoplon/hoplon/wiki/Get-Started guide on a brand new Ubuntu VM running under vmware on windows 10 and all went well until: lein new hoplon address-book That actually went fine, but the resulting