comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: [Q] Returning Strings From A Function
Date: 1997/04/05
Date: 1997-04-05T00:00:00+00:00	[thread overview]
Message-ID: <dewar.860265459@merv> (raw)
In-Reply-To: 33468b81.762963@news.demon.co.uk


John McCabe said

<<would be a solution, but I felt sure there was another way to do it so
that I could declare File_Name as an object of a string type e.g.:

type File_Name_Type is new String (1..12);

then use:-

procedure ...

   File_Name : File_Name_Type;

begin
   :
   File_Name := Text_IO.Name (File);
   :
end...

or something similar. But unfortunately this is obviously not possible>>


John, it is still very difficult to understand what you are asking for.
Your code above makes perfect sense if you want File_Name to be 12 characters
long, and of course the assignment will check for 12 characters.

That is apparently NOT what you want, so it is not clear what "this" is
that is "obviously impossible". You need to say what you have in mind.

Do you want to pad the name with blanks to make the length 12? In that
case you could write

   File_name :=
     Ada.Strings.Fixed.Head (Text_IO.Name (File), File_Name'Length));

which seems pretty clear.

If you what you wanted was a string whose maximum length was 12, but to
which smaller strings could be assigned, then Ada.Strings.Bounded is just
the ticket.

It is simply not at all clear to me from the above code what you have in
mind. When you write some perfectly legal, perfectly sensible Ada code,
and say "What I wanted was to do that, but it is impossible, you are
obviously trying to say that you expected some other semantics from the
code than the semantics defined in Ada. That's fine, anyone is allowed
to say such things, and it is often interesting to know what features 
people want, but it is inmpossible to *guess* from this perfectly 
reasonable Ada code what you wanted it to do that was different from
what it actually does in Ada.

So why not try again saying exactly what you have in mind in a clear form.
Don
't try to write Ada, since apparently you think you can't do what you
want to in Ada. Instead describe informally what it is that you think
you cannot do that you would like to do.





  reply	other threads:[~1997-04-05  0:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-04  0:00 [Q] Returning Strings From A Function John McCabe
1997-04-04  0:00 ` Joakim Olsson
1997-04-05  0:00 ` johnherro
1997-04-05  0:00   ` Robert Dewar
1997-04-06  0:00     ` John McCabe
1997-04-06  0:00       ` Robert Dewar
1997-04-05  0:00   ` Mark & Zurima McKinney
1997-04-07  0:00     ` johnherro
1997-04-07  0:00       ` Robert Dewar
1997-04-07  0:00     ` Jon S Anthony
1997-04-07  0:00       ` johnherro
1997-04-08  0:00     ` Jeff Carter
1997-04-09  0:00     ` Looking for an Ada SCIENTIFIC UNITS checking package Ron House
1997-04-05  0:00 ` [Q] Returning Strings From A Function John McCabe
1997-04-05  0:00   ` Robert Dewar [this message]
1997-04-06  0:00     ` John McCabe
1997-04-06  0:00       ` Matthew Heaney
1997-04-06  0:00       ` Robert Dewar
1997-04-06  0:00         ` Nick Roberts
1997-04-07  0:00           ` Robert A Duff
1997-04-08  0:00             ` Nick Roberts
1997-04-07  0:00               ` Matthew Heaney
1997-04-05  0:00   ` Robert A Duff
1997-04-06  0:00 ` John McCabe
replies disabled

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