3 ms·
Where were you when I was learning Perl? That was the best description of context I've ever seen. Context was one of those subjects where it's a little tricky
by jrumbut 3y ago
Where were you when I was learning Perl? That was the best description of context I've ever seen.
Context was one of those subjects where it's a little tricky but the way it was explained to me made it a complete nightmare to understand.
- uhtred 3y agoI picked up perl about 18 months ago and I never really found context hard to understand at all. Not trying to boast- just not really sure what people find hard about it.
- jrumbut 3y agoThe first thing is that it's a little like pointers where it's not too hard but there are a lot of explanations of it that create mystification rather than knowledge. Stuff like this: https://www.perlmonks.org/?node_id=738558 https://www.perlmonks.org/?node_id=738558 > There is a way for a user-defined function to have its arguments in a scalar context, but that's seldom used, often discouraged, and outside the scope of this tutorial. Most of the time, subs' arguments are in list context. > Perl's built-ins don't follow this rule at all. Example 10 does not do what's intended. If that's your first introduction to context you may find it confusing. From another one I dug up (might have been bot generated, just thought it was funny): Perl has a concept called context. Context means context, and there are the following two contexts. The second thing, and this may have been more true in the days of yore when I was learning Perl is that there wasn't much consistency in how context was used. Combined with refs, this creates some painful mental overhead when working with multiple libraries in a project. Do I pass credentials as a list, a reference to a list, a specially formatted string, etc? It's not the end of the world but it adds up.