go ahead... be a heretic | |
PerlMonks |
Re^10: Amicable divorceby LanX (Saint) |
on Jul 12, 2020 at 17:43 UTC ( [id://11119232]=note: print w/replies, xml ) | Need Help?? |
> Named arguments, default values, parameter checking are all syntactic sugar, which sure, is somewhat nice to have, but is no possible way essential. I remember a talk from Damian from YAPC 2011 or 2012 showing the benefits of porting to Perl 6. The thing that stuck the most was when he showed how his subs shrank 30-50% only by using function signatures with parameter checking. > Every time you go "I can do this using this little longer syntax" - you already disqualified it as a "long overdue must have feature". Sorry it's not a little longer syntax, and training new programmers in how best to unpack @_ is a PITA. But, what's your concern here? That the syntax won't work on older Perl-versions??? FWIW: It's possible to implement it with syntactic sugar in pure Perl without any XS, but the syntax would require at least one new sub args() which is called to unpack @_
When using Keyword::Simple this would also come without speed penalty, because args would be evaluated at compile time. Is that acceptable for you??? > This is something I had to write 2 months ago. I'm no Go-go-boy , no idea what that means. > But sure, let's talk about signatures and postfix-deref 🤮 I'm not fond about postfix-deref tho I'd avoid this emoji when criticizing other peoples work. But I'm a big fan of autobox which is backwards compatible. Something like $HoA{key}->push(1,2,3); is more readable than push @{$HoA{key}},1,2,3; , not only to beginners. Problem is that Autobox comes with a speed penalty, because ->push triggers a method lookup in a wrapper class for arrays (or undef scalars) A fast implementation would need to create Op-Codes for certain "special" methods like ->push or '->shift'. If the LHS is an array it would just execute the code for push() and 'shift()', etc without performance lost. Otherwise they would fall back to normal method lookup for objects. That's the way I would go for newer features:
PS: I'm using // nearly every day...
Cheers Rolf
In Section
Meditations
|
|