Open airstruck opened 5 years ago
The problem is that without __gc
support, you leak file descriptors. This makes io.open
a foot-gun waiting to happen.
Additionally, there is no solid concept of a "file" on the web, so you're better off using fengari-interop to call whatever file-like API you want.
whatever tricks
require
uses, right?
What trick are you referring to?
js
library is already loaded in fengari-web; same as all lua standard libraries. https://github.com/fengari-lua/fengari-web/blob/77d35f5e1516f431cbb96e165b4272f2fc9b0b3a/src/fengari-web.js#L84
How much trouble would it be to add support for
io.stdout:write
,io.stdin:read
,io.open
in read mode, andfile:read
?I assume
io.stdout:write
is easy; basically aprint
without tabs or newlines, that'll fail on printing most non-string types. It should also probably flush itself, if possible.Not sure how difficult
io.stdin:read
would be, but seems possible at least.And I guess opening a file in read mode could use whatever tricks
require
uses, right?That probably covers most of the commonly-used stuff from
io
. Is there any interest in this? I'd be willing to take a crack at it myself, although I just discovered this project and I'm sure someone else could get it done faster and better.If only one of these things can happen, a blocking
io.stdin:read
is probably the most essential. The rest of it can probably be worked around pretty easily. Meanwhile, if anyone knows of a possible workaround forio.stdin:read
, I'd be interested in hearing about it.