From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 8 Jul 91 18:03:46 GMT From: elroy.jpl.nasa.gov!usc!petunia!nwebre@decwrl.dec.com (Neil Webre) Subject: Re: Sliding Semantics? Message-ID: <2878a902.2d8b@polyslo.CalPoly.EDU> List-Id: In article <1991Jul8.154928.24379@aio.jsc.nasa.gov> dean@sweetpea.jsc.nasa.gov writes: >In article <2871efdf.5c45@polyslo.CalPoly.EDU>, nwebre@polyslo.CalPoly.EDU (Ne il Webre) writes: >|> >|> There are a couple of workarounds. The best we've been able to invent >|> has been using type conversions. The substring statement, for instance, >|> becomes >|> >|> declare >|> type anchor is new string(1..len); >|> begin >|> s3 := (len, string(anchor(s2.text(posn .. posn + len - 1)))); >|> end; >|> >|> That "slides" the index range of the result to be from 1 to some value. >|> > >Very interesting problem. I was unable to come a significantly better >solution. One question I do have though, is there any advantage to >using a subtype declaration for anchor, i.e. > > declare > subtype anchor is string(1..len); > begin > s3 := (len, anchor(s2.text(posn .. posn + len - 1))); > end; > >Will the compiler generate less code in this case since there is no >type conversion? This works as desired on the Rational. Does it do >the same thing on other machines / other Ada compilers? > >-- Good point. Your approach avoids a conversion back to type string. Neil Webre Cal Poly, San Luis Obispo, CA Department of Computer Science