History of trailing comma in programming language grammars

后端 未结 4 1505
执念已碎
执念已碎 2020-11-30 10:16

Many programming languages allow trailing commas in their grammar following the last item in a list. Supposedly this was done to simplify automatic code generation, which is

4条回答
  •  温柔的废话
    2020-11-30 10:33

    I just found out that a g77 Fortran compiler has the -fugly-comma Ugly Null Arguments flag, though it's a bit different (and as the name implies, rather ugly).

    The -fugly-comma option enables use of a single trailing comma to mean “pass an extra trailing null argument” in a list of actual arguments to an external procedure, and use of an empty list of arguments to such a procedure to mean “pass a single null argument”.

    For example, CALL FOO(,) means “pass two null arguments”, rather than “pass one null argument”. Also, CALL BAR() means “pass one null argument”.

    I'm not sure which version of the language this first appeared in, though.

提交回复
热议问题