Please help me understand this function signature: std.stdio.File.byLine

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Jul 15 21:23:58 UTC 2021


On Thu, Jul 15, 2021 at 08:24:57PM +0000, Scotpip via Digitalmars-d-learn wrote:
[...]
> For starters, it's now clear to me that a strong understanding of
> Templates is essential to make much headway - that's why I got stuck
> here. They are dealt with towards the back of the books, but you
> really can't understand much of the library code without them. That's
> the first gap I'm going to fill.
[...]

My personal favorite approach to D template functions is to not think of
them as templates in the first place, but rather as functions with
*compile-time* parameters (in addition to the usual runtime parameters).
I.e., parameters that get baked in at compile-time. Since the parameters
are processed at compile-time, they can do a more than the usual runtime
parameters can, such as receiving types and aliases and other such
things that only exist at compile-time.  The function can then act on
these arguments at compile-time to adapt itself to the task thus
specified, without incurring the runtime overhead of a runtime check.


T

-- 
There are two ways to write error-free programs; only the third one works.


More information about the Digitalmars-d-learn mailing list