6 ms·
I know it’s not a popular opinion, but one thing I love about Perl and wished more languages adopted was the way how variables and functions could be prefixed b
by hnlmorg 6y ago
I know it’s not a popular opinion, but one thing I love about Perl and wished more languages adopted was the way how variables and functions could be prefixed by a special character (‘$’ for scalars, ‘%’ for hashes, ‘@‘ for arrays and ‘&’ for functions, though the latter was optional). Perl had a lot of properties that made it look a lot like executable line noise but those prefixes did help with readability in a way that a lot of more readable languages lack.
In the case of Go and the example you’ve given, if ‘W’ were a function then the code should read like this:
a, b = w() < x, y > (z)
- Jtsummers 6y agoIn the example, we can't tell if w is a generic function or not (by looking at this line of code). Remove the spaces, as would be more conventional: w<x,y>(z) Is this two expressions on one line or one expression with two type parameters? Possible groupings: (w<x,y>)(z) // w is a generic function (w<x),(y>(z)) // two comparisons
- blandflakes 6y agoThe parens look like "helping ambiguous syntax" rather than "should read like this" here - if z is an argument to w, there was already a set of parens signifying the function call.