🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.ada
Article #872

Re: Ada language problem/question

#872
From: esmith
Date: Wed, 09 Jul 1986 15:18
29 lines
1640 bytes
Your compiler does the right thing.  A subtype declaration does not
derive any operations (read "enumeration literals").  If you change
the assignment in package B to y := st_2 or y := B.st_2 you will see
that the literals aren't locally defined in B, therefore they can't be
made available anywhere else through the use of a "with B".

Note that if you must do this, and a derived type won't do what you want,
you can use renaming declarations:

  package fruit_mgr is
    type fruit is (apple, banana, cherry);
  end fruit_mgt;

  with fruit_mgr;
  package pseudo_fruit_mgr is
    subtype fruit is fruit_mgr.fruit;
    function apple return fruit renames fruit_mgr.fruit;
    function banana return fruit renames fruit_mgr.banana;
    function cherry return fruit renames fruit_mgr.cherry;
  end pseude_fruit_mgr;

You can, of course, just declare constants of type pseudo_fruit_mgr.fruit
instead:

    apple: constant fruit := fruit_mgr.apple;

but this method does not preserve the semantics of enumeration literals,
particularly with reference to overloading.
Technical Details
Message-ID: <38000031@gypsy.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!seismo!caip!princeton!siemens!gypsy!esmith
References: <91@houligan.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!seismo!caip!princeton!siemens!gypsy!esmith
From: esmith@gypsy.UUCP
Newsgroups: net.lang.ada
Subject: Re: Ada language problem/question
Message-ID: <38000031@gypsy.UUCP>
Date: Wed, 9-Jul-86 11:18:00 EDT
Article-I.D.: gypsy.38000031
Posted: Wed Jul  9 11:18:00 1986
Date-Received: Fri, 11-Jul-86 21:57:34 EDT
References: <91@houligan.UUCP>
Lines: 29
Nf-ID: #R:houligan:-9100:gypsy:38000031:000:1065
Nf-From: gypsy!esmith    Jul  9 11:18:00 1986