comp.lang.ada
 help / color / mirror / Atom feed
* Renaming exceptions in private section?
@ 1996-04-18  0:00 Dale Stanbrough
  1996-04-22  0:00 ` Michel Gauthier
  0 siblings, 1 reply; 2+ messages in thread
From: Dale Stanbrough @ 1996-04-18  0:00 UTC (permalink / raw)


Looking through some data structure packages I noted
that many package specs required the use of an
instantiated generic, and would rename some of it's
exceptions.

e.g.

	with some_generic_package;

	package a is

		package b is new some_generic_package(some_type);
	
		overflow :exception renames b.overflow;
	
		....

In the case where no other resources from the generic are being
used by clients of package a, it would be better if the generic
were instantiated in the private section, and the exception
renamed there. However this doesn't seemed to be allowed.

When I tried...

	package fred is
	
		a: exception;
		
	private
		b: exception;
		a: exception renames b;
	end;
	
...Gnat complained that

	"a" conflicts with declaration at line 3
	
Is it possible to rename an exception in the private section
- sort of a deferred exception (similar to deferred constants)?

Dale




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

* Re: Renaming exceptions in private section?
  1996-04-18  0:00 Renaming exceptions in private section? Dale Stanbrough
@ 1996-04-22  0:00 ` Michel Gauthier
  0 siblings, 0 replies; 2+ messages in thread
From: Michel Gauthier @ 1996-04-22  0:00 UTC (permalink / raw)


In article <4l52fh$ivr@goanna.cs.rmit.edu.au>, Dale Stanbrough
<dale@goanna.cs.rmit.EDU.AU> wrote:

>>  [...]
>>  When I tried...
>>  
>>          package fred is
>>          
>>                  a: exception;
>>                  
>>          private
>>                  b: exception;
>>                  a: exception renames b;
>>          end;
>>          
>>  ....Gnat complained that
>>  
>>          "a" conflicts with declaration at line 3
>>          
>>  Is it possible to rename an exception in the private section
>>  - sort of a deferred exception (similar to deferred constants)?

Strictly speaking, no, but a good trick could be to use
Exception_Id~entities (see for instance my old paper 
in Ada Letters).

with Ada . Exceptions ;  
package fred is
       a: constant Ada . Exceptions . Exception_Id ;
       ...
private
        b: exception;
        a: constant Ada . Exceptions . Exception_Id := B ' Identity ;
end;

----------          ----------          ----------          ---------- 
Michel Gauthier / Laboratoire d'informatique
123 avenue Albert Thomas / F-87060 Limoges
telephone +33 () 55457335 [or ~ 7232]
fax +33 ()  55457315  [or ~7201]
----------          ----------          ----------          ----------
La grande equation de la fin du siecle : windows-X = Mac-Y
The main end-of-century equation : windows-X = Mac-Y
----------          ----------          ----------          ----------
Si l'an 2000 est pour vous un mysticisme stupide, utilisez la base 9
If you feel year 2000 a stupid mystic craze, use numeration base 9
----------          ----------          ----------          ----------




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

end of thread, other threads:[~1996-04-22  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-18  0:00 Renaming exceptions in private section? Dale Stanbrough
1996-04-22  0:00 ` Michel Gauthier

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