Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
what's your lua convention? — Gideros Forum

what's your lua convention?

bysregbysreg Member
edited October 2012 in General questions
hi,

Just want to know what convention do you use for lua or for gideros
I myself has googled for any convention for lua, and been using upper camel case for class name and class filename. and do you use package (http://www.lua.org/pil/15.html)?

and also, we use _ prefix for variable that is meant for private class variable

Comments

  • atilimatilim Maintainer
    edited October 2012
    I follow the same convention as you. And although It's not a coding convention, I always use lowercase for filenames.
  • bysregbysreg Member
    edited October 2012
    @atilim
    i'm curious of how you avoid class name conflict?
  • atilimatilim Maintainer
    Maybe you can check before creating it:
    if MySprite then
    	error("MySprite is already defined")
    else
    	MySprite = Core.class(Sprite)
    end
     
    -- or more compactly
     
    MySprite = MySprite and error("MySprite is already defined") or Core.class(Sprite)
  • if for example, i want to have class name Shape but the functionality is different from that of the gideros Shape class(though it can happen to every other class, not just gideros class), how can i differentiate it ?

    like for example, in java this issue is solved with package
  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    @bysreg well theoretically you can namespace it, but I don't know if it would give you much
    --Create namespace for class
    My = {}
     
    My.Shape = Core.class()
     
    function My.Shape:init()
    end
     
    --etc
    it's probably just better to select another class name
Sign In or Register to comment.