4 ms·
That seems like an exceedingly error-prone thing to write. "x +=1" isn't a value and the unmanaged mutation will be surprising when it happens. On a Python impl
by lmm 10y ago
That seems like an exceedingly error-prone thing to write. "x +=1" isn't a value and the unmanaged mutation will be surprising when it happens. On a Python implementation with parallelism (e.g. Jython) you could very easily end up losing updates - on CPython the GIL will probably mean your code accidentally doesn't exhibit that problem, but that doesn't seem a very desirable way to code.
- jononor 10y agoWhat is the proposed alternative? (using a named function or method just seems to be semantically the same, just more characters)
- lmm 10y agoSomething like functional reactive programming style, where you explicitly define a pipeline from foo.click to x and explicitly gather together all your pipelines (explicitly defining the interleaving semantics rather than just "whenever an event happens it happens") and run them in one place.
- xapata 10y agofoo.on_click(partial(q.append, foo)) The nice thing about ``append`` is it's atomic (for builtins).
- jononor 10y agoWhere does the update of `x` go in this example? By observing a Queue or Stream `q`?
- xapata 10y agoIf it must be mutable state, then ideally you'd have a single consumer thread for counting off that queue to avoid worrying about locks. Or maybe what's in the queue gets written to a permanent log and ``x`` is a query of that log, a la Datomic.
- deleted 10y ago[deleted]