function overloading with lua - LUA Scripting - CHDK Forum

function overloading with lua

  • 2 Replies
  • 6445 Views
function overloading with lua
« on: 04 / April / 2009, 23:33:51 »
Advertisements
in the lua libs i have a couple of functions which perform very similar functions but take different variables. (smartShoot and smartShootWithName)

in some languages, both functions could have the same name and the function would be called depending upon the passed variables. does lua provide for something like this?

*

Offline reyalp

  • ******
  • 14125
Re: function overloading with lua
« Reply #1 on: 06 / April / 2009, 16:29:43 »
no. Lua function can take varying arguments, so this wouldn't make sense.
Don't forget what the H stands for.

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: function overloading with lua
« Reply #2 on: 07 / April / 2009, 02:32:32 »
Well, the semantics are different but the result is quite similar...

I don't know if I am pointing you at what's already obvious, but ALL parameters are optional in Lua, and if you skip a parameter this parameter will get a value of nil.
See http://www.lua.org/pil/5.html

 

Related Topics


SimplePortal © 2008-2014, SimplePortal