comp.lang.ada
 help / color / mirror / Atom feed
* Slices of 2d arrays?
@ 2002-07-24  9:29 Dale Stanbrough
  2002-07-24  9:39 ` Lutz Donnerhacke
  2002-07-24 13:47 ` Peter Hermann
  0 siblings, 2 replies; 14+ messages in thread
From: Dale Stanbrough @ 2002-07-24  9:29 UTC (permalink / raw)


I've always been under the impression that you could take a 
horizontal slice of a 2d array, but for the life of me I can't
find it in the LRM, or get it to work. Does anyone know
whether this exists, or is it just a figment of my overworked 
imagination?

I would like to be able to do...

   type grid is array (1..10, 1..10) of character;

   g : grid;
   ...

   put (g (1, 4..5));

Dale



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

* Re: Slices of 2d arrays?
  2002-07-24  9:29 Slices of 2d arrays? Dale Stanbrough
@ 2002-07-24  9:39 ` Lutz Donnerhacke
  2002-07-24 12:41   ` Pascal Obry
  2002-07-25  0:38   ` Robert Dewar
  2002-07-24 13:47 ` Peter Hermann
  1 sibling, 2 replies; 14+ messages in thread
From: Lutz Donnerhacke @ 2002-07-24  9:39 UTC (permalink / raw)


* Dale Stanbrough wrote:
>I've always been under the impression that you could take a 
>horizontal slice of a 2d array, but for the life of me I can't
>find it in the LRM, or get it to work. Does anyone know
>whether this exists, or is it just a figment of my overworked 
>imagination?

Projections of multidimensional array are not part of the Ada Language.

>I would like to be able to do...
>   type grid is array (1..10, 1..10) of character;

   type grid is array (1..10) of array (1..10) of character;




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

* Re: Slices of 2d arrays?
  2002-07-24  9:39 ` Lutz Donnerhacke
@ 2002-07-24 12:41   ` Pascal Obry
  2002-07-25  0:38   ` Robert Dewar
  1 sibling, 0 replies; 14+ messages in thread
From: Pascal Obry @ 2002-07-24 12:41 UTC (permalink / raw)



lutz@iks-jena.de (Lutz Donnerhacke) writes:

> >I would like to be able to do...
> >   type grid is array (1..10, 1..10) of character;
> 
>    type grid is array (1..10) of array (1..10) of character;

This is not Ada.

     type Str is array (1 .. 10) of Character;
     type Grid is array (1 .. 10) of Str;

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



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

* Re: Slices of 2d arrays?
  2002-07-24  9:29 Slices of 2d arrays? Dale Stanbrough
  2002-07-24  9:39 ` Lutz Donnerhacke
@ 2002-07-24 13:47 ` Peter Hermann
  2002-07-25  0:33   ` Robert Dewar
  1 sibling, 1 reply; 14+ messages in thread
From: Peter Hermann @ 2002-07-24 13:47 UTC (permalink / raw)


Dale Stanbrough <dstanbro@bigpond.net.au> wrote:
> I've always been under the impression that you could take a 
> horizontal slice of a 2d array, but for the life of me I can't
> find it in the LRM, or get it to work. Does anyone know
> whether this exists, or is it just a figment of my overworked 
> imagination?

imagination is always a fine thing

> I would like to be able to do...
>    type grid is array (1..10, 1..10) of character;
>    g : grid;
>    ...
>    put (g (1, 4..5));

Apart from the pragmatic solution (as Pascal Obry already proposed)
for your special case:
    subtype s10 is string(1..10);
    type grid is array(1..10) of s10;
    begin
    g(1)(1) := 'x';

there may be an incentive for Ada2005 thoughts on index ranges
in place of index position. I can not oversee all the implications
which a language lawyer may see.  Important may be the aspect:
   g(1   ,4   ) is of type character
   g(1..1,4..5) is of type grid
   g(1   ,4..5) is of type grid slice?
   g(1..1,4   ) is of type grid slice?
   and the n-dimensional arrays?

No.   Language designers will certainly refusei, IMHO.

