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,fee8802cc3d8334d X-Google-Attributes: gid103376,public X-Google-Thread: 10a146,fee8802cc3d8334d X-Google-Attributes: gid10a146,public From: Matthew Heaney Subject: Re: Ada and Java. different behaviour. casting long to int problem. Date: 1999/06/18 Message-ID: #1/1 X-Deja-AN: 490954937 References: <7jt2c0$vrb@drn.newsguy.com> <7k57vb$1ipf@drn.newsguy.com> <3766650F.705125B7@pwfl.com> <7k64t7$igo$1@its.hooked.net> <7k689a$ci2@drn.newsguy.com> <3766C842.E1EAB60A@pwfl.com> <3766D1CC.D712895E@itools.symantec.com> <7k7ls5$15tv@drn.newsguy.com> <3767D042.C8A8B131@cajunbro.com> <7kc3oo$2kac$1@news.gate.net> NNTP-Posting-Date: Thu, 17 Jun 1999 22:39:57 PDT Newsgroups: comp.lang.ada,comp.lang.java.programmer Date: 1999-06-18T00:00:00+00:00 List-Id: On 18 Jun 1999 11:15, dale@cs.rmit.edu.au (Dale Stanbrough) wrote: > ...but i think that Java is easier to read in some circumstances. You don't > end up having the code cluttered up with ".all", "'access" and "access". It depends on your style of programming. Access parameters were added to the language specifically to avoid having to explicitly dereference access objects: declare Matt : Man_Access := New_Man; begin Shave (Matt); ... end; where procedure Shave (Man : access Man_Type); One thing Java does give you is automatic garbage collection, but we can emulate that easily enough: type Man_Handle is private; function "+" (Handle : Man_Handle) return Man_Access; function New_Man return Man_Handle; declare Matt : Man_Handle := New_Man; begin Shave (+Matt); ... end; So you see, explicit dereferencing and 'Access are often unnecessary. The time when need to do that sort of thing is when you're programming close to the machine (which is entirely appropriate). Browse the Ada95 design patterns archive for more examples of access parameter and garbage collection idioms. > I also like Java's interfaces, a feature I'm not sure how Ada can replicate. You can do something like that using access discriminants. See the observer series (in the patterns archive) for lots o' examples.