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: 103376,52d41ed2965dfc50 X-Google-Attributes: gid103376,public From: Mike Young Subject: Re: Something like "->" in Ada? Date: 1996/04/02 Message-ID: <31620B5E.FCD@mcs.com>#1/1 X-Deja-AN: 145546468 references: <4jpd79$ces@newsflash.concordia.ca> content-type: text/plain; charset=us-ascii organization: Fen Software, Inc. mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01Gold (Win95; I) Date: 1996-04-02T00:00:00+00:00 List-Id: Robert Dewar wrote: > > Chris says > > " I am learning OOP with Ada 95. Although I have only a bit of experience, > mostly with Perl 5, I find that the "->" operator is much more intuitive > than passing an object as a parameter to a subprogram. Is it possible to > define "->" as the following:" > > What you are used to always seems more intuitive than what you are > getting used to. Wait till you can say "I have completely learned OOP > with Ada 95", then see what you think. Many people think that the > procdure argument approach is in fact much simpler, and that the -> > is unnecssarily restrictive and over-specific. ======= Mayhaps, Robert. I would appreciate any help you might offer. In playing with Intermetric's adajava package last night, I had an interesting few minutes translating the following Java statement into Ada-ish code: (size().width - g.getFontMetrics().stringWidth(helloStr)) The Ada equivalents I finally coughed up are: 1) (size(this).width - stringWidth(getFontMetrics(G), hello_Str)) 2) declare pSize : Rectangle_Ptr := size(this); fontM : FontMetrics_Ptr := getFontMetrics(G); begin ... (pSize.width - stringWidth(fontM, hello_Str)), ... end; In other words: g().f().func(...); compares to: func(f(g(this)), ...); I'm not drawing any conclusions from this exercise, but the contrast between Java's cascading style and Ada's func(f(g(x)), ...) style appears somewhat extreme. The Java version is consistent with a heirarchy (g.getFontMetrics().stringWidth(...)); this has some value when trying to unravel what stringWidth is. Also, there's a certain inconsistency in inverting the relationship when an attribute is directly accessed, compared to calling functions only. Changing an attribute into a function call would involve more work in re-ordering the statement. But, as you say, it's probably a matter of acclimation. Mike.