All the Perl that's Practical to Extract and Report

Navigation

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Without JavaScript enabled, you might want to
use the classic discussion system instead. If you login, you can remember this preference.

Please Log In to Continue

There is another class of languages besides Perl, Java, and C++: statically-typed functional languages. In particular, ocaml [ocaml.org] hits a terseness/performance spot that is great for many applications in my opinion, including most current uses of C++.

Also, ocaml's option type is way better than perl's undef. We hates undef!

I think undef would be fantastic if Perl better supported three-value logic. Right now we have true or false. If Perl natively supported "true", "false" and "unknown", many problems could be made simpler.

I did allude to other paradigms (logic programming, to be specific), but I confess that I don't know much about OCaml.

My unhappiness with undef is that I can never remember whether my functions return undef or not, and what the behavior of the function is when given an undef arg, etc.. In the end, I always end up having to write comments.

Ocaml has a nice distinction between a type "foo" and a type "foo option" -- the latter can be undef, whereas the former is guaranteed to have a value:

Keep to a strict convention and it's easier to remember. Don't return undef or a false value when you mean false, just return. A bare return will return undef in scalar context and an empty list in list context. By keeping to this convention, you can simplify your code. If you're returning from a ternary operator, use parens:

return;# orreturn $val ? defined $val : ();

Personally, I usually return as soon as I know a function will fail and I don't get to the ternary operator too often (though that's n