planck

Planck ClojureScript REPL
johanatan 2016-07-05T02:34:40.000711Z

I'm getting the following error when trying to build latest:

file.c:4:10: fatal error: 'unicode/ustdio.h' file not found
#include "unicode/ustdio.h"
         ^
1 error generated.
make[1]: *** [file.o] Error 1

johanatan 2016-07-05T02:34:47.000712Z

@mfikes: What dependency am I missing?

johanatan 2016-07-05T02:34:51.000713Z

[on Mac OS X]

mfikes 2016-07-05T02:35:56.000714Z

Try brew install icu4c. I think I failed to update the build docs with that one.

johanatan 2016-07-05T02:39:49.000715Z

That worked! And yep seems to be missing from the docs.

mfikes 2016-07-05T02:40:54.000716Z

@johanatan: Sorry about that. I was careful about all of the Unixes but forgot about OS X.

johanatan 2016-07-05T02:42:08.000717Z

Do you know what the cause of this stack trace is?

goog.global.setTimeout is not a function. (In 'goog.global.setTimeout(cb, 0)', 'goog.global.setTimeout' is undefined)
	cljs.core.async.impl.dispatch/queue-dispatcher (cljs/core/async/impl/dispatch.cljs:29:6)
	cljs.core.async.impl.dispatch/run (cljs/core/async/impl/dispatch.cljs:33:4)

johanatan 2016-07-05T02:42:13.000718Z

[in planck 2.0]

mfikes 2016-07-05T02:42:32.000719Z

Yes… hah! I was actually thinking about that one.

mfikes 2016-07-05T02:43:12.000720Z

The problem is that setTimeout is not part of JavaScriptCore. We inject it in under 1.x, but with the C-based 2.0 we need some sort of timer implementation to back it up.

mfikes 2016-07-05T02:43:41.000721Z

Perhaps some crude thing built off of setitimer

johanatan 2016-07-05T02:43:49.000722Z

Ahh, perhaps this would do it: http://man7.org/linux/man-pages/man2/timer_create.2.html

mfikes 2016-07-05T02:44:01.000723Z

Exactly, except for OS X

johanatan 2016-07-05T02:44:15.000724Z

OS X is POSIX compliant no?

mfikes 2016-07-05T02:45:31.000725Z

If timer_create exists on OS X, that would do the trick.

johanatan 2016-07-05T02:46:40.000726Z

Looks like setitimer is definitely supported on OS X so that may be the better option.

mfikes 2016-07-05T02:47:53.000727Z

Yes. It is there, I believe. It is fairly limited, so difficult to program against. But it would suffice.

mfikes 2016-07-05T02:48:27.000728Z

We could almost use timer_create on Linux and perhaps something else on OS X, with #ifdefs if easier.

johanatan 2016-07-05T03:19:18.000729Z

Ya, that could work. Are you planning to do this soon? If not, I can do it if you show me where the code needs to be hooked in. <-- @mfikes

mfikes 2016-07-05T03:24:06.000730Z

@johanatan: No, I probably won’t get to it right away. There is a TODO on the Wiki that you could put your name next to if you’d like to pursue it. Also, there is stuff in 1.x which could be used as inspiration on how the general mechanism works. (It is just another global function like the PLANCK_* functions, just with the name setTimeout.) It turns out we already need timers in the bit of code that “hops” the cursor back after typing a closing delimiter like ] or ), and in that code you can see that we simply burn a thread that sleeps in order to crudely implement a timer. Planck 2.0’s initial setTimeout implementation could actually be implemented using the same strategy, just go get something in the codebase that works (thus allowing core.async to work, etc., and we can figure out a better implementation using timer_create, setitimer, or even kqueue.

johanatan 2016-07-05T03:25:00.000731Z

Mmm, ok. But how to hook goog.global.setTimeout into it?

mfikes 2016-07-05T03:25:16.000732Z

Oh.. let’s see...

mfikes 2016-07-05T03:29:13.000736Z

In other words @johanatan I think that var global = this; might have a consequence that var setTimeout = … being automatically hooked into goog.global. (But, I’m not a JavaScript expert.) I know I got that from Nolen: https://github.com/omcljs/ambly/commit/da21de24f63e11d6faf93e47d1e6a2e0b75091d6

mfikes 2016-07-05T03:29:40.000737Z

(Some Planck code is based on Ambly 🙂 )

mfikes 2016-07-05T03:31:02.000738Z

And that setTimeout came from this SO: http://stackoverflow.com/questions/21100190/using-setinterval-settimeout-in-javascriptcore-framework-for-objectivec/21170761#21170761 (it has been in use in Planck for quite a while now.)

johanatan 2016-07-05T03:34:37.000741Z

Mmm, ok

johanatan 2016-07-05T03:34:43.000742Z

We'll see how it goes. 🙂