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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,628d2a493f1e203d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!news.belwue.de!newsfeed.arcor.de!news.arcor.de!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Subtype conformance... not what I was expecting. From: Georg Bauhaus In-Reply-To: <44c77cf0$0$2917$4d3efbfe@news.sover.net> References: <44c6db66$0$2928$4d3efbfe@news.sover.net> <44c77cf0$0$2917$4d3efbfe@news.sover.net> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: # Message-ID: <1153928329.4980.14.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Date: Wed, 26 Jul 2006 17:38:50 +0200 NNTP-Posting-Date: 26 Jul 2006 17:35:54 MEST NNTP-Posting-Host: 9f1aa74f.newsread2.arcor-online.net X-Trace: DXC=ZA:nO^`bIl_40bn3J7ld6QQ5U85hF6f;TjW\KbG]kaMXU7^]5?JhlB^?U0dAj7QF;TUUng9_FXZ=S>:=P9Ihe`BX@Z?dZ]MOidU X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:5940 Date: 2006-07-26T17:35:54+02:00 List-Id: On Wed, 2006-07-26 at 10:32 -0400, Peter C. Chapin wrote: Sounds like the technical/mathematical versus practical/real-world co(ntra)variance issue? > Using the notation common in functional languages, let F : t1 -> t2 and > G : t1' -> t2'. Then t1 -> t2 is a subtype of t1' -> t2' (that is, > t1->t2 <: t1'->t2') iff t2 <: t2' and t1' <: t1. In this case I realize > that G is an access type but it "feels" like a function when it is used. > Since I'm trying to use F where G is expected and since F and G have the > proper subtype relationship to each other one might suppose that the > above rule would be obeyed. Let F : Person -> Room and G : Girl -> Girls_Dormitory. Then Person -> Room is a subtype of Girl -> Girls_Dormitory (that is, Person->Room <: Girl->Girls_Dormitory) iff Room <: Girls_Dormitory and Girl <: Person. Let F : Girl -> Girls_Dormitory and G : Person -> Room. Then Girl -> Girls_Dormitory is a subtype of Person -> Room (that is, Girl->Girls_Dormitory <: Person->Room) iff Girls_Dormitory <: Room and Person <: Girl. Now add Boy. Granted Persons and Rooms are distinct type classes, but are the transcriptions correct otherwise? (The example is from Meyer's OOSC2 as I remember it, but I don't have the book here to check.)