my @x = ( 1 ,2 ,3, 4, ) ;This can be useful when you have things you want to add to or move around, not having to be sure to remove the last comma and add one if you move up the last element.
Compare this SQL.
SELECT foo , bar , blee , FROM quuz ;
That'll give you an error. In one sense, well, sure. On the other hand, it sucks because the same dynamic forces that happen as you program in Perl come forth as you develop SQL queries.
I suppose the solution is to put a kind of null into the last field so you can shuffle until the cows come home, but I'm still frustrated.
The same thing is true in JSON, which really sucks! I mean, it would be bad enough if it were just JavaScript, but it's not; we use JSON in a lot of places.
ReplyDeleteI had already been thinking of this before, but now your article has inspired me to make my Muldis D language (for object-relational databases) support Perl's trailing comma syntax, where before it disallowed this like SQL does. This update is part of version 0.142.0 of the spec that has been uploaded to CPAN an hour ago.
ReplyDeleteI've seen to use the following in JS:
ReplyDelete, item1
, item2
, item3
so you can cut and paste lines without worring by the last ','
Nice post