From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,9e7db243dfa070d7 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!y23g2000yqd.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: Do people who use Ada also use ocaml or F#? Date: Sun, 31 Oct 2010 14:46:07 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <87k4kz3mda.fsf@mid.deneb.enyo.de> <5jjgrklivesk$.z0is5qe7mgbt.dlg@40tude.net> NNTP-Posting-Host: 174.28.254.71 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1288561567 16860 127.0.0.1 (31 Oct 2010 21:46:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 31 Oct 2010 21:46:07 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y23g2000yqd.googlegroups.com; posting-host=174.28.254.71; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729; .NET4.0E),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:15074 Date: 2010-10-31T14:46:07-07:00 List-Id: On Oct 30, 1:37=A0pm, "Dmitry A. Kazakov" wrote: > On Sat, 30 Oct 2010 21:12:36 +0200, Yannick Duch=EAne (Hibou57) wrote: > > This is not more not less safe than any =A0 > > other composition process. > > This requires a proof, which would be hard to provide because generics ar= e > non-testable. > > -- > Regards, > Dmitry A. Kazakovhttp://www.dmitry-kazakov.de Are generics really non-testable? I think they are, though perhaps they may quickly spiral into a wide range of tests. The simple example of a bubble-sort on an array is testable: Generic Type Element_Type is private; Type Index_Type is (<>); Type Array_Type is Array( Index_Type Range <> ) of Element_Type; With Function "<" ( Left, Right : in Element_Type ) Return Boolean is <>; Function Bubble_Sort( Input : In Array_Type ) Return Array_type; ---- Body for Bubble_Sort Function Bubble_Sort( Input : In Array_Type ) Return Array_type is begin Return Result: Array_Type:=3D Input do For Index_1 in Input'First..Index_Type'Pred(Input'Last) loop For Index_2 in Index_Type'Succ(Index_1)..Input'Last loop if Not (Input(Index_1) < Input(Index_2)) then declare Temp : Element_Type:=3D Result(Index_1); begin Result(Index_1):=3D Result(Index_2); Result(Index_2):=3D Temp; end; end if; end loop; end loop; End Return; end Bubble_Sort; Because we know that the index is a discrete type, and has the 'Pred & 'Succ functions we can prove this to be correct; and because we are requiring a function "<" for the element-type we can prove that this is a correct and complete bubble-sort; it is also a generic function though. Things get much, much more complex very quickly when you expand out into packages, but this does not invalidate this example. It is my opinion that a lot of what the software industry is facing is the culmination of the failure to really understand the problems we have been given; I don't exclude myself from this assessment, many times I have coded something, and then coded it again, and then again, and *THEN* I finally **GET** the problem. {I am here distinguishing getting the task-completed from _understanding_ the task itself.} Much of that lack of a deeper understanding, in my opinion, is caused by the Cut-n-paste mentality of my peers. C/C++/Java students have a "rich tradition" of going online, looking up the code that "basically does what you want" and then "tweaking" it to suit their needs. Working within the realm of generics is somewhat akin to mathematical induction, you HAVE to use the properties of the objects your working with and, once you do it "magically" comes together. Just like induction requires two distinct portions the "n -> n+1"- and the "n"- portions generics can be divided up into two portions the problem that you are trying to address, and the properties of the objects you are working with within that problem.