Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • There is another class of languages besides Perl, Java, and C++: statically-typed functional languages. In particular, ocaml [] 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:

        let succ_int i = i + 1;;
        let succ_int_option o = match o with
        | None -> 0
        | Some i -> i + 1;;
        • 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:

          # or
          return $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