lua-users home
lua-l archive

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


Personally I used to love camelCaseNaming.  However, more recently
someone gave a talk about ruby and asked the question which is easier
to read:

 LexHTMLToXML
 LexHtmlToXml
 lex_html_to_xml

I go for readability these days (aka I'm a fan of using underscores).

However, as most other people have said, it is better to stick to the
old adage: "When in Rome wear a toga" (aka use the conventions already
dictated by the API's you are integrating with).

Cheers,
-Brian

On Wed, Mar 30, 2011 at 11:12 AM, Henk Boom <henk@henk.ca> wrote:
> On 28 March 2011 15:16, Gaspard Bucher <gaspard@teti.ch> wrote:
>> Hi list !
>> For a long time, I have been able to stick with the conventions inherited
>> from ruby: PascalCase for classes, under_score for all the rest.
>> Now that I am working with Qt, I have a problem: all Qt methods are camel
>> case. After some time, my Lua code starts to look really weird:
>> instance:setHue(def.hue or 0.2)
>> instance:set_inlets(def.inlets)
>> setHue is a method used in a QWidget, set_inlets is used in a sub-class from
>> QWidget.
>> At this point, I have 3 options:
>> 1. rename Qt methods to use under_score (I subclass and rewrite methods
>> anyway).
>> 2. use camel case in the context of Qt and Qt sub-classes (but this means we
>> will see setInlet for NodeView and set_inlet for Node which could be
>> confusing).
>> 3. use camel case everywhere (more work but doable on the long run).
>> What is your advice ? Is there any "native" style for Lua ?
>
> Since I often mix C and Lua in my projects I follow the underscore
> convention to keep it uniform. The fact that lua is as neutral to this
> as possible gives you the freedom to match it to what you're embedding
> it in.
>
>    henk
>
>



-- 
Brian Maher >> Glory to God <<