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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,751584f55705ddb7 X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Side-effect arithmetic again [was: Ada ... in embedded systems] Date: 1996/03/20 Message-ID: #1/1 X-Deja-AN: 143213682 references: <314B33CE.64EE@escmail.orl.mmc.com> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-03-20T00:00:00+00:00 List-Id: In article dewar@cs.nyu.edu (Robert Dewar) writes: > Direction_Type'Increment (Direction); > does not seem very inspiring > Direction := Direction + 1; > seems OK. Yes, I know you can find complex cases, but in well written > code, complex stuff is minimized anyway, and for example nearly all > increments in the GNAT source are of simple variables. Agreed. Very much agreed. At one time I thought that Ada 9X should include user defined attributes, but it just isn't that useful a feature. As Robert Dewar points out above the second form is usually both shorter and reads better. When you do lots of increments and decrements what you really want is: Inc(Direction); And the code for that is fairly trival. I may accept John Volan's challenge and post a proposed package tomorrow. But I don't think it needs to be standardized. (The issue I want to think about overnight is whether the generic formal should be "is range <>" or "is (<>)". I already know that I want to rewrite the package to: procedure Inc(Object: in out Formal_Type); procedure Inc(Object: in out Formal_Type; By: in Integer); function Inc(Value: in Formal_Type) return Formal_Type; function Inc(Value: in Formal_Type; By: in Integer) return Formal_Type; Since you want the one parameter forms to inline right. (Should the function form be named something other than Inc and Dec? Does the Ada domain specific knowledge that the parameters of a function are not changed dominate here, or should it be named Next?) -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...