comp.lang.ada
 help / color / mirror / Atom feed
* exceptions and streams
@ 1998-10-30  0:00 Bernd Ragutt
  1998-10-31  0:00 ` dewarr
  0 siblings, 1 reply; 8+ messages in thread
From: Bernd Ragutt @ 1998-10-30  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2272 bytes --]

Hello,

I tried to write (and read) exception occurrences to a stream;
with the Gnat-Compiler I succeeded,
with the Apex-Compiler I failed.

I think there is a contradiction between RM 11.4.1 (16) and RM 13.13.2 (36).

Any comments?

Bernd Ragutt
----------------------
BerndRagutt@csi.com


--*******************************************************************

Ada95-Code
Exceptions.Exception_Occurrence'Write
 (Stream => As_Excecption_Stream, Item => An_Exception_Occurrence);

GNAT 3.10 / NT
... compiles and executes the code without an error message.

Rational APEX 3.0 AIX
>>> Line 37: Exceptions.Exception_Occurrence'Write (As_Excecption_Stream,
An_Excecption_Occur);
*** Exceptions.Exception_Occurrence'Write must be specified via an attribute
definition

RM 11.4.1 (16)
The implementation of the Write attribute (see 13.13.2) of
Exception_Occurrence shall [!!!] support writing a representation of an
exception occurrence to a stream; the implementation of the Read attribute
of Exception_Occurrence shall support reconstructing an exception occurrence
from a stream (including one written in a different partition).

RM 13.13.2 (2)
For every subtype S of a specific type T, the following attributes [S�Write,
S�Read] are defined.

RM 13.13.2 (36)
The stream-oriented attributes may be specified for any type via an
attribute_definition_clause. All nonlimited types have default
implementations for these operations. An attribute_reference for one of
these attributes is illegal if the type is limited, unless the attribute has
been specified by an attribute_definition_clause. For an
attribute_definition_clause specifying one of these attributes, the subtype
of the Item parameter shall be the base subtype if scalar, and the first
subtype otherwise. The same rule applies to the result of the Input
function.

AI95-00047/03, 96-02-06
...
The wording of 13.13.2(2) is misleading.  Limited types don't have a
default implementation for the Read and Write attributes, per 13.13.2(36).
Clearly 13.13.2(2) should be reworded to make it clear that although
the attributes are in some sense "defined," it is illegal to evaluate
them for limited types unless the user specifies them.
...
--*******************************************************************






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

* Re: exceptions and streams
  1998-10-30  0:00 exceptions and streams Bernd Ragutt
@ 1998-10-31  0:00 ` dewarr
  1998-11-02  0:00   ` Bernd Ragutt
  0 siblings, 1 reply; 8+ messages in thread
From: dewarr @ 1998-10-31  0:00 UTC (permalink / raw)


In article <O8CzNTFB#GA.364@nih2naaa.prod2.compuserve.com>,
  "Bernd Ragutt" <BerndRagutt@csi.com> wrote:
> Hello,
>
> I tried to write (and read) exception occurrences to a stream;
> with the Gnat-Compiler I succeeded,
> with the Apex-Compiler I failed.
>
> I think there is a contradiction between RM 11.4.1 (16) and RM 13.13.2 (36).


I don't know why you think there is a contradiction here. There is most
certainly a requirement that you can write exception occurrences to a stream,
and this is quite an important capability.


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

* Re: exceptions and streams
  1998-10-31  0:00 ` dewarr
@ 1998-11-02  0:00   ` Bernd Ragutt
  1998-11-03  0:00     ` dewar
  0 siblings, 1 reply; 8+ messages in thread
From: Bernd Ragutt @ 1998-11-02  0:00 UTC (permalink / raw)


dewarr@my-dejanews.com wrote:
>I don't know why you think there is a contradiction here. There is most
>certainly a requirement that you can write exception occurrences to a
stream,
>and this is quite an important capability.


RM 11.4.1 (16) requires the existence of a Wrtite atrribute:

    "The implementation of the Write attribute (see 13.13.2) of
    Exception_Occurrence shall support writing a representation of an
    exception occurrence to a stream"


