Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8622

Re: in praise of [loosey goosey] type checking)

Date 2011-10-07 12:20 +0100
From RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: in praise of [loosey goosey] type checking)
References <noiq87l3l9umnl3a74u5jd2c0pnlq21dat@4ax.com> <4e8ed97f$0$2921$fa0fcedb@news.zen.co.uk>
Message-ID <4e8ee082$0$2553$da0feed9@news.zen.co.uk> (permalink)
Organization Zen Internet

Show all headers | View raw


On 07/10/2011 11:50, RedGrittyBrick wrote:
> On 06/10/2011 07:33, Roedy Green wrote:
>> I changed the result of a widely used method from boolean to int. The
>> neat thing was the compiler (actually the Intellij syntax checker)
>> made sure I fixed up every invocation of that method. It would not let
>> me forget even one.
>>
>> Imagine a language with loosey goosey type checking where it was
>> entirely up to you entirely to ensure all the invocations were
>> corrected. You could never be sure.
>
> The problem might not arise. Depending on which language you mean and
> how you apply your knowledge of the language to the intended use of the
> method.
>
> For example, in Perl, if I changed a method so that it returned an
> integer instead of a boolean I would do so in such a way that any
> existing code calling that method could continue to function unchanged.
> Perl can quite happily treat any integer as a boolean, I would just have
> to ensure that I return an integer value that will be treated as (say)
> false under circumstances where the original method would have been
> expected to return false.

To illustrate:

Let's say I have an object "store" and I have a method "contains()" that 
takes an argument and returns boolean telling us if the store contains a 
matching element. I might use it thusly in a zillion places

     if ($store.contains($APPLE)) {
       $store.sell($APPLE);
     } else {
       die "Out of $APPLE!";
     }

Now lets say I change contains() to return a count instead of a boolean.

My zillions of places treating the return value as boolean still work 
unchanged. Hurrah for loosey goosey!

-- 
RGB

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

in praise of type checking Roedy Green <see_website@mindprod.com.invalid> - 2011-10-05 23:33 -0700
  Re: in praise of type checking Lew <lewbloch@gmail.com> - 2011-10-06 06:43 -0700
    Re: in praise of type checking Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-06 09:52 -0700
    Re: in praise of type checking Roedy Green <see_website@mindprod.com.invalid> - 2011-10-07 12:43 -0700
      Re: in praise of type checking Gene Wirchenko <genew@ocis.net> - 2011-10-07 14:57 -0700
      Re: in praise of type checking Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-07 20:18 -0400
  Re: in praise of type checking Robert Klemme <shortcutter@googlemail.com> - 2011-10-06 22:31 +0200
    Re: in praise of type checking Roedy Green <see_website@mindprod.com.invalid> - 2011-10-07 12:36 -0700
      Re: in praise of type checking Robert Klemme <shortcutter@googlemail.com> - 2011-10-08 16:05 +0200
        Re: in praise of type checking Lew <lewbloch@gmail.com> - 2011-10-08 09:35 -0700
          Re: in praise of type checking Robert Klemme <shortcutter@googlemail.com> - 2011-10-11 07:48 +0200
            Re: in praise of type checking Gene Wirchenko <genew@ocis.net> - 2011-10-11 13:04 -0700
            Re: in praise of type checking Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-10-11 17:52 -0300
              Re: in praise of type checking Patricia Shanahan <pats@acm.org> - 2011-10-12 01:49 +0100
                Re: in praise of type checking Gene Wirchenko <genew@ocis.net> - 2011-10-11 19:12 -0700
            Re: in praise of type checking Lew <lewbloch@gmail.com> - 2011-10-11 19:10 -0700
  Re: in praise of type checking Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-06 20:29 -0400
    Re: in praise of type checking Robert Klemme <shortcutter@googlemail.com> - 2011-10-06 23:56 -0700
      Re: in praise of type checking Gunter Herrmann <notformail0106@earthlink.net> - 2011-10-07 13:57 -0400
  Re: in praise of type checking Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-10-07 07:19 -0300
    Re: in praise of type checking Roedy Green <see_website@mindprod.com.invalid> - 2011-10-07 12:39 -0700
      Re: in praise of type checking Gene Wirchenko <genew@ocis.net> - 2011-10-07 15:03 -0700
        Space probes was Re: in praise of type checking Tom Anderson <twic@urchin.earth.li> - 2011-10-11 19:26 +0100
          Re: Space probes was Re: in praise of type checking Leif Roar Moldskred <leifm@dimnakorr.com> - 2011-10-12 01:15 -0500
            Re: Space probes was Re: in praise of type checking Travers Naran <tnaran@gmail.com> - 2011-10-12 07:23 -0700
            Re: Space probes was Re: in praise of type checking Martin Gregorie <martin@address-in-sig.invalid> - 2011-10-12 20:04 +0000
            Re: Space probes was Re: in praise of type checking Gene Wirchenko <genew@ocis.net> - 2011-10-12 13:53 -0700
              Re: Space probes was Re: in praise of type checking Leif Roar Moldskred <leifm@dimnakorr.com> - 2011-10-12 16:55 -0500
                Re: Space probes was Re: in praise of type checking Gene Wirchenko <genew@ocis.net> - 2011-10-12 15:02 -0700
                Re: Space probes was Re: in praise of type checking Leif Roar Moldskred <leifm@dimnakorr.com> - 2011-10-13 00:08 -0500
                Re: Space probes was Re: in praise of type checking Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-10-13 07:48 -0300
                Re: Space probes was Re: in praise of type checking "John B. Matthews" <nospam@nospam.invalid> - 2011-10-14 07:09 -0400
                Re: Space probes was Re: in praise of type checking Martin Gregorie <martin@address-in-sig.invalid> - 2011-10-12 22:03 +0000
            Re: Space probes was Re: in praise of type checking Tom Anderson <twic@urchin.earth.li> - 2011-10-14 14:14 +0100
  Re: in praise of type checking RedGrittyBrick <RedGrittyBrick@spamweary.invalid> - 2011-10-07 11:50 +0100
    Re: in praise of [loosey goosey] type checking) RedGrittyBrick <RedGrittyBrick@spamweary.invalid> - 2011-10-07 12:20 +0100
  Re: in praise of type checking Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-10-07 14:00 +0000

csiph-web