[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Simulate Polymorphism in Lua
- From: David Dunham <david@...>
- Date: Fri, 18 Jan 2008 12:41:17 -0800
On 18 Jan 2008, at 10:14, RJP Computing wrote:
I would like to bind two functions that are using polymorphisms in C
++, to Lua, is this possible?
example:
Create( std::string path, std::string section )
and
Create( std::string hardware, std::string device,
std::map<std::string, std::string> hardwareInitSettings )
This isn't actually polymorphism, it's function overloading.
But it's trivial, count the arguments. Or change your API to pass a
table:
Create{path="foo/bar", section="top"}
This approach also makes it easy to have any argument optional.
David Dunham Utility Infielder GameHouse Studios
w: +1 206 926 5722 m: +1 206 769 2227 www.gamehouse.com
"TV--what a waste. You could be playing games, or reading a
book, for that matter." -- Greg Costikyan