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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,61e9062c1f23b9d5 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!w5g2000hsg.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Reconsidering assignment Date: Mon, 11 Jun 2007 14:12:09 -0700 Organization: http://groups.google.com Message-ID: <1181596329.198235.320830@w5g2000hsg.googlegroups.com> References: <1181165630.012508.55290@i38g2000prf.googlegroups.com> <19fxsxv1god43$.1pqq8vgfu2itn$.dlg@40tude.net> <1181428673.148991.76570@p77g2000hsh.googlegroups.com> NNTP-Posting-Host: 85.3.217.1 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1181596329 9418 127.0.0.1 (11 Jun 2007 21:12:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 11 Jun 2007 21:12:09 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: w5g2000hsg.googlegroups.com; posting-host=85.3.217.1; posting-account=Ch8E9Q0AAAA7lJxCsphg7hBNIsMsP4AE Xref: g2news1.google.com comp.lang.ada:16165 Date: 2007-06-11T14:12:09-07:00 List-Id: On 11 Cze, 20:57, "Randy Brukardt" wrote: > > > X : Integer := 1 + 1; > > It's a compile-time expression with the value 2. > > Not very complex. ;-) > > Sorry, Dmitry is right; you seem to have missed his point. In order for this > to be "a compile-time expression", you need complex preference rules in your > type system. (That is, that "compile-time expressions" are preferred over > types that would cause some other kind of expression.) Hm... indeed, that must be the case - there must be some logic to allow the compiler to actually figure out that it is a compile-time expression. Granted, such a logic might be a good candidate for the optimizer (who wants function calls where the result can be immedately available), but at the same time this is easiest to do when the type system itself is very minimal. I think there is time for some conclusions. The major points I've learned in these discussions: - Constraint_Error cannot be easily excluded with the use of legality rules that are applied only locally. What I mean here is the rules that can be checked only based on the static properties of names that the compiler encounters in each expression (a type system, basically), without information flow analysis and such. - Unconstrained types in Ada can be used to "parameterize" whole subprograms, even though these subprograms don't need to be proper generics. Interestingly, no "implicit instantiation" is needed here neither. Thanks to all contributors and to Dmitry in particular. Still (heck, that doesn't seem to be the end of discussion :-) ), the earlier idea of expressing restrictions for subprogram parameters looks interesting to me. The point is that subprogram overloading operates on each parameter in isolation, whereas such restrictions could add the possibility of selecting more convoluted subsets of the whole relation. This is similar to treating the whole set of parameters as a single record type and then constraining this single record type for the purpose of overloading. If the restriction is based on run-time properties of parameters, then it doesn't provide anything that cannot be achieved with explicit if/ else at the beginning of the subprogram. Consider: procedure P(X, Y : Real) with X*X + Y*Y <= 1; procedure P(X, Y : Real); The idea was to have some assistance from the language for the proper selection of overloaded P (one is for arguments that fall withing the unit circle, and the other is for the rest). Here it doesn't give anything fundamentally new, this can be achieved with if/else in a single procedure. On the other hand, restrictions for compile-time properties might be more useful and can be for example an interesting optimization tool. In C++ such effects are achieved with so called type traits and (partial) template specializations. I wouldn't mind having this in Ada. -- Maciej Sobczak http://www.msobczak.com/