Hacker News new | past | comments | ask | show | jobs | submit login

    x = rx.cell(3)
    y = rx.cell(5)
    z = bind -> x.get() + y.get() #1
    z.get() # 8
    x.set(1)
    z.get() # 6
I wonder when #1 will be simply expressed as z <- x + y.



That would require a new language/syntax layer, which we wanted to avoid. (There's also something to be mentioned for being explicit and reducing "magic," which was part of what drove us to create this library in the first place.)

That said, you could imagine a simple implementation by reflecting on each sub-expression (or auto-lifting operators/functions), where something like `z <- x + y` is compiled to:

  z = bind ->
    tmp0 = if x instanceof ObsCell then x.get() else x
    tmp1 = if y instanceof ObsCell then y.get() else y
    tmp0 + tmp1
Rather than forking CoffeeScript for the `<-`, you could start with a simple expression parser:

  z = rx.expr('x + y')


Right, I've been doing too much lisp recently, I assume macros everywhere.

Couldn't `bind` be ordered (meaning always reading its input) to avoid '.get()' ?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: