Re:Perl 7 is going to be Perl 5.32, mostly
by mfontani on Wednesday June 24, 2020 @06:09PM
(#23634425)
Right, which I sorta kinda get why coming from C - a *something is the thing pointed to by that something.
How is that more understandable than @ vs \@ without knowing the language? My guess is it isn't.
Re:Perl 7 is going to be Perl 5.32, mostly
by joshuamorton on Thursday June 25, 2020 @03:02AM
(#23637676)
Python is "relatively" consistent about * and being used to expand or contract arrays and dicts, respectively.
a, *, b = [1,2,3,4]
def foo(*args):
bar(*[1,2,3])
all do "what you'd expect" from the single concept that "* is sort of pattern-matchy for an array".But the more important bit is just that you don't have to prefix variables with @ and $. Python is optimized for writing code that acts on variables, while perl is optimized for code that acts on strings. While strings are certainly a common data type, most code isn't modifying strings directly. So optimizing for that case doesn't make a lot of sense.
As someone who learned python first - the idea that `myfn(@xs)` would call `myfn(1,2,3)` is... unnerving. Implicitly splicing in arguments makes me wonder what other kind of syntactic oddities are going over my head in my code.
With an asterisk: method(*array)