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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC 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!news4.google.com!out03a.usenetserver.com!news.usenetserver.com!in04.usenetserver.com!news.usenetserver.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Reconsidering assignment Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1181165630.012508.55290@i38g2000prf.googlegroups.com> <19fxsxv1god43$.1pqq8vgfu2itn$.dlg@40tude.net> <1181428673.148991.76570@p77g2000hsh.googlegroups.com> <1181596329.198235.320830@w5g2000hsg.googlegroups.com> Date: Tue, 12 Jun 2007 10:31:34 +0200 Message-ID: <1v0wjynus2uj6$.b4qm8649j38o$.dlg@40tude.net> NNTP-Posting-Date: 12 Jun 2007 10:28:56 CEST NNTP-Posting-Host: 8c08d2b2.newsspool1.arcor-online.net X-Trace: DXC=YkAJ5Tm>ND8U`5g[@c]@J1ic==]BZ:af>4Fo<]lROoR1Fl8W>\BH3Y2WG30a1gD7<4DNcfSJ;bb[5FCTGGVUmh?4LK[5LiR>kg2jJF33`Wa]D: X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:16167 Date: 2007-06-12T10:28:56+02:00 List-Id: On Mon, 11 Jun 2007 14:12:09 -0700, Maciej Sobczak wrote: > 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. (Note that by allowing this you allow multiple-dispatch, with its more than linear number of alternatives) > 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). This cannot work because overloading resolution happens at compile-time, while the conditions of matching, in your case are general run-time expressions. BTW, a similar mechanism exists for entry point barriers: entry P (X, Y : Real) when ; Though, note that for very strong reasons may not depend on the entry point arguments. Another objection is that it is again preferences and it is undecidable. Consider: procedure P(X, Y : Real) when Halt (X); procedure P(X, Y : Real); and it is ambiguous: procedure P(X, Y : Real) when X in -1..10;; procedure P(X, Y : Real) when X in -10..1; which one to choose when X is 0? Yet another point: P is a polymorphic subprogram. Various overloading are implementations of. The condition clause controls the choice. Does not it remind you anything? Make Real a class! A general software design objection is that this breaks encapsulation. The idea of type is that constraints like X*X+Y*Y<1 should be property of a type. When you move them to procedures, you loose OO/ADT decomposition. > Here it doesn't give > anything fundamentally new, this can be achieved with if/else in a > single procedure. IMO there is great need in a language support for compile-time user-defined expressions and decomposition subprograms into compile- and run-time parts. The most obvious case is dimensioned expressions. > On the other hand, restrictions for compile-time properties might be > more useful and can be for example an interesting optimization tool. Well, Optimizations are optional, a proper choice of P is not. If you wanted to have an optimization tool, you should make both Ps in your example legal: procedure P(X, Y : Real) when Memory_Is_Low; procedure P(X, Y : Real) when A_CPU_Core_Is_Free; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de