whereas RM 13.13.2 (36) states that the use is illegal for
limited types:

    "All nonlimited types have default implementations
    for these operations [stream-oriented attributes ].
    An attribute_reference for one of these attributes is
    illegal if the type is limited, unless the attribute has
    been specified by an attribute_definition_clause."



Bernd
----------------------
BerndRagutt@csi.com






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

* Re: exceptions and streams
  1998-11-02  0:00   ` Bernd Ragutt
@ 1998-11-03  0:00     ` dewar
  1998-11-03  0:00       ` Tucker Taft
  0 siblings, 1 reply; 8+ messages in thread
From: dewar @ 1998-11-03  0:00 UTC (permalink / raw)


In article <#CgYVsiB#GA.338@nih2naaa.prod2.compuserve.com>,
  "Bernd Ragutt" <BerndRagutt@csi.com> wrote:
> dewarr@my-dejanews.com wrote:
> >I don't know why you think there is a contradiction here. There is most
> >certainly a requirement that you can write exception occurrences to a
> stream,
> >and this is quite an important capability.
>
> RM 11.4.1 (16) requires the existence of a Wrtite atrribute:
>
>     "The implementation of the Write attribute (see 13.13.2) of
>     Exception_Occurrence shall support writing a representation of an
>     exception occurrence to a stream"
>
> whereas RM 13.13.2 (36) states that the use is illegal for
> limited types:
>
>     "All nonlimited types have default implementations
>     for these operations [stream-oriented attributes ].
>     An attribute_reference for one of these attributes is
>     illegal if the type is limited, unless the attribute has
>     been specified by an attribute_definition_clause."


These paragraphs are not in the slightest bit contradictory. They simply
say that the implementor must define (non-default) implementations of the
stream attributes for the type Exception_Occurrence.

In GNAT this is done using the special GNAT pragma Stream_Convert, which
provides a way of implementing these stream attributes without dragging in
all the stream stuff unconditionally.

Again, it is clearly the case, as your quote shows above, that an
implementation is required to provide implementations of stream attributes
for the exception_occurrence type, and of course this is quite fundamental
to the implementation of Annex E for cross-partition exception propagation.
Yes, of course, as your second quote shows, this cannot be the default
implementation, since there isn't one in this case!

Robert Dewar
Ada Core Technologies

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

* Re: exceptions and streams
  1998-11-03  0:00     ` dewar
@ 1998-11-03  0:00       ` Tucker Taft
  0 siblings, 0 replies; 8+ messages in thread
From: Tucker Taft @ 1998-11-03  0:00 UTC (permalink / raw)


dewar@gnat.com wrote:

: ...
: These paragraphs are not in the slightest bit contradictory. They simply
: say that the implementor must define (non-default) implementations of the
: stream attributes for the type Exception_Occurrence.

: In GNAT this is done using the special GNAT pragma Stream_Convert, which
: provides a way of implementing these stream attributes without dragging in
: all the stream stuff unconditionally.

How does your Stream_Convert pragma work?  

Without some kind of special pragma, it is a royal pain to define
the 'Read and 'Write attributes for a limited private type
like Exception_Occurrence.  You must define the attributes visibly
to make it public that they exist, but you must define them
after the limited private type is fully defined because the
definition is considered a representation clause.  This requires
defining multiple Exception_Occurrence-like types, with the visible one in 
Ada.Exceptions inheriting from some limited private type declared
elsewhere which has the 'Read and 'Write defined, using various 
and sundry shenanigans involving nested packages, multiple derivations,
etc.

Some kind of pragma which indicated: "This limited type has
stream attributes" would simplify things dramatically.

And while we are on the topic of the limitness of Exception_Occurrence,
the deferred constant Null_Occurrence is also a royal pain.  During most of
the Ada 9X revision process, Exception_Occurrence was non-limited, and
Null_Occurrence was somewhat useful.  However, now that Exception_Occurrence
is limited, Null_Occurrence is pretty useless, and a pain to implement.

I suppose this is pretty old news for us poor implementors...

: ...
: Robert Dewar
: Ada Core Technologies

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA
An AverStar Company




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

* Exceptions and Streams
@ 2006-05-20 16:03 REH
  2006-05-21 20:40 ` Simon Wright
  0 siblings, 1 reply; 8+ messages in thread
