www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2415] New: DMD allows void foo(int i, ); function definition

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2415

           Summary: DMD allows void foo(int i, ); function definition
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: 2korden gmail.com


void foo(int i, ) //< note the comma
{
}

void main()
{
        foo(1);
}

compiles and runs.


-- 
Oct 12 2008
next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2415





------- Comment #1 from business3 twistedpairgaming.com  2008-10-12 23:49
-------
I'm not sure but I think this might be intended in any place that accepts a
comma separated list to make it easier to maintain long multi-line lists. For
example, copy/pasting a bunch of entries from the start/middle of a list to the
end and you don't have to worry about adding a comma after the former last
element or removing the comma from the new last element. That's been my
assumption, as I've actually found it useful for just that reason.


-- 
Oct 12 2008
parent Don <nospam nospam.com.au> writes:
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=2415
 
 
 
 
 
 ------- Comment #1 from business3 twistedpairgaming.com  2008-10-12 23:49
-------
 I'm not sure but I think this might be intended in any place that accepts a
 comma separated list to make it easier to maintain long multi-line lists. For
 example, copy/pasting a bunch of entries from the start/middle of a list to the
 end and you don't have to worry about adding a comma after the former last
 element or removing the comma from the new last element. That's been my
 assumption, as I've actually found it useful for just that reason.

Is it documented anywhere?
Oct 13 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2415





------- Comment #2 from terranium yandex.ru  2008-10-13 03:47 -------
enum declaration has the same feature.


-- 
Oct 13 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2415





------- Comment #3 from samukha voliacable.com  2008-10-13 04:48 -------
But not array literals. I wish they also had this feature. It is useful for
compile time generated code.


-- 
Oct 13 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2415





------- Comment #4 from business3 twistedpairgaming.com  2008-10-13 14:45
-------
From the newsgroup (Don):
 
 I'm not sure but I think this might be intended in any place that accepts a
 comma separated list to make it easier to maintain long multi-line lists. For
 example, copy/pasting a bunch of entries from the start/middle of a list to the
 end and you don't have to worry about adding a comma after the former last
 element or removing the comma from the new last element. That's been my
 assumption, as I've actually found it useful for just that reason.

Is it documented anywhere?

For enums, and array and struct initializations: yes. For parameter and argument lists: not according to the grammars, however the inconsistency makes me wonder if (and hope) the "not allowed" ones were oversights. The following appear to be the same in both D1 docs and D2 docs: http://www.digitalmars.com/d/1.0/enum.html EnumMembers: EnumMember EnumMember , EnumMember , EnumMembers http://www.digitalmars.com/d/1.0/declaration.html ArrayMemberInitializations: ArrayMemberInitialization ArrayMemberInitialization , ArrayMemberInitialization , ArrayMemberInitializations StructMemberInitializers: StructMemberInitializer StructMemberInitializer , StructMemberInitializer , StructMemberInitializers ParameterList: Parameter Parameter , ParameterList Parameter ... ... DeclaratorIdentifierList: DeclaratorIdentifier DeclaratorIdentifier , DeclaratorIdentifierList http://www.digitalmars.com/d/1.0/template.html TemplateParameterList TemplateParameter TemplateParameter , TemplateParameterList TemplateArgumentList: TemplateArgument TemplateArgument , TemplateArgumentList http://www.digitalmars.com/d/1.0/expression.html NewExpression: NewArguments Type [ AssignExpression ] NewArguments Type ( ArgumentList ) NewArguments Type NewArguments ClassArguments BaseClasslistopt { DeclDefs } NewArguments: new ( ArgumentList ) new ( ) new ClassArguments: class ( ArgumentList ) class ( ) class ArrayLiteral: [ ArgumentList ] IndexExpression: PostfixExpression [ ArgumentList ] PostfixExpression: PrimaryExpression PostfixExpression . Identifier PostfixExpression . NewExpression PostfixExpression ++ PostfixExpression -- PostfixExpression ( ) PostfixExpression ( ArgumentList ) IndexExpression SliceExpression ArgumentList: AssignExpression AssignExpression , ArgumentList --
Oct 13 2008