lua-users home
lua-l archive

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

On Jan 31, 2005, at 20:10, André de Leiradella wrote:

It's not a proposal, just a common syntax.

Evil I say! :P

I'd like too to have multiple
constructors in Lua as it is dynamic typed (it get's too confusing
inside the only constructor to compare all possible combinations of
arguments to decide how to instantiate the object).

You can use different factory method names:

b = 'me' )
b = B.newWithNumber( 1 )
b = B.newWithBoolean( true )

etc... etc...

The main point being _not_ to introduce any unnecessary new 'new' keyword as you can achieve the exact same effect with a factory method. One less thing for your user to remember :))


PA, Onnay Equitursay