From: REH @ 2006-05-20 16:03 UTC (permalink / raw)


I have a stream class that just writes the stream data to an array.
This is used to marsal parameters to make distributed calls in another
address space.  I have two questions about streams:

1) Does 11.4.1 (16) of the RM (see below) say that I can stream an
exception occurrance to another address space and re-raise it?  Note
that I am not using "partitions" as defined in the  Distributed Ada
Annex, but just separate address spaces.

"The implementation of the Write attribute (see 13.13.2) of
Exception_Occurrence shall support writing a representation of an
exception occurrence to a stream; the implementation of the Read
attribute of Exception_Occurrence shall support reconstructing an
exception occurrence from a stream (including one written in a
different partition)."

2) Is there an easy way to determine the number of elements an object
of a given type will write to a stream before hand?  I need to know how
big to make the array to hold all a procedures parameters, and I don't
want to have to hard-code things like dupe vector sizes.

Much appreciated,

REH




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

* Re: Exceptions and Streams
  2006-05-20 16:03 Exceptions and Streams REH
@ 2006-05-21 20:40 ` Simon Wright
  2006-05-22 15:11   ` REH
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Wright @ 2006-05-21 20:40 UTC (permalink / raw)


"REH" <spamjunk@stny.rr.com> writes:

> 1) Does 11.4.1 (16) of the RM (see below) say that I can stream an
> exception occurrance to another address space and re-raise it?  Note
> that I am not using "partitions" as defined in the Distributed Ada
> Annex, but just separate address spaces.

I have certainly had trouble streaming ::something to do with
exceptions:: with GNAT, but I'm afraid I can't remember what. The
symptom was an endless recursion, I think. Not much help, I know.

One thought: with 'gnatbind -E', GNAT keeps a traceback in the
occurence, but it's in terms of addresses so may not make a lot of
sense in another address space. This can also cause confusion in
exceptions raised during rendezvous if the traceback is reported from
the caller's point of view!

> 2) Is there an easy way to determine the number of elements an
> object of a given type will write to a stream before hand?  I need
> to know how big to make the array to hold all a procedures
> parameters, and I don't want to have to hard-code things like dupe
> vector sizes.

You might find it easier to create a stream which could extend itself
on overflow?

I found 'Max_Size_In_Storage_Elements + 128 worked well (the streamed
version will very likely be smaller than 'Max_Size.., plus something
for the constraints).



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

* Re: Exceptions and Streams
  2006-05-21 20:40 ` Simon Wright
@ 2006-05-22 15:11   ` REH
  0 siblings, 0 replies; 8+ messages in thread
From: REH @ 2006-05-22 15:11 UTC (permalink / raw)



Simon Wright wrote:
> "REH" <spamjunk@stny.rr.com> writes:
>
> I have certainly had trouble streaming ::something to do with
> exceptions:: with GNAT, but I'm afraid I can't remember what. The
> symptom was an endless recursion, I think. Not much help, I know.

Maybe your exception stream code was generating exceptions? :)

>
> One thought: with 'gnatbind -E', GNAT keeps a traceback in the
> occurence, but it's in terms of addresses so may not make a lot of
> sense in another address space. This can also cause confusion in
> exceptions raised during rendezvous if the traceback is reported from
> the caller's point of view!

I am using Green Hills.

> You might find it easier to create a stream which could extend itself
> on overflow?

I can't.  It's in an embedded system that must be certified.  I cannot
use dynamic allocation.

Thanks,

REH




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

end of thread, other threads:[~2006-05-22 15:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-20 16:03 Exceptions and Streams REH
2006-05-21 20:40 ` Simon Wright
2006-05-22 15:11   ` REH
  -- strict thread matches above, loose matches on Subject: below --
1998-10-30  0:00 exceptions and streams Bernd Ragutt
1998-10-31  0:00 ` dewarr
1998-11-02  0:00   ` Bernd Ragutt
1998-11-03  0:00     ` dewar
1998-11-03  0:00       ` Tucker Taft

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