Moonscript uses \
to call methods
to call member methods. as in a\b c, ...
translates to a.b(a,c,...)
.
this doesn't work here because io.open
is a static function (io.open(what,how)
), not a member (io.open(self,what,how)
).
you couldn't call io:open
in Lua either. the only place where io
functions allow for being called as members is when you want to read/write stdio.
but when you call it to read the file it does ?
because now it's a member method of the file. you're actually still using io.read
there, but the file object has io
as a metatable index, therefore allowing you to access the same function via file.read
, and since file\read!
translates to file.read(file)
it's the same thing.
so essentially the answer boils down to "because io:open
doesn't work in Lua".