Path: news.cs.au.dk!olm From: olm@cs.au.dk (Ole Lehrmann Madsen) Newsgroups: comp.lang.beta Subject: Re: Is Beta a statically typed language? Date: 10 Jan 1999 21:52:44 GMT Organization: University of Aarhus, Department of Computer Science (DAIMI) Lines: 101 Message-ID: <77b7fc$l2o$1@xinwen.cs.au.dk> References: NNTP-Posting-Host: sunrise.cs.au.dk X-Trace: xinwen.cs.au.dk 916005164 21592 255.255.255.255 (10 Jan 1999 21:52:44 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 10 Jan 1999 21:52:44 GMT X-Newsreader: NN version 6.5.3 (NOV) Xref: news.cs.au.dk comp.lang.beta:11786 In Jean-Louis Leroy writes: >In my explorations I came up with the following oddity: >(# > Fruit: (# #); > Apple: Fruit (# #); > Banana: (# #); > Animal: (# Food:< Object; f: ^Food enter f[] do INNER #); > Monkey: Animal (# Food::< Banana #); > cheetah: ^Animal >do > &Monkey[]->cheetah[]; > &Banana[]->cheetah; > &Apple[]->cheetah >#) >This program compiles but fails at runtime because of a 'qualification >error in reference assignment'. In fact my program contains an implicit >downcast which is quite well hidden. The compiler gives you a warning about this unless you have used the compiler siwtch '-q' which eliminates warnings. >This experiment was inspired by the C++ FAQ that goes 'why doesn't >Monkey::eat(Banana&) override virtual Animal::eat(Fruit&)?'. It is also >a Frequently Proposed Extension, sometimes under the moniker 'covariant >method signatures'. >The canonical reply/rebuttal is 'because it would open a hole in the >type system'. >This posits Beta somewhere between typeless and statically typed >languages, doesn't it? You are right. BETA is not completely statically typed. The issues goes all the way back to Simula where so-called reverse assignments were allowed. Consider declarations F: ^Fruit; A: ^Apple The assignment A[] -> F[] is of course legal, and this can be detected at compile-time. The assignment F[] -> A[] is legal if F refers to an Apple or a subpattern of Apple. This can in general only be checked at run-time. Simula and BETA allows such assignments and inserts a run-time check. You (covariant) example above is another example of reverse assignment where a run-time check is needed. We have discussed these issues in several papers (the references below are as precise as I remember them) Madsen, Moller-Pedersen,Magnusson: Strong typing of object-oriented languages revisited OOPSLA'90 Madsen: Open issues in object-oriented programming Software Practice & Experience, vol. 25(S4), December 95 Thorup Genericity in Java with Virtual types ECOOP'97 Torgersen: Virtual types are statically safe FOOL'5 Madsen: BETA, a block-structured, concurrent, object-oriented language In Handbook of Object Technology (S. Zamir ed.) CRC Press, 1999 and I think it is discussed in the BETA book also: Madsen, Moller-Pedersen, Nygaard: Object-oriented programming in the BETA Programming language ACM Press/Addison Wesley, 1993 Finally I am giving an invited a talk on these issues at The Sixth International Workshop on Foundations of Object-Oriented Languages FOOL 6, January 23, 1999 San Antonio, Texas, USA http://www.cs.williams.edu/~kim/FOOL/FOOL6.html Thanks for this opportunity to provide some commercials:-) ---olm >Jean-Louis Leroy >http://ourworld.compuserve.com/homepages/jl_leroy/