"Hyman Rosen" a �crit dans le message de news:1071687303.254780@master.nyc.kbcfp.com... > Jean-Pierre Rosen wrote: > > "Hyman Rosen" a �crit > >>I expect this is just the usual "simulate MI with access discriminants" > >>bit that always comes up here. I think it can do everything except support > >>cross-casting. > > > > It can. See my paper at http://www.adalog.fr/publicat/ada-interfaces.pdf > > Does this mean that you think it can support cross-casting, > or do you agree that it cannot? That is, in Java, I may have > two interfaces: > interface IF_1 { } interface IF_2 { } > and given an object of type IF_1, I may try to see if it is > also of type IF_2: > boolean is_both(IF_1 o) { return o instanceof IF_2; } > and if it is, I can cross-cast: > IF_2 as_IF_2(IF_1 o) { return is_both(o) ? (IF_2)o : null; } > > Note that I can do this without any knowledge at all of the > existence of one or more parent types which implement both > interfaces. I don't think this can be done with the inner class/ > access discriminant approach. > What I meant is that if class A implements interface IF, and you get an object as an IF, you can get a view of it as an A. I didn't consider the case you mention - presumably because I never met a need for it! -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr