4 ms·
> I always had to look up if a particular notation was dereferencing a pointer to an array or an array of pointers in perl. You should rephrase this because yo
by grondilu 12y ago
> I always had to look up if a particular notation was dereferencing a pointer to an array or an array of pointers in perl.
You should rephrase this because you can't de-reference an array. Plus a reference to an array is always a scalar so it always has the '$' sigil, thus it's not clear what you're talking about.
- kstrauser 12y agoThat is precisely the kind of minutia that made me abandon Perl the week I discovered Python. I think I'm a reasonably intelligent person, and Perl's cleverness was a source of fun for the first year or two. I eventually got tired of feeling like I had to prove my subject mastery every time I opened an editor.
- grondilu 12y agoFrankly, I've never understood people complaining about Perl's references. Me, when I first learnt about it, I felt in familiar territory, for it reminded me of C pointers. Hell, even the '->' notation was easy to remember since it's the same as in C. And as mentioned above, the sigil system of Perl makes it impossible to confuse a reference with the object it refers to (PS. except maybe for references to scalars, but those are arguably very rare).
- alayne 12y agoFor starters, Perl has five different kinds of references with different qualifying characters for each one. $scalarref = \$foo; $arrayref = \@ARGV; $hashref = \%ENV; $coderef = \&handler; $globref = \*foo;
- grondilu 12y agoPardon me but I see only one kind of reference here. The five references above differ only with the kind of object they refer to. The "qualifying characters" you're talking about do not qualify the reference, but the referenced object.
- byEngineer 12y agoCouldn't make it more complicated, huh?
- deleted 12y ago[deleted]
- grondilu 12y agoNo, this is not complicated. I have hard times believing people on HN are that dumb, so stop pretending.
- byEngineer 12y agoNo. I get it. I do understand. Maybe I should have said needlessly complex. Ie you can have keyless entry to a car and start the engine with a press of a button. Or -- instead -- you can search for a key in your pockets (put the bag in your hand on the ground first) insert it into the lock, turn the key and then pick up the bag, take the key and put it into the ignition, turn it and start the car. So you tell me the first solution is dumb and the other one is smart? I would say that exactly opposite is true.
- deleted 12y ago[deleted]
- kbenson 12y agoYou are combining two features of the language that don't really have anything to do with each other (references, and core type sigils), and conflating them in a way that's irrelevant, which is why you are getting some pushback on your critique. Perl uses sigils. You can think of them like inflection in spoken language. They provide hints as to what is being referred to, to help make intent clear. Perl uses references. In some respect, almost all languages use references, and it's just a matter of whether it's explicit or implicit. Perl makes it explicit, which means the programmer has to understand it early to make some things work (nested data structures). Other languages may have it as implicit, but that doesn't mean the programmer can ignore it, it just means they may be able to ignore it for a short while when first learning the language. Sooner or later they will encounter and have to deal with whether they are working with a copy of data or the original data. If they are lucky, this happens before it's a nasty bug.