-- 
--Peter Hermann(49)0711-685-3611 fax3758 ica2ph@csv.ica.uni-stuttgart.de
--Pfaffenwaldring 27 Raum 114, D-70569 Stuttgart Uni Computeranwendungen
--http://www.csv.ica.uni-stuttgart.de/homes/ph/
--Team Ada: "C'mon people let the world begin" (Paul McCartney)



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

* Re: Slices of 2d arrays?
  2002-07-24 13:47 ` Peter Hermann
@ 2002-07-25  0:33   ` Robert Dewar
  2002-07-25 11:26     ` Slices of 2d arrays? +HPF Peter Hermann
  2002-07-25 20:31     ` Slices of 2d arrays? Robert A Duff
  0 siblings, 2 replies; 14+ messages in thread
From: Robert Dewar @ 2002-07-25  0:33 UTC (permalink / raw)


Peter Hermann <ica2ph@iris16.csv.ica.uni-stuttgart.de> wrote in message news:<ahmb67$jjb$1@news.uni-stuttgart.de>...
>    g(1   ,4   ) is of type character
>    g(1..1,4..5) is of type grid
>    g(1   ,4..5) is of type grid slice?
>    g(1..1,4   ) is of type grid slice?
>    and the n-dimensional arrays?
> 
> No.   Language designers will certainly refusei, IMHO.

It is not hard to work out the semantics of this feature,
just see Algol-68 for inspiration.

However, as soon as you extend slices to >1D arrays, the
feature no longer obeys the "Bauer Principle" which says
that you should not pay overhead for a feature unless
you use it. That's because general slicing results in
non-standard strides, and you have to allow for this
whether or not such slicing is used.



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

* Re: Slices of 2d arrays?
  2002-07-24  9:39 ` Lutz Donnerhacke
  2002-07-24 12:41   ` Pascal Obry
@ 2002-07-25  0:38   ` Robert Dewar
  1 sibling, 0 replies; 14+ messages in thread
From: Robert Dewar @ 2002-07-25  0:38 UTC (permalink / raw)


lutz@iks-jena.de (Lutz Donnerhacke) wrote in message news:<slrnajstf0.ok.lutz@taranis.iks-jena.de>

 type grid is array (1..10) of array (1..10) of character;

This is illegal. Please please if you don't know Ada reliably well,
test out any fragment of code that you
post. One of the things that makes CLA very painful
for those learning Ada is the frequency with which
illegal code fragments are posted.



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

* Re: Slices of 2d arrays? +HPF
  2002-07-25  0:33   ` Robert Dewar
@ 2002-07-25 11:26     ` Peter Hermann
  2002-07-25 13:04       ` Jacob Sparre Andersen
  2002-07-25 20:31     ` Slices of 2d arrays? Robert A Duff
  1 sibling, 1 reply; 14+ messages in thread
From: Peter Hermann @ 2002-07-25 11:26 UTC (permalink / raw)


Robert Dewar <dewar@gnat.com> wrote:
> However, as soon as you extend slices to >1D arrays, the
> feature no longer obeys the "Bauer Principle" which says
> that you should not pay overhead for a feature unless
> you use it. That's because general slicing results in
> non-standard strides, and you have to allow for this
> whether or not such slicing is used.

convincing.

In this context, BTW:
I am unhappy with the fact, that Ada does not gain terrain
in the realm of high performance computing/fortran (HPF).
Those "customers" seem to be entirely satisfied with their
fortran neverending story.

-- 
--Peter Hermann(49)0711-685-3611 fax3758 ica2ph@csv.ica.uni-stuttgart.de
--Pfaffenwaldring 27 Raum 114, D-70569 Stuttgart Uni Computeranwendungen
--http://www.csv.ica.uni-stuttgart.de/homes/ph/
--Team Ada: "C'mon people let the world begin" (Paul McCartney)



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

* Re: Slices of 2d arrays? +HPF
  2002-07-25 11:26     ` Slices of 2d arrays? +HPF Peter Hermann
@ 2002-07-25 13:04       ` Jacob Sparre Andersen
  2002-07-25 15:58         ` Darren New
  0 siblings, 1 reply; 14+ messages in thread
From: Jacob Sparre Andersen @ 2002-07-25 13:04 UTC (permalink / raw)


Peter Hermann wrote:

> I am unhappy with the fact, that Ada does not gain terrain
> in the realm of high performance computing/fortran (HPF).

I agree that it would be nice to see Ada gain more terrain 
in the realm of high performance computing, but the only 
question I have seen from a beginner in Ada this week, was 
in the area of scientific (and most likely also high 
performance) computing, so things are bad everywhere.

 > Those "customers" seem to be entirely satisfied with their
 > fortran neverending story.

I am not sure that they are aware of any better solutions.

One should also consider the cost of converting a piece of 
software which nobody understands why works (both the Danish 
and the joint European weather forecast systems appear to be 
in this category) to anything else. I do not think it is 
realistic to convert this kind of software, but new 
development in the realms of scientific and high performance 
computing is certainly a worthwhile target for expansion of 
the use of Ada.

Jacob
-- 
Do you have a job for a physicist with experience in:

  * Complex systems (mostly turbulence experiments)
  * Geoscience (a bit of oceanography and geology)
  * Programming (mostly in Ada and Pascal)




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

* Re: Slices of 2d arrays? +HPF
  2002-07-25 13:04       ` Jacob Sparre Andersen
@ 2002-07-25 15:58         ` Darren New
  2002-07-28 23:54           ` Robert Dewar
  0 siblings, 1 reply; 14+ messages in thread
From: Darren New @ 2002-07-25 15:58 UTC (permalink / raw)


Jacob Sparre Andersen wrote:
> One should also consider the cost of converting a piece of
> software which nobody understands why works (both the Danish
> and the joint European weather forecast systems appear to be
> in this category) to anything else. I do not think it is
> realistic to convert this kind of software, but new
> development in the realms of scientific and high performance
> computing is certainly a worthwhile target for expansion of
> the use of Ada.

Another part of the problem is again a lack of libraries, I expect. About 15
years ago, I had in my hands an ACM publication which was basically 60 or 70
microfiche foils full of FORTRAN listings of numerical algorithms of all
kinds. Having this sort of resource at hand for FORTRAN and no such resource
at hand for Ada is a compelling argument against switching to Ada, methinks.

Now, if you could get the ACM to compile a similar set of free libraries and
give it away as part of the bonus you get for subscribing to CACM, maybe
you'd have an in. :-)

-- 
Darren New 
San Diego, CA, USA (PST). Cryptokeys on demand.
** http://home.san.rr.com/dnew/DNResume.html **
** http://images.fbrtech.com/dnew/ **

Things to be thankful for, #37:
   No sausage was served at the Last Supper.



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

* Re: Slices of 2d arrays?
  2002-07-25  0:33   ` Robert Dewar
  2002-07-25 11:26     ` Slices of 2d arrays? +HPF Peter Hermann
@ 2002-07-25 20:31     ` Robert A Duff
  2002-07-25 21:09       ` Chad R. Meiners
  1 sibling, 1 reply; 14+ messages in thread
From: Robert A Duff @ 2002-07-25 20:31 UTC (permalink / raw)


dewar@gnat.com (Robert Dewar) writes:

> However, as soon as you extend slices to >1D arrays, the
> feature no longer obeys the "Bauer Principle" which says
> that you should not pay overhead for a feature unless
> you use it.

Who is Bauer?  Can you give a cite for his principle?

I've always tried to obey this principle, but I never knew it had a
name.

- Bob



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

* Re: Slices of 2d arrays?
  2002-07-25 20:31     ` Slices of 2d arrays? Robert A Duff
@ 2002-07-25 21:09       ` Chad R. Meiners
  2002-07-29 13:37         ` Robert Dewar
  0 siblings, 1 reply; 14+ messages in thread
From: Chad R. Meiners @ 2002-07-25 21:09 UTC (permalink / raw)


Yes, please cite this principle.  I would like to see where this principle
was first stated since it does seem to be a rather intuitive principle.

-CRM

