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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c39ad3e35a7690a9 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Received: by 10.68.213.68 with SMTP id nq4mr6371884pbc.2.1328990799454; Sat, 11 Feb 2012 12:06:39 -0800 (PST) Path: wr5ni13441pbc.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Convention for naming of packages Date: Sat, 11 Feb 2012 20:06:36 +0000 Organization: A noiseless patient Spider Message-ID: References: <4f355230$0$21451$ba4acef3@reader.news.orange.fr> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="10535"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YLWazaDt98OLHK/iXVjL53oMmaOqbT3k=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:JdDmDO5l0NAqjyy/IdrAbpr4k18= sha1:TS2Hx7LMBVwACwK9VqHi3vTWzm8= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Date: 2012-02-11T20:06:36+00:00 List-Id: "Yannick Duchêne (Hibou57)" writes: > Le Sat, 11 Feb 2012 11:17:41 +0100, Yannick Duchêne (Hibou57) > a écrit: > >> Le Sat, 11 Feb 2012 10:22:18 +0100, Simon Wright >> a écrit: >>> In most cases the subprogram name tells what it does, and the object >>> parameter might just as well be called 'This'. > > Finally I will either not keep this one, or else, complete it. "This" > as‑as and alone, don't map well on all subprograms. > > Fine with that: > > Print (This => …); -- Operation > Update (This => …); -- Operation > > But not with that: > > Set_Weight (This => …, Value => …); -- Setter > Weight (This => …); -- Getter > Relation (This => …, Foo => …); -- Expression Personally I wouldn't use named association for the first (dispatching/oblect) parameter. I saw Foo (This => This, ...) too often. And now you'd say Foo.Set_Weight (Value => ...); or Foo.Set_Weight (To => ...); Bar := Foo.Weight; > In any case, if things needs all to be properly named, naming from the > user point of view, ends into bad name from the implementation/self > point of view. So a corresponding renaming could be advisable in > implementation. > > Ex. > > Me : constant Instance_Type renames This; > Me : constant Instance_Type renames On; > Me : constant Instance_Type renames Of; > Me : constant Instance_Type renames From; > > Would be rather pleasant to read and unlikely to make people shout > "Hey, that's too much wordy! That's just bloat!". > > What's your feeling? I think I would say it was bloat. One very quickly gets used to 'This' (especially when using a code generator which always uses 'This' for the object parameter!). But for one of the longer 'functional' names I was mentioning earlier, it certainly could make sense. In my current project I found myself saying type Attribute_Element is new Element with record ... end record; overriding procedure Resolve (A : in out Attribute_Element); overriding procedure Output (A : Attribute_Element; To : Ada.Text_IO.File_Type); because 'This' seemed inappropriate. But it was only a vague feeling.