Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.lang.perl.misc Subject: Re: [OT] scoping Date: Mon, 16 Sep 2013 10:46:31 +0100 Lines: 75 Message-ID: <87mwnd2j60.fsf@sable.mobileactivedefense.com> References: <51e2660f$0$15864$e4fe514c@news2.news.xs4all.nl> <51e2c51a$0$15981$e4fe514c@news2.news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net Sl1gg0JO9R3tPXQIuWJweQywgt/MAU9AYxIacNSQoytRAwG5U= Cancel-Lock: sha1:WvJ+SmFbZ/tKNM9UxRk065mMPU4= sha1:wQvlGSbKT/yosQmw7g1uiCA6X4o= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Xref: csiph.com comp.lang.perl.misc:9287 David Harmon writes: > On Sun, 14 Jul 2013 17:34:50 +0200 in comp.lang.perl.misc, "Dr.Ruud" > wrote, >>On 14/07/2013 17:11, Tim McDaniel wrote: >>> In article , >>> Ben Morrow wrote: >>>> Quoth "Dr.Ruud" : >> >>>>> 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.