🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.lang.ada
Article #19

Re: Renommage

#19
From: Damien Carbonne
Date: Sun, 26 Aug 2012 15:07
94 lines
4380 bytes
Bonjour,

Cela fait longtemps que je n'ai pas fait d'Ada mais, pour �viter 
d'�crire "with Interfaces" l� o� tu �cris "with A4A", une solution 
consisterait, si je me souviens bien, � remplacer les d�clarations 
"subtype XXX is Interfaces.YYY;" par "type XXX is new is Interfaces.YYY;".

Avec "subtype XXX", on ne fait que d�clarer une sorte d'alias de YYY.
Les fonctions primitives du type XXX sont en fait celles de YYY, qui 
sont (toujours) dans le package Interfaces, qui doit donc �tre import�.

En revanche, avec "type XXX", on cr�e un nouveau type (XXX), qui ram�ne 
avec lui les fonctions primitives de YYY dans le package A4A. Il n'y a 
donc pas besoin de de faire "with Interfaces".

Les sp�cialistes Ada utiliseront un vocabulaire plus pr�cis et exact que 
le mien, mais j'esp�re que ces explications sont compr�hensibles pour toi.

Donc je pense qu'il te suffis d'�crire  ceci :

-- Ada For Automation
with Interfaces;
package A4A is

     type Byte is new Interfaces.Unsigned_8;
     --  8-bit unsigned integer

     type Word is new Interfaces.Unsigned_16;
     -- 16-bit unsigned integer
     ...


Cordialement,
Damien Carbonne



Le 26/08/2012 00:07, slos a �crit :
> Bonjour,
>
> J'apprends Ada et donc j'�cris un petit logiciel.
>
> Dans mon domaine, l'automatisation, les types Byte, Word, DWord sont classiques ainsi que les fonctions SHL, ROL...
>
> J'ai trouv� tout cela dans le paquetage Interfaces et j'ai �crit le paquetage p�re suivant :
>
>
> -- Ada For Automation
> with Interfaces;
> package A4A is
>
>     subtype Byte is Interfaces.Unsigned_8;
>     --  8-bit unsigned integer
>
>     subtype Word is Interfaces.Unsigned_16;
>     -- 16-bit unsigned integer
>
>     subtype DWord is Interfaces.Unsigned_32;
>     -- 32-bit unsigned integer
>
>      function SHL
>       (Value  : DWord;
>        Amount : Natural) return DWord renames Interfaces.Shift_Left;
>     -- Shift Left
>
>     function ROL
>       (Value  : DWord;
>        Amount : Natural) return DWord renames Interfaces.Rotate_Left;
>     -- Rotate Left
>
>     -- Global variables
>
>     Quit : Boolean := False;
>     -- When Quit is set, the application shall exit
>     -- Quit is set either by SIGINT Handler or by GUI
>     -- All tasks should care about Quit and terminate themselves
>
> end A4A;
>
> De ce que je comprends, une ligne comme :
>     subtype Byte is Interfaces.Unsigned_8;
> d�finit une sorte d'alias que je peux utiliser comme bon me semble dans tous les paquetages fils de A4A.
>
> En tous cas cela fonctionne.
>
> Pour mes fonctions SHL et ROL, cela fonctionne �galement, mais � la condition expresse que je with Interfaces dans le paquetage fils, ce que je souhaiterais �viter si possible.
>
> Pourquoi faut-il faire ce with ?
>
> Il y a-t-il une solution triviale � mon besoin ?
>
> Cordialement,
> St�phane
>
Technical Details
Message-ID: <503A3BB6.5040000@free.fr>
Path: arc1-ca.pugleaf.net!m12ni138500bkm.0!nntp.google.com!news2.google.com!r1no23761222qas.0!news-out.google.com!q11ni326774833wiw.1!nntp.google.com!proxad.net!feeder1-2.proxad.net!cleanfeed2-b.proxad.net!nnrp3-1.free.fr!not-for-mail
References: <1eca5845-9df8-4b81-b6e9-da09628761ec@googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 43d0c745c,5c0f9e92502143f6
X-Google-Attributes: gid43d0c745c,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: FRENCH,ASCII
Received: by 10.205.126.4 with SMTP id gu4mr1136428bkc.8.1345993660660;
        Sun, 26 Aug 2012 08:07:40 -0700 (PDT)
Received: by 10.216.233.196 with SMTP id p46mr605304weq.0.1345993655095;
        Sun, 26 Aug 2012 08:07:35 -0700 (PDT)
Path: arc1-ca.pugleaf.net!m12ni138500bkm.0!nntp.google.com!news2.google.com!r1no23761222qas.0!news-out.google.com!q11ni326774833wiw.1!nntp.google.com!proxad.net!feeder1-2.proxad.net!cleanfeed2-b.proxad.net!nnrp3-1.free.fr!not-for-mail
Message-ID: <503A3BB6.5040000@free.fr>
Date: Sun, 26 Aug 2012 17:07:34 +0200
From: Damien Carbonne <damien.carbonne@free.fr>
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0
MIME-Version: 1.0
Newsgroups: fr.comp.lang.ada
To: slos <new.stephane.los@gmail.com>
Subject: Re: Renommage
References: <1eca5845-9df8-4b81-b6e9-da09628761ec@googlegroups.com>
In-Reply-To: <1eca5845-9df8-4b81-b6e9-da09628761ec@googlegroups.com>
Lines: 95
Organization: Guest of ProXad - France
NNTP-Posting-Date: 26 Aug 2012 17:07:35 CEST
NNTP-Posting-Host: 82.247.219.63
X-Trace: 1345993655 news-1.free.fr 21938 82.247.219.63:35474
X-Complaints-To: abuse@proxad.net
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit