comp.lang.ada
 help / color / mirror / Atom feed
* Ada 0x Wish List
@ 2001-02-12  3:25 Peter Richtmyer
  2001-02-12  4:22 ` Jeffrey Carter
                   ` (4 more replies)
  0 siblings, 5 replies; 26+ messages in thread
From: Peter Richtmyer @ 2001-02-12  3:25 UTC (permalink / raw)


Here are a few Ada "improvements" that I would like to see.
First couple are minor. Third is ...?

1) In a Package Spec, it would be nice to be able to declare
variables that are "constants' to other packages. that is, they can
be "read" by other packages, but not written / updated. Code
within the package (and child packages, etc) could update these
variables like any other variables.

e.g.:

   Package A is

       B : constant Integer := 5;   -- normal constant
       C : convar   integer := 8;   -- externally constant, internally
variable
       ...

Note the keyword "convar" is used for lack of a better keyword for now.


2) In a subroutine, would like to be able to declare variables that are
"persistent", like C "static" variables and only used by the one subroutine.
Presently this data must be in the package body (or spec, or some other
package spec), where it is visible and updatable by other routines,
even though it is intended for use by one routine only. (Or is there
another easy way to do this already?)

3) I would like "portable" representation specs. Regardless of the
endian-ness of the machine, would like an option (that is required
to be implemented for all compilers) so we can write rep specs once
and be able to use them on any computer. (Would also like the compilers
to continue to support Ada95 rep specs).

I could think of a number of different ways to specify these, but I am
sure others with compiler-writing experience would have more to say
on what is practical.

So, please go easy on me, but go at it on the ideas....   :-)

For Ada...
Peter





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

* Re: Ada 0x Wish List
  2001-02-12  3:25 Ada 0x Wish List Peter Richtmyer
@ 2001-02-12  4:22 ` Jeffrey Carter
  2001-02-12  7:23   ` Dale Stanbrough
  2001-02-12  7:39 ` Florian Weimer
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 26+ messages in thread
From: Jeffrey Carter @ 2001-02-12  4:22 UTC (permalink / raw)


Peter Richtmyer wrote:
> 
> 1) In a Package Spec, it would be nice to be able to declare
> variables that are "constants' to other packages. that is, they can
> be "read" by other packages, but not written / updated. Code
> within the package (and child packages, etc) could update these
> variables like any other variables.
> 
> e.g.:
> 
>    Package A is
> 
>        B : constant Integer := 5;   -- normal constant
>        C : convar   integer := 8;   -- externally constant, internally
> variable
>        ...
> 
> Note the keyword "convar" is used for lack of a better keyword for now.

This already exists. It is called a function:

B : constant Integer := 5;

function C return Integer;

In the package body:

C_Value : Integer := 8;

function C return Integer is
   -- null;
begin -- C
   return C_Value;
end C;

If this causes timing problems compared to a global variable you can
inline C.

-- 
Jeff Carter
"Perfidious English mouse-dropping hoarders."
Monty Python & the Holy Grail



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

* Re: Ada 0x Wish List
  2001-02-12  4:22 ` Jeffrey Carter
@ 2001-02-12  7:23   ` Dale Stanbrough
  2001-02-12 13:04     ` Preben Randhol
  2001-02-13 16:33     ` Robert Deininger
  0 siblings, 2 replies; 26+ messages in thread
From: Dale Stanbrough @ 2001-02-12  7:23 UTC (permalink / raw)


Jeffrey Carter wrote:

> This already exists. It is called a function:
> 
> B : constant Integer := 5;
> 
> function C return Integer;
> 
> In the package body:
> 
> C_Value : Integer := 8;


...and if you put C_Value in the package declaration's
private section, it'll be visible to child packages.


What -I- would like to see is a named parameter association
that shows you the mode of the parameter....

E.g.
   procedure X (a : in integer; b : in out integer; c : out integer);


   X (a <-  5,
      b <-> y,
      c  -> d);

It would be nice to see in a procedure call exactly which way
the data is going.

Not quite sure how you would represent "access" mode. Maybe
the same as "in out"?


Dale



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

* Re: Ada 0x Wish List
  2001-02-12  3:25 Ada 0x Wish List Peter Richtmyer
  2001-02-12  4:22 ` Jeffrey Carter
