Why do we (I) need this? (small example)

downs default_357-line at yahoo.de
Thu Jan 3 12:10:51 PST 2008


I currently use the following code as part of dglut:
>
> glChecked("RenderToScreen", MatrixScope(init, renderScene(f), img2.With(WithFlag(GL_BLEND, true, { ... }))));
> 

With the proposed features, this could be rewritten as follows:
>
> glChecked("RenderToScreen") MatrixScope { init; renderScene(f); img2.With WithFlag(GL_BLEND, true) { ... } }
> // without trailing delegates
> glChecked("RenderToScreen", { MatrixScope({ init; renderScene(f); img2.With({ WithFlag(GL_BLEND, true, { ... }); }); }); });
>

Now if this looks better is a matter of taste (personally I think it does). But with the proposed extension,
the first would translate to four function-call levels of wrappers, while the second and third can be inlined completely.

I don't think it should be necessary to decide for user-defined abstractions OR speed, and since the delegate inlining issue
looks hard to fix, this seems to be the only way to use your own abstractions as well as take advantage of inlining.

 --downs



More information about the Digitalmars-d mailing list