lua-users home
lua-l archive

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




On Mon, Mar 5, 2012 at 9:07 AM, Eric Wing <ewmailing@gmail.com> wrote:
I'm going to stick up for Greg and agree with him on both these points:
- Commas are generally the more common case
- Consistency is better than compromise (i.e. applying only to
associative arrays only vs. arrays is a bad idea). (I would say this
compromise would not be worth doing at all.)

As an aside, I never cared much for the current inconsistency in the
rules of omitting parenthesis.

-- Valid
print "foo"
print { }

-- Error
print 2
foo={}; print foo



Back to commas, this is an example of a Corona SDK build.settings
file. The most common bug users run into with this is forgetting a
comma somewhere. And it *is* an annoyance.

settings =
{
       orientation =
       {
               default = "portrait",
               supported =
               {
                       "portrait", "portraitUpsideDown", "landscapeRight", "landscapeLeft"
               }
       },
[...]

I think if you really want to be nice to your users, let them write these kinds of settings in a pure data representation language such as yaml. IMHO, this is easier to read:

settings = yaml.load [[
orientation:
  default: portrait
  supported:
  - portrait
  - portraitUpsideDown
  - landscapeRight
  - landscapeLeft
iphone:
  plist:
    UIApplicationExitsOnSuspend: false
    CFBundleIconFile: Icon.png
    UIBackgroundModes:
    - audio
    CFBundleIconFiles:
    - Icon.png
    - Icon@2x.png
    - Icon-72.png
    - Icon-Small-50.png
    - Icon-Small.png
    - Icon-Small@2x.png
    CFBundleURLTypes:
    - CFBundleURLSchemes:
      - fb1234567890
      - coronasdkapp
androidPermissions:
- android.permission.ACCESS_FINE_LOCATION
- android.permission.INTERNET
android:
  versionCode: '3'
]]
--

                                                               Gaspard