See [1][2] for related thread introducing extern(objective C)
A)
The syntax proposed in [2] transforms:
-(void) insertItemWithObjectValue: (NSString *) path atGreen:(NSInteger) anInt;
[obj insertItemWithObjectValue:val atGreen:idx ];
into:
void insertItem(NSString* object, NSInteger anInt) [insertItemWithObjectValue:atGreen:];
obj.insertItem(val, idx);
B)
I don't see how it handles this case:
[obj insertItemWithObjectValue:val atGreen:idx ];
[obj insertItemWithObjectValue:val atRed:idx ];
obj.insertItem(val, idx); //atGreen or atRed ?
C)
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:
'void insertItemWithObjectValue(NSString* object, NSInteger anInt) [insertItemWithObjectValue: atGreen:];'
Then it's not DRY.
D)
the variable list is separated from the argument name list; this makes it less readable with more arguments.
E)
the only benefit of objective C's syntax (making it clear at call site what is the argument description) is lost.
----
F)
I'd like to propose instead the following syntax:
void insertItemWithObjectValue(NSString* object, NSInteger atGreen:);
void insertItemWithObjectValue(NSString* object, NSInteger atRed:);
obj. insertItemWithObjectValue(object, atGreen: idx);
obj. insertItemWithObjectValue(object, atRed: idx);
Advantages:
* unambiguous (cf B)
* no need to come up with new name or repeat it (cf C)
* no need to separate variables from their submethod name (cf D)
* more D-like, yet reminiscent of objective C argument description at call site (without those fugly objective C brackets)
G)
Finally, this would be compatible with named argument parameter syntax 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:
void fun1(int a, int b, int c:, int d:);
obj.fun1(1, 2, c:3, d:4);
void fun2(int a, int b, int c:3, int d:4);
obj.fun2(1, 2); => fun2(1,2,c:3,d:4)
obj.fun2(1, 2,d:0); => fun2(1,2,c:3,d:0)
obj.fun2(1, 2,d:0, c:6); => fun2(1,2,c:6,d:4)
'd:' indicates that d argument is mandatory at call site and name d is part of the API.
'd:4' indicates that d argument is optional at call site and name d is part of the API;
optional named arguments must appear after all other arguments, and can be reordered / omitted.
[2]