comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Any easy/build-in construct to extract submatrices from larger matrix?
Date: Fri, 6 Jul 2012 18:47:22 -0500
Date: 2012-07-06T18:47:22-05:00	[thread overview]
Message-ID: <jt7teg$c97$1@munin.nbi.dk> (raw)
In-Reply-To: 3u95tkqb1l8t$.t7lzt049tvq8.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:3u95tkqb1l8t$.t7lzt049tvq8.dlg@40tude.net...
> On Wed, 4 Jul 2012 20:33:32 -0500, Randy Brukardt wrote:
...
>> This is distributed overhead, which programs would  have to pay whether 
>> or
>> not they used any 2-d slices. It would make all array parameters more
>> expensive.
>
> By-value passed slices should impose no overhead.

Sure. but they're not a general solution. That is, they don't work for 
slices of arrays of by-reference types, which a compiler would have to 
support. Since this is not an important feature for our customers, we would 
not want to support more than one implementation of it. And even if we did, 
there would still be distributed overhead in any parameter type that could 
not be passed by copy (which is most of them, if new types are always 
controlled, as I recommend in most cases).


>>> Slices should be first class, that would remove the burden of
>>> implementation from compiler writers. The rest is just same problematic 
>>> as
>>> with referencing single array/container element. There is no big
>>> difference for one element or a set of elements.
>>
>> That's not really possible so long as slices are what C calls l-values. 
>> The
>> problem is passing slices as parameters and allowing assignments into 
>> them.
>
> Why does this work for array elements then?

(There is a "not" missing in what I wrote above.)

It works for array elements only because they are contiguous and passing a 
single address is sufficient to represent the slice, as it is for any array 
objects. (Recall that we're talking about *constrained* array parameters 
here.)

...
...
>> Value semantics only works for a small subset of types (for most 
>> compilers,
>> that subset is elementary types). Moreover, Ada has many types for which
>> value semantics is not allowed (immutably limited types and tagged types 
>> are
>> the best known). So this would be a feature of fairly limited value.
>
> I don't see big problem here. Arrays of referential elements are most
> likely internally are array of pointers. Slices of such arrays are again
> arrays of pointers. There is nothing difficult about that, except that
> usual problems that a reference shall not outlive the object.

That's not how our compiler handles by-reference types. They live like other 
objects in place, but are always *passed* by reference (there is no 
requirement to *allocate* them by reference). There are some cases where we 
use implicit pointers (such as in shared generics), but that's unusual for 
Ada compilers. I don't think GNAT ever uses them.

                            Randy.







  reply	other threads:[~2012-07-06 23:47 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-24  8:05 Any easy/build-in construct to extract submatrices from larger matrix? Nasser M. Abbasi
2012-06-24  8:24 ` Dmitry A. Kazakov
2012-06-24  8:55   ` Nasser M. Abbasi
2012-06-24 11:10     ` Dmitry A. Kazakov
2012-06-24 12:16       ` Nasser M. Abbasi
2012-06-24 16:11         ` Dmitry A. Kazakov
2012-06-24 17:14           ` Nasser M. Abbasi
2012-06-24 18:33             ` Dmitry A. Kazakov
2012-06-25  5:44             ` J-P. Rosen
2012-06-25  6:32               ` Nasser M. Abbasi
2012-06-25  7:54                 ` J-P. Rosen
2012-06-25  8:20                   ` Dmitry A. Kazakov
2012-06-25 14:21                   ` Nasser M. Abbasi
2012-06-25  8:36                 ` Georg Bauhaus
2012-06-25 13:17                   ` Nasser M. Abbasi
2012-06-26 11:44                     ` Georg Bauhaus
2012-06-25 16:49                 ` Pascal Obry
2012-06-25 17:36                   ` Nasser M. Abbasi
2012-06-25 18:49                     ` stefan-lucks
2012-06-26  4:41                       ` Nasser M. Abbasi
2012-06-26  7:15                 ` Jacob Sparre Andersen
2012-06-26  9:51                   ` Nasser M. Abbasi
2012-06-25  9:33               ` Simon Wright
2012-06-26  2:48 ` Jerry
2012-06-26  4:19   ` Nasser M. Abbasi
2012-06-26  7:06   ` Nasser M. Abbasi
2012-06-26 12:54     ` Robert A Duff
2012-06-26 15:19       ` Adam Beneschan
2012-06-26 21:14         ` Robert A Duff
2012-06-27 23:42     ` Shark8
2012-06-26  7:10   ` Dmitry A. Kazakov
2012-06-26 15:06   ` Adam Beneschan
2012-06-26 21:19     ` Robert A Duff
2012-06-26 21:40       ` Adam Beneschan
2012-07-03  4:22         ` Randy Brukardt
2012-07-03  8:37           ` Dmitry A. Kazakov
2012-07-05  1:33             ` Randy Brukardt
2012-07-05  7:08               ` Dmitry A. Kazakov
2012-07-06 23:47                 ` Randy Brukardt [this message]
2012-07-07  8:22                   ` Dmitry A. Kazakov
2012-07-05 18:56               ` Adam Beneschan
replies disabled

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