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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,79bbf7e359159d0d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-17 02:26:06 PST Path: supernews.google.com!sn-xit-03!supernews.com!news-feed.riddles.org.uk!freenix!oleane.net!oleane!nnrp.oleane.net!not-for-mail From: "Jean-Pierre Rosen" Newsgroups: comp.lang.ada Subject: Re: newbie can't get exceptions to work! Date: Tue, 17 Apr 2001 11:08:37 +0200 Organization: Adalog Message-ID: <9bh236$4ed$1@s1.read.news.oleane.net> References: <3AD2788C.7F2BAFA3@worldnet.att.net> <9b1oqv$ikb$2@taliesin.netcom.net.uk> <3AD4D3C2.E45751D9@worldnet.att.net> <3AD54C20.27489848@mida.se> <3ADBEAE0.7D69463E@mida.se> NNTP-Posting-Host: mailhost.axlog.fr X-Trace: s1.read.news.oleane.net 987499430 4557 195.25.228.57 (17 Apr 2001 09:23:50 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Tue, 17 Apr 2001 09:23:50 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Xref: supernews.google.com comp.lang.ada:6942 Date: 2001-04-17T11:08:37+02:00 List-Id: "Mats Karlssohn" a �crit dans le message news: 3ADBEAE0.7D69463E@mida.se... > [...], I've always (almost anyway) > wondered why the attributes were designed to have the syntax that they > have today. Not that I find them that annoying, but in half of their > use the attributes behaves just like functions, the other half (when > setting object'size := 14; for example) is another matter. > > Do someone remember the history behind this ? > Here is how I explain it to my students. When you declare a type, the compiler defines some constants and functions that can be helpful. Now the problem is that the compiler must find names for these constants and functions, and those names must not conflict with names defined by the user. The trick is that the compiler allows itself to put an apostrophe in the name, something that is not allowed to regular identifiers. Therefore, there can be no conflict. In short, when you define: type My_Int is range 0..100; the compiler adds the declarations: My_Int'First : constant My_Int := 0; My_Int'Last : constant My_Int := 100; function My_Int'Image (Item : My_Int) return String; etc. So, if you see attributes not as special constructs, but simply as identifiers with a special character in them, they are not different from other language constructs, and allowing the user to define them would defeat their purpose. Actually, I find it quite nice that their is no "magic" identifier recognized in a special way by the compiler, like sizeof() in C for example. With attributes, you know without ambiguity what is defined by the compiler and what is defined by the user. (David: if you want to put this in the FAQ, you are welcome) -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr