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,799e6e37c90ca633 X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: Future Ada language revisions? Date: 1998/10/06 Message-ID: #1/1 X-Deja-AN: 398511993 References: <6um7on$db5$1@nnrp1.dejanews.com> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: 907732321 26087 bpr 206.184.139.136 MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-10-06T00:00:00+00:00 List-Id: On 6 Oct 1998, Robert I. Eachus wrote: > In article Brian Rogoff writes: > > > Yes, this is nice, though I (perhaps wrongly) feel that this solution is > > kind of heavy in terms of performance costs, especially if I want to have > > side-effecting functions on objects with value semantics. > > 1) You can do that! The compiler may warn you that you are being > naughty, but you knew that. The idiom is to use an attribute > definition clause to overlay an internal object: > > with Text_IO; > procedure Cheat_Test is > Test_String: String := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; > Junk: Character; > > function Cheat(X: in String) return Character is > Temp: Character := X(X'First); > Overlay: String(X'Range); > for Overlay'Address use X'Address; > begin > Overlay(X'First) := 'Z'; > return Temp; > end Cheat; > > begin > > Text_IO.Put_Line(Test_String); > Junk := Cheat(Test_String); > Text_IO.Put_Line(Test_String); > > end Cheat_Test; Very nice! Kind of naughty IMO, but still very nice. I never thought about this approach, thanks for bringing it to my attention. > > Eh? READERS will look at the interface to the function and see an out mode > > parameter, so they'll only be surprised if they don't read the spec. > > "Against stupidity the gods themselves contend in vain", right? > > Correct, but irrelevant. If the style in Ada is that functional > notation means that--in spite of the realities above--the effect of a > function on its parameters is benign, then a function which does > violence to its parameters will always be unexpected. Sure, but I was assuming an Ada with out-mode functions, in which that assumption would no longer be true. I think we're talking about slightly different things. > ... snip some stuff about "distributed costs" ... > > No, in Ada design it has always been used to mean a "feature" which > makes things more difficult even if it is not used. I defer to your definition, for obvious reasons :-). I took it as meaning an actual speed or space penalty imposed for a feature which isn't used in a program; I see its meaning was actually much broader. -- Brian