comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: 'first of strings returned from a function should be 1?
Date: 1997/07/27
Date: 1997-07-27T00:00:00+00:00	[thread overview]
Message-ID: <01bc9a76$459c2250$4c8371a5@dhoossr> (raw)
In-Reply-To: 5rcaqi$le8$1@goanna.cs.rmit.edu.au


What's wrong with Result_String (Result_String'first) for getting at the
first character of a function result?

From my own experience, I know that it is easy to write a poor function
returning a string result of which the first subscript is not 1, and I
always make the effort to slice (if necessary) the result into the range 1
. result'length, but if you're using
something you can't change, then something like 
New_Result (1 .. Result_String'length) :=
Result_String(Result_String'first .. result_String'first +
Result_String'length -1)
will do the job.

David C. Hoos, Sr.

Dale Stanbrough <dale@goanna.cs.rmit.EDU.AU> wrote in article
<5rcaqi$le8$1@goanna.cs.rmit.edu.au>...
> I suppose the subject line says it all...
> 
> Should the 'first of a string returned from a function be 1?
> 
> (Getting at the first character of such a string requires creating
> a declare block...
> 
> 	declare
> 	   result_String : constant String := Some_Function(Params);
> 	   result_char   : constant Character := Result_String(1);
> 	begin
> 	   ...
> 
> rather than just...
> 
>     if Some_Function(Params)(1) = ...
> 
> if this is the case).
> 
> Dale
> 




  parent reply	other threads:[~1997-07-27  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5rcaqi$le8$1@goanna.cs.rmit.edu.au>
1997-07-26  0:00 ` 'first of strings returned from a function should be 1? Matthew Heaney
1997-07-27  0:00 ` David C. Hoos, Sr. [this message]
1997-07-27  0:00   ` Matthew Heaney
1997-07-28  0:00     ` Robert A Duff
1997-07-29  0:00       ` Anonymous
1997-07-30  0:00         ` Robert A Duff
1997-07-30  0:00       ` Dale Stanbrough
1997-07-27  0:00   ` Simon Wright
1997-07-27  0:00   ` Dale Stanbrough
1997-07-27  0:00     ` Robert A Duff
1997-07-27  0:00       ` Dale Stanbrough
1997-07-27  0:00         ` Matthew Heaney
1997-07-27  0:00 ` Dale Stanbrough
replies disabled

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