Fork me on GitHub
#hoplon
<
2016-07-25
>
micha00:07:46

so that appears to work ok

micha00:07:10

the only thing that won't really work there is using set! to mutate the dynamic var

micha00:07:19

from inside a bound-fn

micha00:07:28

hm yeah that's not the best solution

micha00:07:24

ok there we go

jumblerg00:07:44

let’s see it!

jumblerg00:07:34

that will be incredibly useful

jumblerg00:07:44

do you want to roll that into hoplon proper?

micha00:07:49

we could yeah

micha00:07:09

i wonder if binding+ and fn+ would be good names?

micha00:07:15

or something like that?

micha00:07:31

i guess there is no additional cost to using this form of binding

micha00:07:35

no runtime cost anyway

micha00:07:44

it's all computed at compile time

jumblerg00:07:54

how do the semantics differ from a clojure.core binding?

micha00:07:04

they don't, i don't think

micha00:07:31

actually i'm not 100% sure

jumblerg00:07:47

if the semantics are similar, binding sounds good to me, we have namespaces for disambiguation

jumblerg00:07:40

this will give us a nicely controlled, dynamic inheritance mechanism

micha00:07:43

hm this solution is too simple

micha00:07:49

unfortunately

micha00:07:06

it only works when everything is nested inside the binding expression

micha00:07:13

because it works during macroexpansion only

micha00:07:01

i guess i need to keep track of bound vars in a global js variable

micha00:07:06

not just in the macro

jumblerg00:07:09

can you remind me of the difference between defelem and defelem+ again?

jumblerg00:07:39

+ allows destructuring to cells in the fn definition

jumblerg00:07:12

but i recall there being some larger ideas than that behind it

micha00:07:51

(defelem x1 [{:keys [color]} kids]
  (ul :css (cell= {:color color}) (map li kids)))

(defelem+ x2 [{:keys [color]} kids]
  (ul :css (cell= {:color color})
    (for-tpl [kid kids] (li kid))))

micha00:07:57

if you do this:

micha00:07:26

(def x (x1 "hello"))
(body (x "there"))

micha00:07:44

you end up with something like <ul><li>hello</li>there</ul>

micha00:07:07

(def x (x2 "hello"))
(body (x "there"))

micha00:07:23

you get <ul><li>hello</li><li>there</li></ul>

micha00:07:29

the main difference is the arguments, like you said

flyboarder00:07:35

@micha is there any way to get the Dom object as some data structure prior to creating it? Like some AST of the node structure?

micha00:07:35

they're cells with defelem+

micha00:07:51

@flyboarder: how do you mean?

micha00:07:04

the lisp program is an AST, i guess?

flyboarder00:07:23

I'd like to use zippers on the elements to navigate

micha00:07:56

jquery provides a very good zipper implementation

flyboarder00:07:56

Yeah that's what I was thinking, just use the clojure code as a list

micha00:07:11

way better than the immutable zipper stuff

flyboarder00:07:16

I didn't know jquery had

micha00:07:17

yeah because the dom isn't immutable

micha00:07:26

so you don't need to do the fancy functional zipper thing

micha00:07:29

it makes no sense

micha00:07:37

jquery is basically a zipper library

micha00:07:46

that's it's whole thing, really

micha00:07:06

$(elem).children().find(".foo").map(...

flyboarder00:07:20

Hm ok, i see what you mean

micha00:07:39

the functional zipper stuff wants to achieve that, but it can only partly do it because of the limitations of immutable data

flyboarder00:07:28

Mostly just curious, I'm working on a boot task for inlining html-imports and css files and turning the file into a zipper made it super easy once you get around the zippers location

micha00:07:51

you mean like html files?

flyboarder00:07:12

I used hickory and wrote an extension for CDs

micha00:07:16

you can parse those with tagsoup, there are some handy functions in boot-hoplon for that

micha00:07:37

then make a zipper and use it on the immutable hiccup stuff

micha00:07:47

yeah there are lots of things

flyboarder00:07:50

Yeah hickory wraps tag soup

micha00:07:51

enlive is another one

flyboarder00:07:23

I kinda want to write another zipper for JS but rhino is its own beast

micha00:07:18

in js for dom stuff jquery is an excellent zipper implementation

micha00:07:35

statefulness makes that kind of thing a lot easier

micha00:07:39

and mutation in place

flyboarder00:07:34

But I'm more looking to manipulate the JS file itself, so I'm looking for a zipper around a JS parser which currently doesn't exist for clojure

micha00:07:02

ah like parse javascript AST and manipulate that?

flyboarder00:07:16

For actual file manipulation

micha00:07:18

there is a thing called sweetjs i think

micha00:07:24

like macros for javascript

micha00:07:34

it exposes an AST

micha00:07:48

maybe that would be helpful

flyboarder00:07:48

That looks interesting might be able to use their parser

micha00:07:26

you could possibly express your transformations in terms of macros, even

micha00:07:45

then just macroexpand

flyboarder00:07:33

I hadn't thought of that, hmmm

flyboarder00:07:06

I guess for the JS stuff I don't really need to be able to parse it for my use, since the browser doesn't have things like import the way html and css does

kenneth06:07:06

@alandipert: Hey Alan, thanks for offering to help. The widget in question is from here https://publish.twitter.com (the Embedded timeline) I’ve created an example repo showing the problem we are having: https://github.com/exicon/twitter-embed-issue Where we are having trouble reinitialising the widget, I have tried to explain the problem in more detail in the repo's readme. If you have any questions let me know and thanks again.