Re: Initializing default parameters from prior parameter

2019-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 25 May 2019 at 16:25:53 UTC, Robert M. Münch wrote: myfunc(myObj o, myType m = o.getmyTypeValue()){...} I'd probably just write it myType m = null) { if(m is null) m = o.getmyTypeValue; } or myfunc(myObj o) { /* use the default */ } myfunc(myObj o, myType m) { /* use the

Initializing default parameters from prior parameter

2019-05-25 Thread Robert M. Münch via Digitalmars-d-learn
Wouldn't it make sense if this would be possible? It would shorten the function interface in cases, where no specialization of m is needed but still makes it possible to override. myfunc(myObj o, myType m = o.getmyTypeValue()){...} The compiler complains, that o is an undefined identifier.