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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,73cb216d191f0fef X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.68.161.163 with SMTP id xt3mr4086443pbb.7.1363383987818; Fri, 15 Mar 2013 14:46:27 -0700 (PDT) Path: jm3ni51984pbb.0!nntp.google.com!news.glorb.com!xmission!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Is this expected behavior or not Date: Fri, 15 Mar 2013 17:46:26 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <8klywqh2pf$.1f949flc1xeia.dlg@40tude.net> <513f6e2f$0$6572$9b4e6d93@newsspool3.arcor-online.net> <513faaf7$0$6626$9b4e6d93@newsspool2.arcor-online.net> <51408e81$0$6577$9b4e6d93@newsspool3.arcor-online.net> <11rcs3gg4taww$.bylek8fsshyz$.dlg@40tude.net> <99929f93-b80f-47c3-8a37-c81002733754@googlegroups.com> <87ec4b1d-f7cd-49a4-8cff-d44aeb76a1ad@googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls6.std.com 1363383987 8727 192.74.137.71 (15 Mar 2013 21:46:27 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 15 Mar 2013 21:46:27 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:GI3c0so1xqbH+N339nrunbOAdGs= Content-Type: text/plain; charset=us-ascii Date: 2013-03-15T17:46:26-04:00 List-Id: "Randy Brukardt" writes: > "Shark8" wrote in message > news:87ec4b1d-f7cd-49a4-8cff-d44aeb76a1ad@googlegroups.com... > ... >> Hm, true; speaking of object-attributes I sometimes [though not too often] >> wish I could write something like: >> Procedure X( Input : Some_Type ) is >> Temp : Input'Type := Some_Value; >> begin >> -- Whatever needs done. >> end X; >> >> Is there any reason that should be disallowed / would be difficult for >> compiler-writers to implement? > > I've occassionally had such a thought, too. Me, too. (I also agree with Shark8's "not too often" comment.) Many languages allow the type of an object to be deduced from its initial value. I believe C++ recently added that feature, using the "auto" keyword (which it inherited from C, and meant something completely different -- and completely useless). Ada allows that in a small way -- named numbers. >... Probably the reason this doesn't > exist is that Ada 83 didn't have type-valued attributes and thus it wasn't > considered there. I suspect the reason was that the designers of Ada 83 thought that types of things ought to be explicit. Except for named numbers -- consistency wasn't their strong suit. > 83). There would potentially be a cost to an object attribute vs. using the > subtype name directly, in that the prefix would have to be evaluated (which, > if it included function calls or checks, would generate some code). Such cases could be forbidden. Or one could do something like what C does for sizeof -- the operand is not evaluated. It's as if you could say "X.all'Size" in Ada and not get a C_E, even if X = null. That works in C because all sizes are known at compile time. In Ada, all types are known at compile time, so "X.all'Type" (or "X.all'Subtype"?) could conceivably denote Integer even when X = null. > It's not clear that there is any problem here, it's just that we haven't > considered it and usually that means there is a problem there. :-) Could > just be FUD, too. Well, a bit of FUD is often appropriate in language design. ;-) - Bob