"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
news:wccu1mnk0ri.fsf@shell01.TheWorld.com...
> dewar@gnat.com (Robert Dewar) writes:
>
> > However, as soon as you extend slices to >1D arrays, the
> > feature no longer obeys the "Bauer Principle" which says
> > that you should not pay overhead for a feature unless
> > you use it.
>
> Who is Bauer?  Can you give a cite for his principle?
>
> I've always tried to obey this principle, but I never knew it had a
> name.
>
> - Bob





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

* Re: Slices of 2d arrays? +HPF
  2002-07-25 15:58         ` Darren New
@ 2002-07-28 23:54           ` Robert Dewar
  0 siblings, 0 replies; 14+ messages in thread
From: Robert Dewar @ 2002-07-28 23:54 UTC (permalink / raw)


Darren New <dnew@san.rr.com> wrote in message news:<3D402036.171C354B@san.rr.com>...

> Another part of the problem is again a lack of libraries, I expect. About 15
> years ago, I had in my hands an ACM publication which was basically 60 or 70
> microfiche foils full of FORTRAN listings of numerical algorithms of all
> kinds. Having this sort of resource at hand for FORTRAN and no such resource
> at hand for Ada is a compelling argument against switching to Ada, methinks.

Doesn't compell me! There is no problem in calling these standard Fortran
library units from an Ada program when this makes sense.



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

* Re: Slices of 2d arrays?
  2002-07-25 21:09       ` Chad R. Meiners
@ 2002-07-29 13:37         ` Robert Dewar
  2002-07-29 14:08           ` Steffen Huber
  0 siblings, 1 reply; 14+ messages in thread
From: Robert Dewar @ 2002-07-29 13:37 UTC (permalink / raw)


"Chad R. Meiners" <crmeiners@hotmail.com> wrote in message news:<ahppfr$j53$1@msunews.cl.msu.edu>...
> Yes, please cite this principle.  I would like to see where this principle
> was first stated since it does seem to be a rather intuitive principle.

Prof Dr Fritz L. Bauer

An important member of WG2.1, the group that developed Algol-68. If you
do a search for Bauer Algol-68 you will get a lot of hits (the top ones
are all in German).

He formulated this principle in the 60's. I do not have the exact reference,
I will track it down. It was one of the guiding principles in the Algol-68
design, and whenever we violated it, we were sure to carefully understand
the trade-offs.



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

* Re: Slices of 2d arrays?
  2002-07-29 13:37         ` Robert Dewar
@ 2002-07-29 14:08           ` Steffen Huber
  0 siblings, 0 replies; 14+ messages in thread
From: Steffen Huber @ 2002-07-29 14:08 UTC (permalink / raw)


Robert Dewar wrote:
[snip]
> Prof Dr Fritz L. Bauer

...who is also, IIRC, the "Inventor" of the term "Software Engineering".
Somewhere during a discussion about the software crisis he said
"What we need is Software Engineering", meaning the application of
engineering principles to the process of creating software.

Steffen

-- 
steffen.huber@gmx.de               steffen@huber-net.de
GCC for RISC OS  - http://www.arcsite.de/hp/gcc/
Private homepage - http://www.huber-net.de/



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

end of thread, other threads:[~2002-07-29 14:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-24  9:29 Slices of 2d arrays? Dale Stanbrough
2002-07-24  9:39 ` Lutz Donnerhacke
2002-07-24 12:41   ` Pascal Obry
2002-07-25  0:38   ` Robert Dewar
2002-07-24 13:47 ` Peter Hermann
2002-07-25  0:33   ` Robert Dewar
2002-07-25 11:26     ` Slices of 2d arrays? +HPF Peter Hermann
2002-07-25 13:04       ` Jacob Sparre Andersen
2002-07-25 15:58         ` Darren New
2002-07-28 23:54           ` Robert Dewar
2002-07-25 20:31     ` Slices of 2d arrays? Robert A Duff
2002-07-25 21:09       ` Chad R. Meiners
2002-07-29 13:37         ` Robert Dewar
2002-07-29 14:08           ` Steffen Huber

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