ceylon / ceylon-js

DEPRECATED
Apache License 2.0
54 stars 9 forks source link

Implement process.readLine() #197

Open chochos opened 11 years ago

chochos commented 11 years ago

process.readLine() is unimplemented; it needs a sensible implementation that could work in browser and node.js

chochos commented 10 years ago

This can't be made to work in browser for reasons that should be obvious. And node.js does not offer a synchronous way to read from a stream (even the newest version as of this writing, v0.10.28, which includes a new unstable module called readline, offers only asynchronous readlines with callbacks).

quintesse commented 10 years ago

Would it be worth it to have an asynchronous version in the language module?

gavinking commented 10 years ago

Perhaps we should deprecate the synchronous version, and only have the async version. But that would sorta introduce threads into the picture, I guess.

chochos commented 10 years ago

Yes you need threads for this in jvm. And it's IMO an unnecessarily convoluted way of doing things, because of node's event-based callbacks-for-everything model.

chochos commented 10 years ago

I'm hoping the node.js people realize how limited the async readline is (it borders on useless, honestly) and offer a synchronous version.

gavinking commented 10 years ago

@chochos can't you just write a polling loop that waits for a response?

chochos commented 10 years ago

Other than having a while (line===undefined); I haven't found another way of making the damn thing wait.

gavinking commented 10 years ago

Isn't there some kind of sleep()?

chochos commented 10 years ago

There's a sleep module, but it's not part of the core modules, so if you haven't installed it using npm, you'll get an error Cannot find module 'sleep'