lua-users home
lua-l archive

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


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"
		}
	},

	iphone =
	{
		plist =
		{
			CFBundleIconFile = "Icon.png",
			CFBundleIconFiles = {
				"Icon.png" ,
				"Icon@2x.png" ,
				"Icon-72.png" ,
				"Icon-Small-50.png" ,
				"Icon-Small.png" ,
				"Icon-Small@2x.png"
			},
			CFBundleURLTypes =
			{
				{
					CFBundleURLSchemes =
					{
						"fb1234567890", -- example scheme for facebook
						"coronasdkapp", -- example second scheme
					}
				}
			},
			UIBackgroundModes =
			{
				"audio",
			},
			UIApplicationExitsOnSuspend = false
		}
	},

	android =
	{
		versionCode = "3"
	},

	androidPermissions =
	{
		"android.permission.ACCESS_FINE_LOCATION",
		"android.permission.INTERNET"
	},

}



> Do you leave commas out of lists when you write normally?

Actually when I write lists, I'm not usually thinking/writing in
formal/proper English and I omit commas. I think you'll find this is
more common than you realize.

Shopping List:
milk
butter
eggs
flour
baking soda



> P.S. One thing I love about Lua over JavaScript is that Lua's grammar actually makes semicolons optional as opposed to JavaScript which tries to patch things up after the fact with rules for semicolon insertion.

I also really like optional semi-colons. I always see surprise and
delight from people when I tell them that semi-colons are optional in
Lua. They are even flabbergasted when you omit them for commands on
the same line:
x=1 y=2
I usually get a response like 'How did Lua pull that off?'
(I also never mention the parenthesis omission feature because the
restrictions are too complicated to explain in a  single sentence
which puts a damper on the elegance angle in this context.)



-Eric
-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/