comp.lang.ada
 help / color / mirror / Atom feed
* Two 'Output questions
@ 2005-06-30 18:34 Alex R. Mosteo
  2005-06-30 18:58 ` Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alex R. Mosteo @ 2005-06-30 18:34 UTC (permalink / raw)


Hello everybody,

a) Is there any guarantee that 'Output is implemented like...?

    1. Write bounds/Tag
    2. Call to 'Write

I see that the containers provided with gnat gap 2005 have 'write 
redefined but not 'output. While I don't see reasons to use 'output on 
definite types (?), I'm guessing gnat does so because of a). I don't see 
any explanation in the RM, so if I'm right it may be still 
gnat-dependent. I suppose it's handy too to not have to redefine both 
'Output and 'Write when the latter is enough.

b) Is there any way to call the default 'Output attribute once you have 
redefined it? The reason for this is that I have a variant record in 
which just one of the variations needs special treatment... I have ideas 
for workarounds but I'm now just curious.

Thanks!



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

* Re: Two 'Output questions
  2005-06-30 18:34 Two 'Output questions Alex R. Mosteo
@ 2005-06-30 18:58 ` Matthew Heaney
  2005-06-30 19:08 ` Randy Brukardt
  2005-07-01  5:13 ` Simon Wright
  2 siblings, 0 replies; 5+ messages in thread
From: Matthew Heaney @ 2005-06-30 18:58 UTC (permalink / raw)


Alex R. Mosteo wrote:
> Hello everybody,
> 
> a) Is there any guarantee that 'Output is implemented like...?
> 
>    1. Write bounds/Tag
>    2. Call to 'Write
> 
> I see that the containers provided with gnat gap 2005 have 'write 
> redefined but not 'output.

Yes, because there's no dope for the container types (as there would be 
for an unconstrained array, for example), and hence only 'Write need to 
defined.

(But do note that I do use ET'Output in the implementation of the 'Write 
for the indefinite containers, since there you really do need to write 
out dope.)


> While I don't see reasons to use 'output on 
> definite types (?), I'm guessing gnat does so because of a). I don't see 
> any explanation in the RM, so if I'm right it may be still 
> gnat-dependent. I suppose it's handy too to not have to redefine both 
> 'Output and 'Write when the latter is enough.

There's nothing gnat-specific about what I did for the containers.  I'm 
assuming that the default 'Output is implemented in terms of the 'Write 
defined for the type (but I would have to look this up to be sure).



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

* Re: Two 'Output questions
  2005-06-30 18:34 Two 'Output questions Alex R. Mosteo
  2005-06-30 18:58 ` Matthew Heaney
@ 2005-06-30 19:08 ` Randy Brukardt
  2005-07-01  9:09   ` Alex R. Mosteo
  2005-07-01  5:13 ` Simon Wright
  2 siblings, 1 reply; 5+ messages in thread
From: Randy Brukardt @ 2005-06-30 19:08 UTC (permalink / raw)


"Alex R. Mosteo" <devnull@mailinator.com> wrote in message
news:42C43B48.1040802@mailinator.com...
> Hello everybody,
>
> a) Is there any guarantee that 'Output is implemented like...?
>
>     1. Write bounds/Tag
>     2. Call to 'Write

No, because it might be inherited (untagged types only) or redefined. But if
it is not, the default implementation is described by 13.13.2(25-27), and it
says the same as the above.

> I see that the containers provided with gnat gap 2005 have 'write
> redefined but not 'output. While I don't see reasons to use 'output on
> definite types (?), I'm guessing gnat does so because of a). I don't see
> any explanation in the RM, so if I'm right it may be still
> gnat-dependent. I suppose it's handy too to not have to redefine both
> 'Output and 'Write when the latter is enough.

Like I said, see 13.13.2(25-27).

> b) Is there any way to call the default 'Output attribute once you have
> redefined it? The reason for this is that I have a variant record in
> which just one of the variations needs special treatment... I have ideas
> for workarounds but I'm now just curious.

If the type is derived, you can call the operation of the parent type in the
obvious way. You might be able to rename the original operation before the
redefinition (the "squirreling away" type of rename, which certainly works
for overriding). But otherwise it is gone.

                       Randy.






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

* Re: Two 'Output questions
  2005-06-30 18:34 Two 'Output questions Alex R. Mosteo
  2005-06-30 18:58 ` Matthew Heaney
  2005-06-30 19:08 ` Randy Brukardt
@ 2005-07-01  5:13 ` Simon Wright
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Wright @ 2005-07-01  5:13 UTC (permalink / raw)


"Alex R. Mosteo" <devnull@mailinator.com> writes:

> Hello everybody,
>
> a) Is there any guarantee that 'Output is implemented like...?
>
>     1. Write bounds/Tag
>     2. Call to 'Write

As others have said this is OK. But there was a compiler bug (corner
case?) in GNAT 3.16 where the call was to the original 'Write if the
replacement was defined in a private part.



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

* Re: Two 'Output questions
  2005-06-30 19:08 ` Randy Brukardt
@ 2005-07-01  9:09   ` Alex R. Mosteo
  0 siblings, 0 replies; 5+ messages in thread
From: Alex R. Mosteo @ 2005-07-01  9:09 UTC (permalink / raw)


Randy Brukardt wrote:
> "Alex R. Mosteo" <devnull@mailinator.com> wrote in message
> news:42C43B48.1040802@mailinator.com...
> 
>>Hello everybody,
>>
>>a) Is there any guarantee that 'Output is implemented like...?
>>
>>    1. Write bounds/Tag
>>    2. Call to 'Write
> 
> 
> No, because it might be inherited (untagged types only) or redefined. But if
> it is not, the default implementation is described by 13.13.2(25-27), and it
> says the same as the above.

Shame on me, I managed to read two times that section skipping the 
clarification in parentheses.

>>b) Is there any way to call the default 'Output attribute once you have
>>redefined it? The reason for this is that I have a variant record in
>>which just one of the variations needs special treatment... I have ideas
>>for workarounds but I'm now just curious.
> 
> 
> If the type is derived, you can call the operation of the parent type in the
> obvious way. You might be able to rename the original operation before the
> redefinition (the "squirreling away" type of rename, which certainly works
> for overriding). But otherwise it is gone.

As I thought.

Thanks for all the answers.



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

end of thread, other threads:[~2005-07-01  9:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-30 18:34 Two 'Output questions Alex R. Mosteo
2005-06-30 18:58 ` Matthew Heaney
2005-06-30 19:08 ` Randy Brukardt
2005-07-01  9:09   ` Alex R. Mosteo
2005-07-01  5:13 ` Simon Wright

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