Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> One is the shifting sigils, accessing @x with $x[3] instead of the logical @x[3]

$x[3] is perfectly logical when you think of the sigil as typing the value and not the variable. They're basically one-char cast/convert operators. Auto-flattening is less defensible. It was easier for me to intuit because @foo looks like a list splice in lisp and MOO code, so anywhere you see @foo in args, you can assume it's spliced in ... but then there's prototypes that change that. Yeah.

These just made Perl weird but they didn't reduce its power or expressivity. It was things like only having a single scalar type, or not even having named args without crazy shit like Devel::Declare that always had me looking for greener pastures.

Nowadays I spend most of my time writing PHP and TS. PHP is reasonably pleasant since the 8.x days, but I wish it had generics. And talk about having to crawl out from under a pile of bad legacy decisions...



> > One is the shifting sigils, accessing @x with $x[3] instead of the logical @x[3]

> $x[3] is perfectly logical when you think of the sigil as typing the value and not the variable.

Unfortunately, that doesn't match the intuition of most programmers. It's more natural to think of the scalar variable as having the full name "$x" and the list variable having the full name "@x", since IIRC both can exist at the same time. Having "$x[3]" access the "@x" variable, when a "$x" variable already exists in the same place at the same time, is just plain confusing. Add to that the very similar looking "$x->[3]" syntax, which accesses the "$x" variable and not the "@x" variable (unless you made "$x" a reference to "@x"), and it becomes even less obvious.


Perl has lots of weirdness, that's not surprising to anyone. It's still quite consistent in how it interprets sigils though, even if it's irritating (I don't find stuff like "@{$foo->{bar}}" all that beautiful either). It's not like there was some universal norm around sigils, programmers intuition is informed by the languages they actually use.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: