comp.lang.ada
 help / color / mirror / Atom feed
* Re: 'IMAGE
@ 1992-04-09 20:53 Mark A Biggar
  0 siblings, 0 replies; 5+ messages in thread
From: Mark A Biggar @ 1992-04-09 20:53 UTC (permalink / raw)


In article <1714@nic.cerf.net> sss@nic.cerf.net (Marlene M. Eckert) writes:
>Hello.
>Should the following 'image of an uninitialized
>enumeration type raise CONSTRAINT_ERROR?
>In similar situations our compiler has printed all
>blanks, garbage, and even readable garbage.  Of
>course, the answer is probably in the LRM somewhere...
>---------------------------------------------------------
>with Text_IO; use Text_IO;
>procedure Image is
>type Colors is (Red, Green, Blue);
>My_Color : Colors;  -- Not initialized!
>begin
>  Put_Line(Colors'image(My_Color)); -- Legal?
>end Image;

Using an undefined value like that makes your program erronious and it can do 
anything it damn well pleases, i.e., raise CONSTRAINT_ERROR, Crash the CPU,
Erase your hard disk, even as someone put it in comp.std.c in a similar
discussion cause miniture deamons to blow out your nose!

There has been quite a lot of discussion about this in the Ada9X reviewers
group and Ada9x may well contain something that tightens this up to at
least a bounded error (the program is still in error, it is not required that
the error be detected, but the set of allowed actions is finite and
specified by the standard.)

--
Mark Biggar
mab@wdl1.wdl.loral.com

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

* Re: 'Image
  2014-11-18  0:39                                             ` Randy Brukardt
@ 2014-11-18  8:20                                               ` Björn Lundin
  2014-11-18 22:29                                                 ` 'Image Randy Brukardt
  0 siblings, 1 reply; 5+ messages in thread
From: Björn Lundin @ 2014-11-18  8:20 UTC (permalink / raw)


On 2014-11-18 01:39, Randy Brukardt wrote:
> "Georg Bauhaus" <bauhaus@futureapps.invalid> wrote in message 
> news:m48b93$ke0$1@dont-email.me...
>> On 15.11.14 18:32, Florian Weimer wrote:
> ...
>> Will 'Image be user definable?
> 
> No, not in the Corrigendum (at least).

Is it conceptually the same as T'Image(varible) where T is a scalar type
? That is, it will not apply to records ?

--
Björn


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

* Re: 'Image
  2014-11-18  8:20                                               ` 'Image Björn Lundin
@ 2014-11-18 22:29                                                 ` Randy Brukardt
  0 siblings, 0 replies; 5+ messages in thread
From: Randy Brukardt @ 2014-11-18 22:29 UTC (permalink / raw)


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

"Björn Lundin" <b.f.lundin@gmail.com> wrote in message 
news:m4evds$bru$1@dont-email.me...
> On 2014-11-18 01:39, Randy Brukardt wrote:
>> "Georg Bauhaus" <bauhaus@futureapps.invalid> wrote in message
>> news:m48b93$ke0$1@dont-email.me...
>>> On 15.11.14 18:32, Florian Weimer wrote:
>> ...
>>> Will 'Image be user definable?
>>
>> No, not in the Corrigendum (at least).
>
> Is it conceptually the same as T'Image(varible) where T is a scalar type
> ? That is, it will not apply to records ?

Yes, exactly. Specifically:

 For a prefix X that denotes an object of a scalar type[ (after any implicit 
dereference)], the following attributes are defined:

X'Image  X'Image denotes the result of calling function S'Image with Arg 
being X, where S is the nominal subtype of X.

and similarly for Wide_Image and Wide_Wide_Image.

We've looked at ideas for allowing Image on record types, but it gets messy 
in a hurry, especially if user-defined Image is involved. (User-defined 
'Image only makes sense if there is some additional functionally associated 
with that, as in the stream case; otherwise, just defining a normal function 
is good enough [and fewer characters to write, too].)

                                Randy.


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

* Re: 'Image
  2014-11-19 13:46                                             ` 'Image (was: What exactly is the licensing situation with GNAT?) Brian Drummond
@ 2014-11-19 14:21                                               ` G.B.
  2014-11-20 13:32                                                 ` 'Image Brian Drummond
  0 siblings, 1 reply; 5+ messages in thread
From: G.B. @ 2014-11-19 14:21 UTC (permalink / raw)


On 19.11.14 14:46, Brian Drummond wrote:

> --------------------------------------------------------
> with Ada.Text_IO;
>
> procedure foo is
>      function "&" (l: string; r: natural) return string is
>      begin
>          return  l & character'VAL(r);
>      end "&";
>
>      a: constant string := "abcd";
>      b: constant string := "efgh";
> begin
>      Ada.Text_IO.put_line( "concatenated string is " & a &  -- Line 18
>              character'VAL(16#42#) & b &
>              "  " &  a & 16#42# & b );
> end foo;
> --------------------------------------------------------

This is from GNAT's Spitbol support package:

    function "&" (Num : Integer; Str : String)  return String;
    function "&" (Str : String;  Num : Integer) return String;
    function "&" (Num : Integer; Str : VString) return VString;
    function "&" (Str : VString; Num : Integer) return VString;
    --  In all these concatenation operations, the integer is converted to
    --  its corresponding decimal string form, with no leading blank.




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

* Re: 'Image
  2014-11-19 14:21                                               ` 'Image G.B.
@ 2014-11-20 13:32                                                 ` Brian Drummond
  0 siblings, 0 replies; 5+ messages in thread
From: Brian Drummond @ 2014-11-20 13:32 UTC (permalink / raw)


On Wed, 19 Nov 2014 15:21:19 +0100, G.B. wrote:

> On 19.11.14 14:46, Brian Drummond wrote:
> 
>> --------------------------------------------------------
>> with Ada.Text_IO;
>>
>> procedure foo is
>>      function "&" (l: string; r: natural) return string is begin
>>          return  l & character'VAL(r);
>>      end "&";
...
> This is from GNAT's Spitbol support package:
> 
>     function "&" (Num : Integer; Str : String)  return String;
>     function "&" (Str : String;  Num : Integer) return String;
>     function "&" (Num : Integer; Str : VString) return VString;
>     function "&" (Str : VString; Num : Integer) return VString;
>     --  In all these concatenation operations, the integer is converted
>     to --  its corresponding decimal string form, with no leading blank.

heh, thanks!

- Brian

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

end of thread, other threads:[~2014-11-20 13:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-04-09 20:53 'IMAGE Mark A Biggar
  -- strict thread matches above, loose matches on Subject: below --
2014-11-10  9:30 What exactly is the licensing situation with Gnat? Hubert
2014-11-10 11:09 ` What exactly is the licensing situation with GNAT? Hubert
2014-11-10 11:19   ` Markus Schöpflin
2014-11-10 15:45     ` David Botton
2014-11-11  0:09       ` Hubert
2014-11-11 13:37         ` john
2014-11-11 22:52           ` Hubert
2014-11-11 23:10             ` David Botton
2014-11-11 23:25               ` Alan Jump
2014-11-12  0:50                 ` David Botton
2014-11-12  1:15                   ` Hubert
2014-11-12  1:24                     ` David Botton
2014-11-12  8:12                       ` Simon Wright
2014-11-12  8:35                         ` Hubert
2014-11-12  9:25                           ` Mark Carroll
2014-11-12  9:37                             ` Hubert
2014-11-12 10:31                               ` jm.tarrasa
2014-11-12 10:44                                 ` Hubert
2014-11-12 22:53                                   ` Randy Brukardt
2014-11-12 23:21                                     ` David Botton
2014-11-14  4:51                                       ` Randy Brukardt
2014-11-15 17:32                                         ` Florian Weimer
2014-11-15 19:58                                           ` 'Image (was: What exactly is the licensing situation with GNAT?) Georg Bauhaus
2014-11-18  0:39                                             ` Randy Brukardt
2014-11-18  8:20                                               ` 'Image Björn Lundin
2014-11-18 22:29                                                 ` 'Image Randy Brukardt
2014-11-19 13:46                                             ` 'Image (was: What exactly is the licensing situation with GNAT?) Brian Drummond
2014-11-19 14:21                                               ` 'Image G.B.
2014-11-20 13:32                                                 ` 'Image Brian Drummond

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