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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,953e1a6689d791f6 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,953e1a6689d791f6 X-Google-Attributes: gid103376,public From: jsa@alexandria (Jon S Anthony) Subject: Re: Eiffel and Java Date: 1996/11/01 Message-ID: #1/1 X-Deja-AN: 193798317 sender: news@organon.com (news) references: <550sm2$sn1@buggy.news.easynet.net> organization: Organon Motives, Inc. newsgroups: comp.lang.eiffel,comp.lang.ada Date: 1996-11-01T00:00:00+00:00 List-Id: In article <1996Oct31.201748.29073@merlin.hgc.edu> jcm@hgc.edu (James McKim) writes: > In article <55639c$1of@buggy.news.easynet.net> Sacha@easynet.fr (Vincent WEBER) writes: > >In article , mheaney@ni.net > >says... ... > >>Ada's type mechanism accomplishes the equivalent of pre- and > >>post-conditions, and you don't seem to mind their inclusion in Eiffel, so > >>that can't be it. > > > >Well, to some extent... I admit you can easily use pre and post conditions in > > Whoa, about the simplest precondition I can think of is related to accessing > the top of a generic stack. > > class STACK[G] > ... > top : G is > require > not_empty: depth > 0 > ... > > How do you emulate this using types in Ada? This is not a particularly good example of not having full assertions in standard Ada as it is rather easy to "emulate": type Stack is private; ... type Depth_Range is new Natural; type Stack is record Depth : Depth_Range := Depth_Range'First; ... end record; ... function Top (S : Stack) return ... Not_Empty : Positive := S.Depth; -- Requires Depth > 0 or CE is raised ... > Just askin' > -- Jim Just answerin' /Jon -- Jon Anthony Organon Motives, Inc. Belmont, MA 02178 617.484.3383 jsa@organon.com