<div>See [1][2] for related thread introducing extern(objective C)</div><div><br></div><div>A)</div><div>The syntax proposed in [2] transforms:</div><div><div>-(void) insertItemWithObjectValue: (NSString *) path atGreen:(NSInteger) anInt;</div>
<div><div>[obj insertItemWithObjectValue:val atGreen:idx ];</div><div><br></div><div>into:</div></div><div>void insertItem(NSString* object, NSInteger anInt) [insertItemWithObjectValue:atGreen:];</div><div><div><div></div>
</div><div></div></div><div>obj.insertItem(val, idx);</div><div><br></div><div>B)</div><div>I don't see how it handles this case:</div><div><div>[obj insertItemWithObjectValue:val atGreen:idx ];</div></div><div><div>[obj insertItemWithObjectValue:val atRed:idx ];</div>
</div><div><div><br></div><div>obj.insertItem(val, idx); //atGreen or atRed ?</div></div><div><br></div><div>C)</div><div>The fact that one needs to come up with a new name insertItem is not good (as done in [2] ). And if we reuse the name:</div>
<div><div>'void insertItemWithObjectValue(NSString* object, NSInteger anInt) [insertItemWithObjectValue: atGreen:];'</div><div>Then it's not DRY.</div><div><br></div></div><div>D)</div><div>the variable list is separated from the argument name list; this makes it less readable with more arguments.</div>
<div><br></div><div>E)</div><div>the only benefit of objective C's syntax (making it clear at call site what is the argument description) is lost.</div><div><br></div><div>----</div><div>F)</div><div><b>I'd like to propose instead the following syntax:</b></div>
<div><div><div>void insertItemWithObjectValue(NSString* object, NSInteger atGreen:);</div></div></div><div><div>void insertItemWithObjectValue(NSString* object, NSInteger atRed:);</div></div><div><div><div>obj. insertItemWithObjectValue(object, atGreen: idx);</div>
</div></div><div><div>obj. insertItemWithObjectValue(object, atRed: idx);</div></div></div><div><br></div><div>Advantages:</div><div>* unambiguous (cf B)</div><div>* no need to come up with new name or repeat it (cf C)</div>
<div>* no need to separate variables from their submethod name (cf D)</div><div>* more D-like, yet reminiscent of objective C argument description at call site (without those fugly objective C brackets)</div><div><br></div>
<div>G)</div><div>Finally, this would be compatible with <b>named argument parameter syntax</b> that I and others have been pushing for, if they are ever introduced in D. There were many proposals but I'd like to propose this:</div>
<div><br></div><div>void fun1(int a, int b, int c:, int d:);</div><div>obj.fun1(1, 2, c:3, d:4); </div><div><div><br></div><div>void fun2(int a, int b, int c:3, int d:4);</div><div><div>obj.fun2(1, 2); => fun2(1,2,c:3,d:4)</div>
</div></div><div><div><div>obj.fun2(1, 2,d:0); => fun2(1,2,c:3,d:0)</div></div></div><div><div><div>obj.fun2(1, 2,d:0, c:6); => fun2(1,2,c:6,d:4)</div></div></div><div><br></div><div>'d:' indicates that d argument is mandatory at call site and name d is part of the API.</div>
<div><div>'d:4' indicates that d argument is optional at call site and name d is part of the API; </div></div><div>optional named arguments must appear after all other arguments, and can be reordered / omitted. </div>
<div><br></div><div><div>----</div><div>[1] </div><div>for <a href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CC8QFjAA&url=http%3A%2F%2Fforum.dlang.org%2Fthread%2Fkq7li9%242j9v%241%40digitalmars.com&ei=OMbLUae3LLD0iwLl04CACw&usg=AFQjCNHScB2VEdtBBSnkFKum21Gz3sIUDw&sig2=1ToqlVmg6nDWMMpxPg5Lcg&bvm=bv.48572450,d.cGE">https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CC8QFjAA&url=http%3A%2F%2Fforum.dlang.org%2Fthread%2Fkq7li9%242j9v%241%40digitalmars.com&ei=OMbLUae3LLD0iwLl04CACw&usg=AFQjCNHScB2VEdtBBSnkFKum21Gz3sIUDw&sig2=1ToqlVmg6nDWMMpxPg5Lcg&bvm=bv.48572450,d.cGE</a></div>
<div><br></div></div><div>[2]</div><div><a href="http://michelf.ca/projects/d-objc/syntax/#protocols">http://michelf.ca/projects/d-objc/syntax/#protocols</a></div>