Article View: fr.comp.lang.ada
Article #18Renommage
From: slos
Date: Sat, 25 Aug 2012 22:07
Date: Sat, 25 Aug 2012 22:07
60 lines
2810 bytes
2810 bytes
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:
<1eca5845-9df8-4b81-b6e9-da09628761ec@googlegroups.com>Path:
arc1-ca.pugleaf.net!a5ni12203pbv.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 107e1d,5c0f9e92502143f6,start
X-Google-NewGroupId: yes
X-Google-Attributes: gid43d0c745c,domainid0,public,usenet
X-Google-Language: FRENCH,ASCII
Received: by 10.66.85.37 with SMTP id e5mr1351059paz.31.1345932475281;
Sat, 25 Aug 2012 15:07:55 -0700 (PDT)
Path: arc1-ca.pugleaf.net!a5ni12203pbv.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From: slos <new.stephane.los@gmail.com>
Newsgroups: fr.comp.lang.ada
Subject: Renommage
Date: Sat, 25 Aug 2012 15:07:54 -0700 (PDT)
Organization: http://groups.google.com
Lines: 60
Message-ID: <1eca5845-9df8-4b81-b6e9-da09628761ec@googlegroups.com>
NNTP-Posting-Host: 84.103.80.19
Mime-Version: 1.0
X-Trace: posting.google.com 1345932475 13052 127.0.0.1 (25 Aug 2012 22:07:55 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 25 Aug 2012 22:07:55 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=84.103.80.19; posting-account=O3LyFwoAAACc1uh60ZcOUmAGdDmGsEcV
User-Agent: G2/1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable