Setting struct as default parameter of a function using struct literal?

H. S. Teoh hsteoh at qfbox.info
Mon Sep 11 23:47:33 UTC 2023


On Mon, Sep 11, 2023 at 10:39:00PM +0000, Salih Dincer via Digitalmars-d-learn wrote:
> On Monday, 11 September 2023 at 22:13:25 UTC, H. S. Teoh wrote:
> > 
> > Because sometimes I want a specific type.
> > 
> 
> it's possible...
> 
> ```d
> alias ST = Options;
> void specificType(ST option = ST())
[...]

This is missing the point.  The point is that I don't want to have to
type `Options` or `ST` twice.  Since the type of the parameter is
already known, the compiler does not need me to repeat the type name. It
already knows enough to figure it out on its own.  "Don't Repeat
Yourself" (DRY).


T

-- 
"Holy war is an oxymoron." -- Lazarus Long


More information about the Digitalmars-d-learn mailing list