Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Classes in Gideros - Page 2 — Gideros Forum

Classes in Gideros

2»

Comments

  • AhBadianeAhBadiane Member
    edited March 2013
    @keszegh, for local function, simply : local function ... end ?
    AhBadiane
  • thanks @ar2rsawseen, it's only me using my own code, so scopes should not be too much of a problem anyway, i just try to follow best practices. your idea with _... seems best in this case.

    @AhBadiane ... indeed, if you define a local function B inside a function Cl:B of the class Cl, then it is visible only inside THAT function Cl:B of the class and is not visible in OTHER functions (e.g. Cl:C) of the class. although you are right that it is not visible outside of the class, so it is a half-solution, but it is not what i needed.
  • ar2rsawseenar2rsawseen Maintainer
    @keszegh actually @AhBadiane maybe on to something.

    That's not exactly a class property, but if you define
    local function somefunc()
    end
    inside the lua file where your class is, but outside of any function scope, this function seems to be visible only to all methods inside this file and not outside it.

    Need to check more on memory management in this cases, but it could also be a feasible solution.
  • Just remenber it must be defined earlier in the file than wherever itis used.
  • keszeghkeszegh Member
    edited March 2013
    @AhBadiane and @ar2rsawseen,
    you maybe right indeed, then we have to add manually self to its parameters. and of course it is not as nice as having e.g.
    local MyClass:MyLocalFunction(...)

    i wonder if it would make sense to add this to the class system of gideros, or it is not a good or doable idea. I don't need it desperately though, just wondering.

    btw if i put a core class and 2 inherited classes in one lua file, then this method does not hide from each other the local functions of the inherited classes. moreover i cannot define a local function with the same name for each of them this way. of course if i split all up to 3 files, then it is a workaround.
Sign In or Register to comment.