On 28 August 2012 00:11, Walter Bright <newshound2@digitalmars.com> wrote:
On 8/27/2012 3:32 AM, Manu wrote:
Almost all my API's are dynamically bound to foreign code, eg:

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;

These can all be handled in a straightforward (but admittedly wordy) method of wrapping the call to the function pointer in an overloaded function.

They can, see my prev post.

It's less readable, less maintainable, more obscure to those reading the code... the language had an awesome feature that addressed it directly.
When mixins get involved, readability, syntax highlighting, and other basic IDE services all go out the window.

Perhaps the most important one that I forgot; debugging becomes VERY annoying. Try stepping into an engine API when it's wrapped up with magic... F10 (jumps to a rubbish API file, cursor disappears, stub code doesn't actually exist). Continue pressing F10 for a while until it eventually finds it's way into the function pointer. Repeat when leaving the function >_< .. Again, __forceinline would address this.

I understand that you've probably got so many of these, it's drudgery to make the edits.

It would be annoying.

Question: are the default values all of the form T.init? I.e. is Color.white == Color.init?

No, I don't think so. Color inits to black. Many enums also have an Unknown state. and float init's to NaN for some crazy reason ;)