On Thu, Nov 17, 2022 at 12:49:29PM +0000, Paul "LeoNerd" Evans wrote: > (Replying to an old thread with a new subject line - hope that's OK > everyone.) > > On Thu, 28 Nov 2019 17:06:21 +0000 > Dave Mitchell <davem@iabyn.com> wrote: > > > =head2 Defined-or > > > > in [perl #132444], Ovid suggested > > > > sub f($x //= expr) { ... } > > > > which is like > > > > sub f($x = expr) { ... } > > > > Except that it uses the default expression if the argument is undef as > > well as if it is missing. > > I'm verymuch liking the look of this one. I'd already have a bunch of > places to use it right now if it existed. > > It seems to me quite simple to implement, too. Currently OP_ARGDEFELEM > doesn't make use of its private flags, so we could add a flag to make > it have this behaviour. > > > Presumably we should also have ||= . > > I'm less keen on this as an idea, but it'd be so seasy to add while I'm > there looking at `//=` I *could* be talked into adding it while I'm > working in the area. > > > I think I would like to have a look at implementing that sometime in > the next couple of weeks (as I'd like to bring it into some related > parts of Object::Pad and the feature-class branch). I'm happy for you to proceed. Obviously I think the proposed syntax is a a good idea, since I proposed it(!) (having first stolen it), so I guess it would be be good to get feedback from others first. I too am less bothered about the ||= variant, but I suggested it because it should be easy to implement while implementing //=, and so we might as well, for completeness. -- "Do not dabble in paradox, Edward, it puts you in danger of fortuitous wit." -- Lady Croom, "Arcadia"Thread Previous | Thread Next