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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f51e93dacd9c7fca X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-01 15:03:34 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!demon!news-hub.cableinet.net!blueyonder!newspeer.clara.net!news.clara.net!psiuk-p2!psiuk-p3!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: status of Ada STL? Date: Mon, 1 Jul 2002 09:12:28 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: References: <3d0ce154_5@news.bluewin.ch> <3d0e574d_2@news.bluewin.ch> <3d0fb5e8$1_3@news.bluewin.ch> <_cvS8.63267$UT.4317265@bgtnsc05-news.ops.worldnet.att.net> NNTP-Posting-Host: dhcp-200-133.miami.pace.co.uk X-Trace: nh.pace.co.uk 1025529150 23926 136.170.200.133 (1 Jul 2002 13:12:30 GMT) X-Complaints-To: newsmaster@news.cam.pace.co.uk NNTP-Posting-Date: 1 Jul 2002 13:12:30 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:26802 Date: 2002-07-01T13:12:30+00:00 List-Id: "Russ" <18k11tm001@sneakemail.com> wrote in message news:bebbba07.0206292005.45ad915a@posting.google.com... > > Perhaps I am missing something here, but when you say the expression > "Z = 0" has a "side-effect" on Z you lose me. I don't see how > assignment can be considered a "side effect". > Think of the user definable Ada function: function "=" (Left, Right : in Some_Type) return Boolean ; You can call it as: "="(L,R) or as: L = R and in either case it returns a Boolean. But note that the formals Left and Right are *in* parameters - they cannot be changed. If Assignment were to be a "function" instead of a primitive statement then you'd have to be able to make Left be an *in out* parameter - which is illegal in Ada. Changing "Left" in a function call is a "side effect" which C/C++ allows, but Ada does not. > I confess I don't know didly about assignment in Ada, but I can tell > you that assignment in C++ for user defined types is a member > function. It does whatever the implementer of the class tells it to > do. And it is considered good form to have it return a reference to > "*this" so that assignment can be cascaded, as in "A = B = C = D". > Sure, but in Ada the way assignment is defined it is *not* a function so it just doesn't behave in the same way as what it does in C/C++. Trying to make it so would probably break the language because it has implications all over the place with respect to the way other things in the language work. > If a C++ class does not explicitly define an assignment operator, the > compiler will define one by default. The default assignment operator > is often perfectly good. In fact, the only time the class should > define its own assignment operator is when the it contains a pointer > to data on the heap that needs to be copied in the assignment > operation. Otherwise, you are much better off with the default. The > same applies to copy constructors, by the way. Newbies often > misunderstand this and write their own unnecessarily, which can only > cause unnecessary bugs. > You have the same capability in Ada. Yoy get assignment for free and if you need to change the behavior, you derive from Controlled and define your own Initialize, Adjust and Finalize subprograms. It actually works much cleaner than Constructors and Destructors in C++ - especially where parameter passing is concerned. The important thing is that you can acomplish the same thing in Ada that you can in C++ - you just can't do it in exactly the same syntactic/semantic manner. > > Ya, and what about Cobol, Basic, Fortran, Java, Perl, Python, Matlab, > and Mathematica programmers? Should they all just get lost too? > If you want to program in Ada - program in Ada. If you want to program in Cobol - program in Cobol. Changing Ada to make it look and act like Cobol is just going to a) not work well and b) urinate-off existing Ada users. Get lost? No. Just get comfortable with what Ada *is* and don't insist it be something it isn't. Attempting to please everyone isn't going to work anyway - Cobol programmers aren't going to switch to Ada if only Ada starts supporting "Add X to Y Giving Z" syntax and semantics for assignment, so why make the compiler writers and existing users go through agony to try to persuade some Cobol guys to jump the fence? The important thing about Ada is that it provides all the capabilities you get with other languages and additional capabilities you don't get with other languages. It doesn't do it identically - but a solution does exist. You *can* achieve the same results and you get extra things on top of it. If you want all those capabilities, then you work within the framework of what Ada is and does. Asking Ada to look like and act like C++, Java, Fortran, Cobol, Perl, etc. in order to make users of those languages more comfortable is just a hopeless task. > As I said, I have no idea how assignment works in Ada, but it would be > nice if it worked as well as it does in C++. > It works just fine. It works (IMHO) better than it does in C++. Its far less of a cobbled together hack that requires all sorts of "I before E except after C or when sounded as A as in Neighbor and Weigh..." kinds of exceptional rules. It just doesn't work *identically* to assignment in C++, so one needs to learn how to work with The Ada Way. Trying to force Ada to do assignment in an identical way to that of C++ is like trying to teach a pig to dance. The results won't be very pretty or successful and it will only annoy the pig. MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com