Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Typeless programming is great most of the time, but it can be a burning irritation as well. When the variables you are working with are malleable, like scalars, then you really don't care because of DWIM. When these scalars are actually object references, things can go all dark and blurry.
my $bork = Bork->new(); my $x = $bork->bork()->bork();
Quick quiz: What type of thing is $x anyway? What methods can you call on it? One of the great things about C++ and other strongly typed languages is that you have to prepare a holder for the thing you are requesting. It would be a lot more like:
Bork bork = new Bork(); Chef x = bork->bork()->bork();
No ambiguity there. Either you get a 'Chef', or you get a compile-time error.

With the coming Apocalypse, I only hope that there will be some sort of optional type checking mechanism that can backpropagate the request into the function itself, just like wantarray. Here's an idea:
my Bork:$bork = Bork->new(); my Chef:$x = $bork->bork()->bork();
Maybe the bork method would be able to return a number of different things, including a 'Chef', based on some sort of if (wanta('Chef')) { ... } type check.

Sure, you can say name your variables properly according to type, perhaps using the so-called Hungarian notation, but this can get quickly out of hand. You can also check the return types explicitly in some sort of paranoid gesture, but these are run-time errors and not compile time, which is really tough to test in comparison.

Strict type checking, please, but only on request.

In reply to Re: Griping about Typing by tadman
in thread Griping about Typing by Ovid

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (4)
    As of 2021-01-16 17:50 GMT
    Find Nodes?
      Voting Booth?