4 ms·
One thing I like about the sigils is that they make bad ideas hard to type. Want to pass me a hashtable of lambdas that return arrays of alternating functions
by hedora 5y ago
One thing I like about the sigils is that they make bad ideas hard to type.
Want to pass me a hashtable of lambdas that return arrays of alternating functions and regexps?
Go ahead. Show me how to invoke it. I'm waitng.
Python (which has all of the type safety and expressivity of perl) allows such abominations to hide behind clean looking syntax.
Sigils also improve readability. Bad Perl looks like serial port noise. Bad Python looks like good python.
(In Python's defense, it has a nice ffi.)
- leadingthenet 5y ago> Bad Python looks like good python. Never used Perl, so I can't really make an honest comparison. I do use Python at work, though, and I can assure you that is FAR from being true. In fact, I think this is so untrue that I urge you to check out essentially any code written in academia (especially projects involving numeric computation and data science). If you come back and make that same statement with a straight face, I'll eat my hat.
- hedora 5y agoI meant superficially. I could write a script that computes histograms over the frequency of the characters in its input, and use the output to judge perl code quality. In Python, that heuristic wouldn't work nearly as well.
- collyw 5y agoI have had colleagues (in academia) asking me to correct their unindented (or very badly indented code) in Perl. You couldn't actually do that ion Python.
- leadingthenet 5y ago> You couldn't actually do that in Python ...and people endlessly complain about it to this day.
- Ultimatt 5y agohttps://metacpan.org/pod/Perl::Tidy https://metacpan.org/pod/Perl::Tidy is your friend. Think Black from Python land but far more powerful.
- SideburnsOfDoom 5y ago> arrays of alternating functions and regexps many languages will allow you to succinctly express the concept of "the type of this element is a or b" e.g. typescript: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types https://www.typescriptlang.org/docs/handbook/2/everyday-type... Rust: https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html F# : https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/discriminated-unions https://docs.microsoft.com/en-us/dotnet/fsharp/language-refe... IDK, allowing that kind of type to be declared seems like a good thing to me? Those links have good examples of where it's useful. You'd need a good reason to use actually "function or regexp" in actual code though.
- bmn__ 5y agoYou have misunderstood GP. Alternating functions and regexps looks like this: [\&some_function, qr/some_regex/, \&another_function, qr/another_regex/] This is distinct from the idea of sum types.
- SideburnsOfDoom 5y agoOh, I get that their example said _alternating_ function and regex. If that's the real requirement then they shouldn't be _alternating_ in the list at all, there should be a list of (function, regex) tuples. We don't need an example of tuples, they're even more widespread than sum types / unions / enums. So the design as stated is very contrived, to the point where it doesn't make sense, but existing constructs can be used to make sense of it with a change one way or the other.
- hedora 5y agoSum types are great, but neither perl nor python let you statically check that they're being used properly.