lua-users home
lua-l archive

Re: From Lua to Python?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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

AltStyle によって変換されたページ (->オリジナル) /