Re: Mysteries of the Underscore

2018-12-24 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 24, 2018 at 04:53:57PM +, Neia Neutuladh via Digitalmars-d-learn wrote: > On Mon, 24 Dec 2018 08:16:01 -0800, H. S. Teoh wrote: > > Rather, it's *conventionally* taken to mean "unused". The language > > actually does not treat it in any special way apart from "normal" > >

Re: Mysteries of the Underscore

2018-12-24 Thread Neia Neutuladh via Digitalmars-d-learn
On Mon, 24 Dec 2018 08:16:01 -0800, H. S. Teoh wrote: > Rather, it's *conventionally* taken to mean "unused". The language > actually does not treat it in any special way apart from "normal" > identifiers. It's perfectly valid (though probably not recommended!) to > declare functions or

Re: Mysteries of the Underscore

2018-12-24 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 24, 2018 at 02:45:24PM +, bauss via Digitalmars-d-learn wrote: [...] > The underscore does nothing and it's just an identifier. > > Really it just means "unused". It's frequently used in loops to. Rather, it's *conventionally* taken to mean "unused". The language actually does

Re: Mysteries of the Underscore

2018-12-24 Thread bauss via Digitalmars-d-learn
On Monday, 24 December 2018 at 11:18:44 UTC, Ron Tarrant wrote: I found a mention that in the definition of a delegate, a function parameter and its type could be replaced by an underscore: myTestRig.addOnDestroy(delegate void(Widget w) { quitApp(); } ); became:

Re: Mysteries of the Underscore

2018-12-24 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 24 December 2018 at 11:30:31 UTC, Johan Engelen wrote: The underscore is just an identifier but nothing special, it could be any valid identifier like "ldkhfksdkdsg". -Johan Thanks, Johan. In a way, I was hoping it was some kind of underscore magic. Now my brain hurts.

Re: Mysteries of the Underscore

2018-12-24 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 24 December 2018 at 11:18:44 UTC, Ron Tarrant wrote: I found a mention that in the definition of a delegate, a function parameter and its type could be replaced by an underscore: myTestRig.addOnDestroy(delegate void(Widget w) { quitApp(); } ); became:

Mysteries of the Underscore

2018-12-24 Thread Ron Tarrant via Digitalmars-d-learn
I found a mention that in the definition of a delegate, a function parameter and its type could be replaced by an underscore: myTestRig.addOnDestroy(delegate void(Widget w) { quitApp(); } ); became: myTestRig.addOnDestroy(delegate void(_) { quitApp(); } ); I was trying to find some further