[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: From Lua to Python?
- From: Sean Conner <sean@...>
- Date: Sat, 15 Jul 2017 02:33:43 -0400
It was thus said that the Great Petri Häkkinen once stated:
>
> > On 14.7.2017, at 23.40, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> > In Lua, this
> > is errorprone as it is a dynamic language - so an API that asks users
> > to say file:write() helps the user to avoid mistakes.
>
> Actually, how is file:write("abc") any less error prone than say
> shb_file_write(file, "abc")? (Example from my Shinobi game engine)
>
> In both cases it's just as easy to have a typo in "file" arg. Having the
> ':' in the OO case actually makes it more error prone because of the ':'
> vs. '.' syntax.
It allows for a form of type substitution. I can write a function like:
function copy(to,from)
local data = from:read(8192)
if data then
to:write(data)
return copy(to,from)
end
end
and as long as the from parameter supports read() and the to parameter
supports write(), it won't really matter if to and from aren't a FILE*
userdata.
-spc
- References:
- Re: From Lua to Python?, Javier Guerra Giraldez
- Re: From Lua to Python?, Dibyendu Majumdar
- Re: From Lua to Python?, Enrico Colombini
- Re: From Lua to Python?, steve donovan
- Re: From Lua to Python?, Javier Guerra Giraldez
- Re: From Lua to Python?, steve donovan
- Re: From Lua to Python?, Dibyendu Majumdar
- Re: From Lua to Python?, Petri Häkkinen
- Re: From Lua to Python?, Dibyendu Majumdar
- Re: From Lua to Python?, Petri Häkkinen