@ 2001-02-12  7:39 ` Florian Weimer
  2001-02-12 13:18   ` Steve Folly
  2001-02-12 15:25   ` Arthur Schwarz
  2001-02-12 14:29 ` John English
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 26+ messages in thread
From: Florian Weimer @ 2001-02-12  7:39 UTC (permalink / raw)


"Peter Richtmyer" <pmr@efortress.com> writes:

> 2) In a subroutine, would like to be able to declare variables that
> are "persistent", like C "static" variables and only used by the one
> subroutine.

This feature wouldn't interoperate with tasking, so I think it's a bad
idea.

> 3) I would like "portable" representation specs. Regardless of the
> endian-ness of the machine, would like an option (that is required
> to be implemented for all compilers) so we can write rep specs once
> and be able to use them on any computer. (Would also like the compilers
> to continue to support Ada95 rep specs).

It's hard to imagine that this is really possible.  However, integer
types whose in-memory or stream representation is guaranteed to be
little endian or big endian would certainly be helpful.



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

* Re: Ada 0x Wish List
  2001-02-12  7:23   ` Dale Stanbrough
@ 2001-02-12 13:04     ` Preben Randhol
  2001-02-13 16:33     ` Robert Deininger
  1 sibling, 0 replies; 26+ messages in thread
From: Preben Randhol @ 2001-02-12 13:04 UTC (permalink / raw)


On Mon, 12 Feb 2001 07:23:19 GMT, Dale Stanbrough wrote:
>   procedure X (a : in integer; b : in out integer; c : out integer);
>
>
>   X (a <-  5,
>      b <-> y,
>      c  -> d);

Yes perhaps, but much more work to code and maintain I would think.

-- 
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 �For me, Ada95 puts back the joy in programming.�



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

* Re: Ada 0x Wish List
  2001-02-12  7:39 ` Florian Weimer
@ 2001-02-12 13:18   ` Steve Folly
  2001-02-12 15:25   ` Arthur Schwarz
  1 sibling, 0 replies; 26+ messages in thread
From: Steve Folly @ 2001-02-12 13:18 UTC (permalink / raw)


On 12 Feb 2001 08:39:18 +0100, Florian Weimer <fw@deneb.enyo.de>
wrote:

>"Peter Richtmyer" <pmr@efortress.com> writes:
>
>> 2) In a subroutine, would like to be able to declare variables that
>> are "persistent", like C "static" variables and only used by the one
>> subroutine.
>
>This feature wouldn't interoperate with tasking, so I think it's a bad
>idea.
>

But neither do global variables if you're not careful.  Just because
it's dangerous *if* you're using tasking, doesn't mean you should
prohibit it in the language. The LRM describes several areas
where doing things like that things will make a program erroneous.


There is a way to accomplish static/persistent variables in Ada...

Where, for example, you would want...

function Count return Natural is
   C : static Natural := 0;
begin
  C := C + 1;
  return C;
end;

Can be achieved ....

package Count_Package is 
   function Count return Natural;
end Count_Package

package body Count_Package is
   C : Natural := 0;
   function Count return Natural is
   begin
    C := C + 1;
    return C;
   end;
end Count_Package;

function Count return Natural renames Count_Package.Count;


-- 
SF.   



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

* Re: Ada 0x Wish List
  2001-02-12  3:25 Ada 0x Wish List Peter Richtmyer
  2001-02-12  4:22 ` Jeffrey Carter
  2001-02-12  7:39 ` Florian Weimer
@ 2001-02-12 14:29 ` John English
  2001-02-13  8:31   ` Dr Adrian Wrigley
  2001-02-13 20:46   ` Fraser Wilson
  2001-02-12 16:08 ` Steve Folly
  2001-02-12 18:22 ` (null)
  4 siblings, 2 replies; 26+ messages in thread
From: John English @ 2001-02-12 14:29 UTC (permalink / raw)


Peter Richtmyer wrote:
> 
> Here are a few Ada "improvements" that I would like to see.
> First couple are minor. Third is ...?

Since we're wishing, here are a couple of very minor ones off the top
of my head that relate to Ada.Text_IO, which unfortunately I haven't
got time to draft proper requests for:

1) a Fill_Character parameter in Integer_IO.Put and similar subprograms,
   defaulted to ' ', to make it easy to print "00123" and the like;

2) Capitalised (or Capitalized, if you must ;-) as an alternative
   to Lower_Case and Upper_Case for conversions to strings in
   Enumeration_IO.

-----------------------------------------------------------------
 John English              | mailto:je@brighton.ac.uk
 Senior Lecturer           | http://www.it.bton.ac.uk/staff/je
 Dept. of Computing        | ** NON-PROFIT CD FOR CS STUDENTS **
 University of Brighton    |    -- see http://burks.bton.ac.uk
-----------------------------------------------------------------



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

* Re: Ada 0x Wish List
  2001-02-12  7:39 ` Florian Weimer
  2001-02-12 13:18   ` Steve Folly
@ 2001-02-12 15:25   ` Arthur Schwarz
  1 sibling, 0 replies; 26+ messages in thread
