comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Access to array slices?
Date: Thu, 16 Jan 2003 03:52:48 GMT
Date: 2003-01-16T03:52:48+00:00	[thread overview]
Message-ID: <k0qV9.573899$GR5.367741@rwcrnsc51.ops.asp.att.net> (raw)
In-Reply-To: 5ad0dd8a.0301151818.7931f6a3@posting.google.com

> > You could also use Ada streams.
> Are they buffered or each 'Read and 'Input will result in a syscall?
  Each 'Read does what it needs to do to get the next value of the data
type.  You could define 'Reads that generate random numbers, or successive
letters of the alphabet, or read from a buffer, in which case no syscalls
or IO calls would be needed.  You can define a 'Read that reads an entire
structure with a single IO call, if that's appropriate.  OTOH, if you do
a 'Read on a String, and pass it a stream from
  Ada.Text_IO.Streams.Stream(Ada.Text_IO.Standard_Input)
then it will do one read from standard input per character.

The special thing a 'Read does is that if you don't overide it
  for My_Record'Read use ...
then the compiler will automatically generate a series of 'Reads for
the various components of My_Record, recursively down to the elementary
types, or the pieces you have overriden, whichever comes first.

> >   Do_Something_With_Data( name, value );
> ...
> wanted a function returning an array of access to
> Name_Value_Pair_Type, where name and value would be accesses to
> strings.
  You haven't really said that you need random access to this
array, as opposed to sequential.  If sequential, you can use the
technique in Message-ID: <WOjV9.570671$GR5.362443@rwcrnsc51.ops.asp.att.net>
  If random, you can create an array of
type Name_Value_Pair_Type is record
  Name_First, Name_Last, Value_First, Value_Last : Natural;
end record;
and then do calls like:
  Do_Something_With_Data(Buffer(Name_First(i) .. Name_Last(i)),
                         Buffer(Value_First(i) .. Value_Last(i)));
If that won't do, and you really truly need "is access all String;",
you will have to do data copying.



  reply	other threads:[~2003-01-16  3:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-15  1:17 Access to array slices? Wojtek Narczynski
2003-01-15  3:13 ` tmoran
2003-01-15 16:31   ` sk
2003-01-15 20:48     ` tmoran
2003-01-16  1:00       ` sk
2003-01-16  1:43         ` tmoran
2003-01-19  4:06     ` David Thompson
2003-01-15 14:44 ` Steve
2003-01-16  2:18   ` Wojtek Narczynski
2003-01-16  3:52     ` tmoran [this message]
2003-01-17 18:04     ` Warren W. Gay VE3WWG
2003-01-15 15:06 ` Stephen Leake
2003-01-16  2:02   ` Wojtek Narczynski
2003-01-16 16:18     ` Stephen Leake
2003-01-16 16:48 ` Victor Porton
2003-01-19  4:32 ` sk
2003-01-27  2:59   ` David Thompson
2003-01-24 19:02 ` Wojtek Narczynski
replies disabled

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