Well, I'm not sure whether it's called Hungarian notation or not, but in BASIC for example, a string variable name is prefixed with a $ character, integers start with % and floating point numbers have no prefix.

That way, you can have 3 different variables called $x, %x and x and know what type of value they can contain (even though "x" tells you little else).

Trying to give a value in the wrong format, such as adding 0.5 to an integer, would cause a "type mismatch" error.

Okay, so maybe that restriction does force you to do unecessary conversions at times, but those prefixes do make it easier to debug unfamiliar code.

It also makes it more obvious what type of value a particular subroutine is expecting to have passed to it if you want to reuse it elsewhere.

I'm sure I can find some way to make it clearer what type of value my variables are intended to be used with. I was just hoping there was some way to have that checked every once in a while during development.

There have been plenty of good suggestions given to help anyway. :o)


In reply to Re: Re: Re: Re: Re: Re: Using "my" suppresses "Name used only once" warning? by Wysardry
in thread Using "my" suppresses "Name used only once" warning? by Wysardry

Title:
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, details, 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, summary, 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.