3 ms·
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
by mfontani 6y ago
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.
- rjeli 6y agoAs 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.
- joshuamorton 6y agoPython 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.