From: Arthur Schwarz @ 2001-02-12 15:25 UTC (permalink / raw)


In article <87u260bba1.fsf@deneb.enyo.de>,
  Florian Weimer <fw@deneb.enyo.de> wrote:
> "Peter Richtmyer" <pmr@efortress.com> writes:
>
> > 2) In a subroutine, would like to be able to declare variables that
> > are "persistent", like C "static" variables and only used by the one
> > subroutine.
>
> This feature wouldn't interoperate with tasking, so I think it's a bad
> idea.

Don't understand this, could you explain? I would think that if the
intent is to have non-reentrant task bodies containing 'static'
variables it would work - with some 'sugar' for synchronization.

art


Sent via Deja.com
http://www.deja.com/



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

* Re: Ada 0x Wish List
  2001-02-12  3:25 Ada 0x Wish List Peter Richtmyer
                   ` (2 preceding siblings ...)
  2001-02-12 14:29 ` John English
@ 2001-02-12 16:08 ` Steve Folly
  2001-02-12 17:53   ` Lao Xiao Hai
  2001-02-12 18:22 ` (null)
  4 siblings, 1 reply; 26+ messages in thread
From: Steve Folly @ 2001-02-12 16:08 UTC (permalink / raw)


Well, let's jump on the bandwagon...  :-)


What about a way of declaring public parts of a package spec
that depend on private parts eg.

package P is
private
    type Derived_Object is new Base.Object with null record;
    function Overridden ( This: Derived_Object ) return Boolean;
public
   Instance : aliased Derived_Object;
end P;

For the users of P, they only need to know about Instance because
it may well be used in a heterogeneous collection where it's only
used via the interface defined in Base.

This would remind users of P that they shouldn't really be
defining their own instances of Derived_Objects.

Thoughts?

-- 
SF.



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

* Re: Ada 0x Wish List
  2001-02-12 16:08 ` Steve Folly
@ 2001-02-12 17:53   ` Lao Xiao Hai
  0 siblings, 0 replies; 26+ messages in thread
From: Lao Xiao Hai @ 2001-02-12 17:53 UTC (permalink / raw)




Steve Folly wrote:

> Well, let's jump on the bandwagon...  :-)
>

OK.   I want a new Ada reserved word, DWIM, for "do what I mean."

Richard Riehle




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

* Re: Ada 0x Wish List
  2001-02-12  3:25 Ada 0x Wish List Peter Richtmyer
                   ` (3 preceding siblings ...)
  2001-02-12 16:08 ` Steve Folly
@ 2001-02-12 18:22 ` (null)
  4 siblings, 0 replies; 26+ messages in thread
From: (null) @ 2001-02-12 18:22 UTC (permalink / raw)


In article <RKIh6.3190$j45.247550@e3500-chi1.usenetserver.com>,
Peter Richtmyer <pmr@efortress.com> wrote:
>
>2) In a subroutine, would like to be able to declare variables that are
>"persistent", like C "static" variables and only used by the one subroutine.
>Presently this data must be in the package body (or spec, or some other
>package spec), where it is visible and updatable by other routines,
>even though it is intended for use by one routine only. (Or is there
>another easy way to do this already?)


Just wrap the subroutine in a sub-package.  It does require a bit
more typing (~7 more lines of code) but my typing is getting better
everyday. :-)


--- foo.ads
package Foo is 
   procedure Do_Stuff;
   function Baz return Integer;
end Foo;


--- foo.adb
with Ada.Text_IO; use Ada.Text_IO;

