Function pointers/delegates default args were stealth removed?

Manu turkeyman at gmail.com
Mon Aug 27 05:14:18 PDT 2012


On 27 August 2012 14:08, Carl Sturtivant <sturtivant at gmail.com> wrote:

>
>> extern(C) void function( ref const(Vector2) v0, ref const(Vector2) v1,
>> ref const(Vector2) v2, ref const(Color) color = Color.white, BlendMode
>> blendMode = BlendMode.Disabled ) fillTriangle2D;
>>
>
> If function pointers could be called with fewer than the prototypical
> number of arguments, and the remaining arguments be always initialized to
> their .init defaults, you could perhaps make this sort of thing work
> without the default argument values by using struct defaults.
>
> How would that be deficient?
>

... no.
Color does not .init == Color.white. You're suggesting I define a new type,
obscuring the API, every time I want a non-.init default arg?
Also, I think it's correct that functions shouldn't be callable without
explicit parameters. Default args are carefully selected, and they are
always opt-in.
'v2' in this case shouldn't be allowed to default to [ NaN, NaN ] if I omit
it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120827/c1b43d65/attachment.html>


More information about the Digitalmars-d mailing list