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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,8ff80a74f45b5cd3 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,8ff80a74f45b5cd3 X-Google-Attributes: gid103376,public From: nospam@thanks.com.au (Don Harrison) Subject: Re: Visibility and access to "public" attributes Date: 1997/09/02 Message-ID: #1/1 X-Deja-AN: 269459729 Sender: news@syd.csa.com.au X-Nntp-Posting-Host: dev50 References: <872873007.3110@dejanews.com> Organization: CSC Australia, Sydney Reply-To: nospam@thanks.com.au Newsgroups: comp.lang.ada,comp.lang.eiffel Date: 1997-09-02T00:00:00+00:00 List-Id: Mike Card wrote: [..] Example of how to emulate Eiffel's look-but-dont-touch attributes: :package Test1 is : type My_Type is tagged private; -- attributes invisible : function A(Obj : My_Type) return Boolean; -- access function :private : type My_Type is tagged : record : A : Boolean; -- attribute : end record; :end Test1; : : :package body Test1 is : function A(Obj : My_Type) return Boolean : is : begin : return Obj.A; : end A; :end Test1; I accept this more accurately emulates the Eiffel functionality, and.. :.. there is no restriction in Ada that prevents an access function :from having the same name as a class' (tagged type's) attribute. True. :That said, I think it is fair to say that I believe the idea behind :Ada's "all or nothing" approach is that you may want to ensure that :a client never depends on some of a type's attributes. As you acknowledge below, this can be done in Eiffel by hiding all the attributes of the type.. (See slso my response to Jon). :I know that Eiffel can totally hide the attributes of an object (i.e. :accessed via methods only) as well. When writing Eiffel programs, how :do you decide when to make a type's attributes "read-only visible" :and when to hide them? You export them when they're needed (or may be needed) by clients; otherwise, you hide them. Mike subsequently wrote: :Now, suppose you change the AIRCRAFT class to have jet engines and :thus remove or change the Propeller_RPM attribute? Because it was :*visible*, someone may have written code to read it and now if you :change the spec of the class their code will break. It doesn't :matter that they can't update the attribute! If they can refer to it :at all and you remove the attribute from the class definition, their :code is broken! As others have pointed out, the problem here is that your design for the AIRCRAFT class, rather than the Eiffel mechanism, is deficient - it assumed the aircraft was propeller-driven. Don. (Reverse to reply) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Don Harrison au.com.csa.syd@donh