package body Foo is 
   
   package Bar is 
      function Baz return Integer;
   private
      -- The variable I in this subpackage 
      -- will 'remember' it's value between calls 
      -- to Baz.  
      I: Integer := 0;
   end Bar;
   package body Bar is 
      function Baz return Integer is 
      begin
         I := I+3;
         return I;
      end Baz;
   end Bar;
   function Baz return Integer renames Bar.Baz;
   
   procedure Do_Stuff is 
   begin
      Put_Line("baz returned " & Integer'Image(Baz));
      for I in 1..10 loop
         Put_Line("I is " & Integer'Image(I) 
                  & " and baz returned " & Integer'Image(Baz));
      end loop;
   end run;
end Foo;

      

-- 
=======================================================================
 Life is short.                  | Craig Spannring 
      Bike hard, ski fast.       | cts@internetcds.com
 --------------------------------+------------------------------------



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

* Re: Ada 0x Wish List
  2001-02-12 14:29 ` John English
@ 2001-02-13  8:31   ` Dr Adrian Wrigley
  2001-02-13 20:46   ` Fraser Wilson
  1 sibling, 0 replies; 26+ messages in thread
From: Dr Adrian Wrigley @ 2001-02-13  8:31 UTC (permalink / raw)


John English wrote:
> 2) Capitalised (or Capitalized, if you must ;-) as an alternative
>    to Lower_Case and Upper_Case for conversions to strings in
>    Enumeration_IO.

I'd like to have As_Written (or something), so you get out the
capitalisation that was used in the type declaration. (all the other
conversions could be achieved with a simple function call).
It always seemed messy and redundant to declare a function to achieve
As_Written, which is the current solution.
--
Adrian Wrigley.



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

* Re: Ada 0x Wish List
  2001-02-12  7:23   ` Dale Stanbrough
  2001-02-12 13:04     ` Preben Randhol
@ 2001-02-13 16:33     ` Robert Deininger
  2001-02-13 18:15       ` Keith Thompson
  1 sibling, 1 reply; 26+ messages in thread
From: Robert Deininger @ 2001-02-13 16:33 UTC (permalink / raw)


On Mon, Feb 12, 2001 2:23 AM, Dale Stanbrough <dale@cs.rmit.edu.au> wrote:


>What -I- would like to see is a named parameter association
>that shows you the mode of the parameter....
>
>E.g.
>   procedure X (a : in integer; b : in out integer; c : out integer);
>
>
>   X (a <-  5,
>      b <-> y,
>      c  -> d);
>
>It would be nice to see in a procedure call exactly which way
>the data is going.


Nice idea... But my first gut reaction is that you have your arrows
pointing the wrong way.  Given your procedure declaration, this call is
more intuitive to me:

>   X (a ->  5,
>      b <-> y,
>      c  <- d);

>Not quite sure how you would represent "access" mode. Maybe
>the same as "in out"?
>
>
>Dale
>



---------------------------
Robert Deininger
rdeininger@mindspring.com






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

* Re: Ada 0x Wish List
  2001-02-13 16:33     ` Robert Deininger
@ 2001-02-13 18:15       ` Keith Thompson
  0 siblings, 0 replies; 26+ messages in thread
From: Keith Thompson @ 2001-02-13 18:15 UTC (permalink / raw)


On Mon, Feb 12, 2001 2:23 AM, Dale Stanbrough <dale@cs.rmit.edu.au> wrote:
> What -I- would like to see is a named parameter association
> that shows you the mode of the parameter....
> 
> E.g.
>    procedure X (a : in integer; b : in out integer; c : out integer);
> 
> 
>    X (a <-  5,
>       b <-> y,
>       c  -> d);
> 
> It would be nice to see in a procedure call exactly which way
> the data is going.

I think the 1979 preliminary version of Ada had something like
this; the syntax was

    X ( a :=  5,
        b :=: y,
        c =:  d );

-- 
Keith Thompson (The_Other_Keith) kst@cts.com  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
MAKE MONEY FAST!!  DON'T FEED IT!!



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

* Re: Ada 0x Wish List
  2001-02-12 14:29 ` John English
  2001-02-13  8:31   ` Dr Adrian Wrigley
@ 2001-02-13 20:46   ` Fraser Wilson
  2001-02-13 22:06     ` Larry Hazel
                       ` (3 more replies)
  1 sibling, 4 replies; 26+ messages in thread
From: Fraser Wilson @ 2001-02-13 20:46 UTC (permalink / raw)


In article <3A87F362.3B2F6CEE@bton.ac.uk>, John English  <je@bton.ac.uk> wrote:

>Since we're wishing, here are a couple of very minor ones off the top
>of my head that relate to Ada.Text_IO, which unfortunately I haven't
>got time to draft proper requests for:

[ good ideas snipped ]

How about an image attribute that doesn't put a space in front of positive
integers.  That space has always puzzled me -- it makes output of a series
of positive integers easier, but as special cases go, that's pretty special.

Strikingly minor, but it's always bugged me.

Fraser.



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

* Re: Ada 0x Wish List
  2001-02-13 20:46   ` Fraser Wilson
@ 2001-02-13 22:06     ` Larry Hazel
  2001-02-13 22:45       ` Fraser Wilson
  2001-02-13 23:51     ` Keith Thompson
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 26+ messages in thread
From: Larry Hazel @ 2001-02-13 22:06 UTC (permalink / raw)


Fraser Wilson wrote:
> 
> In article <3A87F362.3B2F6CEE@bton.ac.uk>, John English  <je@bton.ac.uk> wrote:
> 
> >Since we're wishing, here are a couple of very minor ones off the top
> >of my head that relate to Ada.Text_IO, which unfortunately I haven't
> >got time to draft proper requests for:
> 
> [ good ideas snipped ]
> 
> How about an image attribute that doesn't put a space in front of positive
> integers.  That space has always puzzled me -- it makes output of a series
> of positive integers easier, but as special cases go, that's pretty special.
> 
> Strikingly minor, but it's always bugged me.
> 
> Fraser.

A Trim function is a piece of cake.



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

* Re: Ada 0x Wish List
  2001-02-13 22:06     ` Larry Hazel
@ 2001-02-13 22:45       ` Fraser Wilson
  2001-02-13 23:14         ` Larry Hazel
  0 siblings, 1 reply; 26+ messages in thread
From: Fraser Wilson @ 2001-02-13 22:45 UTC (permalink / raw)


In article <3A89AFC9.A218FF2@mindspring.com>,
Larry Hazel  <lhazel@mindspring.com> wrote:

>A Trim function is a piece of cake.

Well, I know, but don't you think that the function I should be
writing is the one that adds a space when I want it?  Indeed,
it wouldn't even be a function.

Sticking space on the front of the images of positive integers
feels arbitrary.

Fraser.
(obviously, this is not a big deal, just something that irritates me)



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

* Re: Ada 0x Wish List
  2001-02-13 22:45       ` Fraser Wilson
@ 2001-02-13 23:14         ` Larry Hazel
  2001-02-13 23:59           ` David C. Hoos, Sr.
  0 siblings, 1 reply; 26+ messages in thread
From: Larry Hazel @ 2001-02-13 23:14 UTC (permalink / raw)




Fraser Wilson wrote:
> 
> In article <3A89AFC9.A218FF2@mindspring.com>,
> Larry Hazel  <lhazel@mindspring.com> wrote:
> 
> >A Trim function is a piece of cake.
> 
> Well, I know, but don't you think that the function I should be
> writing is the one that adds a space when I want it?  Indeed,
> it wouldn't even be a function.
> 
> Sticking space on the front of the images of positive integers
> feels arbitrary.
> 
> Fraser.
> (obviously, this is not a big deal, just something that irritates me)

It's bothered me some in the past also, but I never considered it a big deal
either.  I think it was defined that way for symmetry since negative numbers.  A
place for the sign.



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

* Re: Ada 0x Wish List
  2001-02-13 20:46   ` Fraser Wilson
  2001-02-13 22:06     ` Larry Hazel
@ 2001-02-13 23:51     ` Keith Thompson
  2001-02-14 11:23     ` David C. Hoos, Sr.
  2001-02-17  8:43     ` Dr Adrian Wrigley
  3 siblings, 0 replies; 26+ messages in thread
From: Keith Thompson @ 2001-02-13 23:51 UTC (permalink / raw)


Fraser Wilson <blancolioni@blancolioni.org> writes:
> In article <3A87F362.3B2F6CEE@bton.ac.uk>, John English
> <je@bton.ac.uk> wrote:
> >Since we're wishing, here are a couple of very minor ones off the top
> >of my head that relate to Ada.Text_IO, which unfortunately I haven't
> >got time to draft proper requests for:
> 
> [ good ideas snipped ]
> 
> How about an image attribute that doesn't put a space in front of positive
> integers.  That space has always puzzled me -- it makes output of a series
> of positive integers easier, but as special cases go, that's pretty special.
> 
> Strikingly minor, but it's always bugged me.
> 
> Fraser.

<AOL>Me too.</AOL>

Better yet, how about an image attribute that takes some optional
extra parameters, depending on the type of the prefix: Width, Base,
Fore, Aft, Exp, etc.

The old Aonix, I mean Thomson, I mean Alsys, I mean TeleSoft compiler
provided a set of extended attributes like this (Extended_Image,
Extended_Value, etc.).  Not only were they useful in their own right,
they were used in implementing Integer_IO, Float_IO, etc.  (That was
actually their primary purpose.)  If they're provided in a new
revision of the language, rather than as an implementation-defined
extension, there's no need to use ugly names like Extended_Image.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
MAKE MONEY FAST!!  DON'T FEED IT!!



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

* Re: Ada 0x Wish List
  2001-02-13 23:14         ` Larry Hazel
@ 2001-02-13 23:59           ` David C. Hoos, Sr.
  2001-02-14  1:22             ` Larry Hazel
  0 siblings, 1 reply; 26+ messages in thread
From: David C. Hoos, Sr. @ 2001-02-13 23:59 UTC (permalink / raw)


Not only is a trim function a piece of cake -- its defined by
the language!!
e.g., Ada.Strings.Fixed.Trim

"Larry Hazel" <lhazel@mindspring.com> wrote in message
news:3A89BFD2.29ABF02B@mindspring.com...
>
>
> Fraser Wilson wrote:
> >
> > In article <3A89AFC9.A218FF2@mindspring.com>,
> > Larry Hazel  <lhazel@mindspring.com> wrote:
> >
> > >A Trim function is a piece of cake.
> >
> > Well, I know, but don't you think that the function I should be
> > writing is the one that adds a space when I want it?  Indeed,
> > it wouldn't even be a function.
> >
> > Sticking space on the front of the images of positive integers
> > feels arbitrary.
> >
> > Fraser.
> > (obviously, this is not a big deal, just something that irritates me)
>
> It's bothered me some in the past also, but I never considered it a big
deal
> either.  I think it was defined that way for symmetry since negative
numbers.  A
> place for the sign.





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

* Re: Ada 0x Wish List
  2001-02-13 23:59           ` David C. Hoos, Sr.
@ 2001-02-14  1:22             ` Larry Hazel
  0 siblings, 0 replies; 26+ messages in thread
From: Larry Hazel @ 2001-02-14  1:22 UTC (permalink / raw)


David - Unfortunately, all of my Ada programming experience was the 83 version. 
I've done lots of reading on Ada 95, but that doesn't stick with you like using
something does.  I got totally frustrated and just retired because all they
wanted me to look at was C/C++, SGML, Tcl/Tk, other people's lousy Ada 83, and
writing specs where they didn't know what they wanted.

Sorry for venting.  I'll shut up now.

Larry

"David C. Hoos, Sr." wrote:
> 
> Not only is a trim function a piece of cake -- its defined by
> the language!!
> e.g., Ada.Strings.Fixed.Trim
> 
> "Larry Hazel" <lhazel@mindspring.com> wrote in message
> news:3A89BFD2.29ABF02B@mindspring.com...
> >
> >
> > Fraser Wilson wrote:
> > >
> > > In article <3A89AFC9.A218FF2@mindspring.com>,
> > > Larry Hazel  <lhazel@mindspring.com> wrote:
> > >
> > > >A Trim function is a piece of cake.
> > >
> > > Well, I know, but don't you think that the function I should be
> > > writing is the one that adds a space when I want it?  Indeed,
> > > it wouldn't even be a function.
> > >
> > > Sticking space on the front of the images of positive integers
> > > feels arbitrary.
> > >
> > > Fraser.
> > > (obviously, this is not a big deal, just something that irritates me)
> >
> > It's bothered me some in the past also, but I never considered it a big
> deal
> > either.  I think it was defined that way for symmetry since negative
> numbers.  A
> > place for the sign.



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

* Re: Ada 0x Wish List
  2001-02-13 20:46   ` Fraser Wilson
  2001-02-13 22:06     ` Larry Hazel
  2001-02-13 23:51     ` Keith Thompson
@ 2001-02-14 11:23     ` David C. Hoos, Sr.
  2001-02-15 22:01       ` Georg Bauhaus
  2001-02-17  8:43     ` Dr Adrian Wrigley
  3 siblings, 1 reply; 26+ messages in thread
From: David C. Hoos, Sr. @ 2001-02-14 11:23 UTC (permalink / raw)


Ada.Strings.Fixed.Trim (Integer'Image (<integer-expression>))
will do it without and leading spaces.

"Fraser Wilson" <blancolioni@blancolioni.org> wrote in message
news:t8j79d3epqts89@corp.supernews.com...
> In article <3A87F362.3B2F6CEE@bton.ac.uk>, John English  <je@bton.ac.uk>
wrote:
>
> >Since we're wishing, here are a couple of very minor ones off the top
> >of my head that relate to Ada.Text_IO, which unfortunately I haven't
> >got time to draft proper requests for:
>
> [ good ideas snipped ]
>
> How about an image attribute that doesn't put a space in front of positive
> integers.  That space has always puzzled me -- it makes output of a series
> of positive integers easier, but as special cases go, that's pretty
special.
>
> Strikingly minor, but it's always bugged me.
>
> Fraser.




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

* RE: Ada 0x Wish List
@ 2001-02-15  1:33 Beard, Frank
  0 siblings, 0 replies; 26+ messages in thread
From: Beard, Frank @ 2001-02-15  1:33 UTC (permalink / raw)
  To: 'comp.lang.ada@ada.eu.org'

Yes, but you talking about going from:

   Ada.Text_Io.Put_Line(integer'image(X));

to

  Ada.Text_Io.Put_Line(Ada.Strings.Fixed.Trim(source => integer'image(X),
                                              side   => Ada.Strings.Left));

It's a lot of extra keystrokes just to make something
uglier and less readable, for something that shouldn't
be there in the first place.  I agree with Fraser.

Frank

PS.  And what if you want to take a slice of the image?
     Then it starts getting really ugly.  So, hideous that
     you definitely need a function.

-----Original Message-----
From: David C. Hoos, Sr. [mailto:david.c.hoos.sr@ada95.com]
Sent: Wednesday, February 14, 2001 6:23 AM
To: comp.lang.ada@ada.eu.org
Subject: Re: Ada 0x Wish List


Ada.Strings.Fixed.Trim (Integer'Image (<integer-expression>))
will do it without and leading spaces.

"Fraser Wilson" <blancolioni@blancolioni.org> wrote in message
news:t8j79d3epqts89@corp.supernews.com...
> In article <3A87F362.3B2F6CEE@bton.ac.uk>, John English  <je@bton.ac.uk>
wrote:
>
> >Since we're wishing, here are a couple of very minor ones off the top
> >of my head that relate to Ada.Text_IO, which unfortunately I haven't
> >got time to draft proper requests for:
>
> [ good ideas snipped ]
>
> How about an image attribute that doesn't put a space in front of positive
> integers.  That space has always puzzled me -- it makes output of a series
> of positive integers easier, but as special cases go, that's pretty
special.
>
> Strikingly minor, but it's always bugged me.
>
> Fraser.

_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada




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

* Re: Ada 0x Wish List
  2001-02-14 11:23     ` David C. Hoos, Sr.
@ 2001-02-15 22:01       ` Georg Bauhaus
  2001-02-15 22:14         ` Marin David Condic
  0 siblings, 1 reply; 26+ messages in thread
From: Georg Bauhaus @ 2001-02-15 22:01 UTC (permalink / raw)


David C. Hoos, Sr. (david.c.hoos.sr@ada95.com) wrote:
: Ada.Strings.Fixed.Trim (Integer'Image (<integer-expression>))
: will do it without and leading spaces.

The RM tells me that images of numbers start with a space
or minus sign, and then there is the 'Width attribute so I
can allocate a string big enough for every possible image...
Does someone know some source of information that deals with
the reasons for this choice for 'Image?


Georg Bauhaus



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

* Re: Ada 0x Wish List
  2001-02-15 22:01       ` Georg Bauhaus
@ 2001-02-15 22:14         ` Marin David Condic
  0 siblings, 0 replies; 26+ messages in thread
From: Marin David Condic @ 2001-02-15 22:14 UTC (permalink / raw)


"Georg Bauhaus" <sb463ba@l1-hrz.uni-duisburg.de> wrote in message
news:96hjjl$e1f$2@a1-hrz.uni-duisburg.de...
> David C. Hoos, Sr. (david.c.hoos.sr@ada95.com) wrote:
> : Ada.Strings.Fixed.Trim (Integer'Image (<integer-expression>))
> : will do it without and leading spaces.
>
> The RM tells me that images of numbers start with a space
> or minus sign, and then there is the 'Width attribute so I
> can allocate a string big enough for every possible image...
> Does someone know some source of information that deals with
> the reasons for this choice for 'Image?
>
>
I believe the reasoning behind it was that Ada83 only had strings of fixed
length, so you need to be as predictable as possible WRT the size of some
string conversion. If you're copying to fixed positions in some sort of
output string, you'd like things to align, etc. as well as fitting into a
predictable space. Hence the leading blank or minus. Now that Ada95 provides
unbounded and bounded strings along with all sorts of clever string
manipulation routines, this becomes much less of a concern - but backward
compatibility will keep this around no doubt pretty much forever.

Personally, I'd rather they had just returned the string without the leading
space. 99% of the time, it turns out to be a nuisance that you just work to
get rid of anyway. Having Ada stick that space in there for the 1% of the
time it might be useful just ends up a waste.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/






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

* Re: Ada 0x Wish List
  2001-02-13 20:46   ` Fraser Wilson
                       ` (2 preceding siblings ...)
  2001-02-14 11:23     ` David C. Hoos, Sr.
@ 2001-02-17  8:43     ` Dr Adrian Wrigley
  3 siblings, 0 replies; 26+ messages in thread
From: Dr Adrian Wrigley @ 2001-02-17  8:43 UTC (permalink / raw)


Fraser Wilson wrote:
> How about an image attribute that doesn't put a space in front of positive
> integers.  That space has always puzzled me -- it makes output of a series
> of positive integers easier, but as special cases go, that's pretty special.
> 
> Strikingly minor, but it's always bugged me.

I would like to define my own function to be used by the 'Image attribute:

type Complex is record Real, Imaginary : Float; end record;
function Polar (X : Complex) return String;
for Complex'Image use Polar;

I can't see what implementation problems arise... but I'm no expert.
Maybe it doesn't add enough usefulness to be worth adding though.
It would simplify some of the code I write somewhat, by eliminating
"Image" generic function parameters, added solely for easy debugging.
--
Dr Adrian Wrigley



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

end of thread, other threads:[~2001-02-17  8:43 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-12  3:25 Ada 0x Wish List Peter Richtmyer
2001-02-12  4:22 ` Jeffrey Carter
2001-02-12  7:23   ` Dale Stanbrough
2001-02-12 13:04     ` Preben Randhol
2001-02-13 16:33     ` Robert Deininger
2001-02-13 18:15       ` Keith Thompson
2001-02-12  7:39 ` Florian Weimer
2001-02-12 13:18   ` Steve Folly
2001-02-12 15:25   ` Arthur Schwarz
2001-02-12 14:29 ` John English
2001-02-13  8:31   ` Dr Adrian Wrigley
2001-02-13 20:46   ` Fraser Wilson
2001-02-13 22:06     ` Larry Hazel
2001-02-13 22:45       ` Fraser Wilson
2001-02-13 23:14         ` Larry Hazel
2001-02-13 23:59           ` David C. Hoos, Sr.
2001-02-14  1:22             ` Larry Hazel
2001-02-13 23:51     ` Keith Thompson
2001-02-14 11:23     ` David C. Hoos, Sr.
2001-02-15 22:01       ` Georg Bauhaus
2001-02-15 22:14         ` Marin David Condic
2001-02-17  8:43     ` Dr Adrian Wrigley
2001-02-12 16:08 ` Steve Folly
2001-02-12 17:53   ` Lao Xiao Hai
2001-02-12 18:22 ` (null)
  -- strict thread matches above, loose matches on Subject: below --
2001-02-15  1:33 Beard, Frank

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