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


Groups > comp.lang.perl.misc > #9287

Re: [OT] scoping

From Rainer Weikusat <rweikusat@mssgmbh.com>
Newsgroups comp.lang.perl.misc
Subject Re: [OT] scoping
Date 2013-09-16 10:46 +0100
Message-ID <87mwnd2j60.fsf@sable.mobileactivedefense.com> (permalink)
References (2 earlier) <51e2660f$0$15864$e4fe514c@news2.news.xs4all.nl> <i7haba-e8u.ln1@anubis.morrow.me.uk> <kruf37$3vl$1@reader2.panix.com> <51e2c51a$0$15981$e4fe514c@news2.news.xs4all.nl> <E4WdnSuxQaOd3avPnZ2dnUVZ_sqdnZ2d@earthlink.com>

Show all headers | View raw


David Harmon <source@netcom.com> writes:
> On Sun, 14 Jul 2013 17:34:50 +0200 in comp.lang.perl.misc, "Dr.Ruud"
> <rvtol+usenet@xs4all.nl> wrote,
>>On 14/07/2013 17:11, Tim McDaniel wrote:
>>> In article <i7haba-e8u.ln1@anubis.morrow.me.uk>,
>>> Ben Morrow  <ben@morrow.me.uk> wrote:
>>>> Quoth "Dr.Ruud" <rvtol+usenet@xs4all.nl>:
>>
>>>>>       qq{
>>>>>           SELECT
>>>>>               $columns_csv
>>>>>           FROM
>>>>>               $table
>>>>>           WHERE
>>>>>               id IN (@ids)  -- hundreds easily
>>>>
>>>> Please, someone tell your cow-orkers about placeholders...
>>>
>>> The classic "Bobby Tables" strip:
>>> http://xkcd.com/327/
>>
>>Yeah, also doesn't apply.
>>
>>See how I left out what @ids is. Now, in stead of assuming anything else 
>>again, assume that @ids can only contain numbers, and that each is 
>>between 1 and some maximum.
>
> Uhm, no.  When evaluating whether code is broken or not, you don't
> assume perfect flawless input.  You assume worst case malicious NSA
> type input.

The code is 'broken' when it doesn't process the data it is supposed to
process such that the intended result results from that. Eg, this

sub sum
{
    return $_[0] + $_[1];
}

is a function which will return the sum of its first two arguments
provided that both are numbers. It can be made to do something very much
different,

---------
package Ha;

use overload "+" => negate;

sub new
{
    return bless([], $_[0]);
}

sub negate
{
    return ~$_[1];
}

package main;

sub sum
{
    return $_[0] + $_[1];
}

print(sum(3, 4), "\n");
print(sum(Ha->new(), 4), "\n");
---------

but this doesn't mean 'sum is broken': The precondition 'first two
arguments are numbers' is not true for the second call, hence, the
postcondition won't necessarily be true afterwards.

Whether or not 'will be a number > 1' is a sensible precondition in a
given situtation would be a different question.

Back to comp.lang.perl.misc | Previous | NextPrevious in thread | Find similar


Thread

Re: [OT] scoping David Harmon <source@netcom.com> - 2013-09-15 16:16 -0700
  Re: [OT] scoping Xho Jingleheimerschmidt <xhoster@gmail.com> - 2013-09-15 19:23 -0700
  Re: [OT] scoping Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-09-16 10:46 +0100

csiph-web