Is returning void functions inside void functions a feature or an artifact?
H. S. Teoh
hsteoh at quickfur.ath.cx
Mon Aug 2 21:58:07 UTC 2021
On Mon, Aug 02, 2021 at 04:42:14PM +0000, Rekel via Digitalmars-d-learn wrote:
[...]
> Also slightly off topic, but when would one use an alias instead of a
> function/delegate? I haven't used aliases before.
When you want a compile-time binding that could potentially elide the
indirect function call to a delegate.
// This generates a specialized template instance with
// `callback` bound to the passed-in compile-time argument, for
// each call to `myFunc`.
auto myFunc(alias callback)(...) { ... }
// This is a single common function that receives an opaque
// runtime delegate and binds it at runtime.
auto myFunc(int delegate(...) callback, ...) { ... }
T
--
An elephant: A mouse built to government specifications. -- Robert Heinlein
More information about the Digitalmars-d-learn
mailing list