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,FREEMAIL_FROM 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.241.37 with SMTP id wf5mr3918572pbc.4.1328886440984; Fri, 10 Feb 2012 07:07:20 -0800 (PST) Path: wr5ni8981pbc.0!nntp.google.com!news2.google.com!goblin3!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Convention for naming of packages Date: Fri, 10 Feb 2012 16:07:19 +0100 Organization: Ada @ Home Message-ID: References: NNTP-Posting-Host: 3Dnc1BsVLavoSxHR9zQiRQ.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/11.61 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Date: 2012-02-10T16:07:19+01:00 List-Id: Le Thu, 09 Feb 2012 22:39:51 +0100, Jeffrey Carter = a =C3=A9crit: > The plural is used a lot in the standard library (Ada.Strings, = > Ada.Containers). I had this in minde, though this was not common enough. After I read you= = yesterday, I changed my mind and feel at rest with the plural now. > The present participle is sometimes useful (Widget_Handling, = > Town_Marshalling). Noted. > I've also seen instances where _Management was meaningful and solved = > this kind of conflict. Idem. Will go for plural so. Now I am seeking for something even more difficult: conflict between = function names and object names. This can be solved using prefixed = notation, but I want to avoid it to not bloat source too much. A too lon= g = full name is not readable and can just make people think Ada is = definitively over=E2=80=91wordy (as J.P. Rosen explained in a paper, peo= ple tends = to keep in mind bad points first about Ada). To be honest, this conflict typically occurs when I want a local constan= t = to hold the value returned by a function, to avoid invocation of this = function multiple time. That's a common idiom, although I feel this may = be = based on wrong assumptions about compiler efficiency, while not the only= = one reason. I feel it's often good to substitute a single name to a whol= e = expression. A quick example. function Object (Param : Param_Type) return Object_Type; procedure Scan is Object : constant Object_Type :=3D Object (Param); -- Or alternatively: =E2=80=9CObject : constant Object_Type renam= es Object = (Param);=E2=80=9D begin for I in Index_Type loop ... Object ... -- Instead of ... Object (Param) ... end loop; end; Object conflict with Object. I can use prefix and have Object : constant Object_Type :=3D Repository_Package.Object (Param)= ; instead of Object : constant Object_Type :=3D Object (Param); But I would like to avoid the Repository_Package prefix for the previous= ly = given reasons. I remember I knew a language (cannot remember which one) = = which was fine with this, as this language considered Object to not = already be defined when it was encountering Object (Param). Thus Object : constant Object_Type :=3D Object (Param); was defining Object with an initial value and right after hiding the = Object function. The problem does not occurs with either record type (as members are all = = prefixed) and subprogram parameters, as these are assigned by the caller= . = The latter may be an idea, so this could be a solution: procedure Scan is procedure Scan (Object : in Object_Type) is begin for I in Index_Type loop ... Object ... -- Instead of ... Object (Param) ... end loop; end, begin Scan (Object (Param)); end; I don't know what to think about it, looks too much like a big trick in = = Ada source and this is even much longer than using the previous prefix = notation along with a local constant. What do you feel about this? -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univers= ity