comp.lang.ada
 help / color / mirror / Atom feed
* re: renaming types
@ 1987-06-29 13:24 Emery
  0 siblings, 0 replies; 5+ messages in thread
From: Emery @ 1987-06-29 13:24 UTC (permalink / raw)


Besides the two mechanisms you mentioned, there's a third possibility:

  type t is new B.BT;

^ permalink raw reply	[flat|nested] 5+ messages in thread
* re: renaming types
@ 1987-06-29 13:07 Emery
  0 siblings, 0 replies; 5+ messages in thread
From: Emery @ 1987-06-29 13:07 UTC (permalink / raw)


besides the two possible solutions (record with single component, and access),
there's a third possibility:


    package A is
      type T is private
    private
      type T is new B.BT;
    end A;

However, this introduces all the 'overhead' of derived types.  I've often wanted
to complete a private type definition as simply another type, so I think this
is a real problem, since several people (independently) have identified this
shortcoming (see the ACM SIGAda Language Issues WG discussions on this topic).

However, I'm not sure that 'rename' is the right operation.  It seems to me
that 'subtype' may be even better:

  package A is
    type T is private;
  private 
    subtype T is new B.BT;	-- possibly constrained, too!
  end A;

				dave emery
				emery@mitre-bedford.arpa

^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <259745@QZCOM>]
* renaming types
@ 1987-06-26 17:28 "Art Evans"
  0 siblings, 0 replies; 5+ messages in thread
From: "Art Evans" @ 1987-06-26 17:28 UTC (permalink / raw)


Ada does not permit renaming types, the syntax in ARM 8.5 not including
any way to do so.  In general, the rationale for this lack is that a
subtype declaration can be used instead.  However, using a subtype does
not work in all cases.

What I want is something like this:
	with B;				-- Package exporting a type.
	package A is
	   type T is private;		-- A private type.
	   ...
	private
	   type T renames B.BT;		-- Illegal!
	end A;
The renaming declaration is of course illegal.  Moreover, the subtype
mechanism doesn't help, since there's no such thing as a 'private
subtype' declaration and a private type may not be completed with a
subtype.

I see no clean way out of this problem.  The problem can be solved (sort
of) by completing the private type declaration with either of 
	   type T is record
	      F: B.BT;
	   end record;
or
	   type T is access B.BT;
I find both of these to be pretty ugly.  Either affects all code that
uses objects of the type.

Has anyone a better solution?  This matter looks like a candidate for
consideration when Ada is next revised.

Art Evans
Tartan Labs
-------

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1987-06-29 17:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1987-06-29 13:24 renaming types Emery
  -- strict thread matches above, loose matches on Subject: below --
1987-06-29 13:07 Emery
     [not found] <259745@QZCOM>
1987-06-28  0:08 ` "Johan Backlund FOA221"
1987-06-29 17:16   ` Robert Stockton
1987-06-26 17:28 "Art Evans"

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox