comp.lang.ada
 help / color / mirror / Atom feed
* Re: String to Integer conversion?
  1998-07-31  0:00   ` Matthew Heaney
@ 1998-07-30  0:00     ` nabbasi
  1998-08-01  0:00     ` Robert Dewar
  1 sibling, 0 replies; 11+ messages in thread
From: nabbasi @ 1998-07-30  0:00 UTC (permalink / raw)


In article <m37m0vvubh.fsf@mheaney.ni.net>, Matthew says...
 
>As an alternative solution to the problem of converting a string to an
>integer, you can use the attribute Integer'Value.
>

I love those Ada attributes. very usefull and easy to use. whoever
came up with those attribute needs a reward of some sort.

Nasser




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

* Re: String to Integer conversion?
  1998-07-31  0:00 ` String to Integer conversion? Matthew Heaney
@ 1998-07-31  0:00   ` daniel gaudry
  0 siblings, 0 replies; 11+ messages in thread
From: daniel gaudry @ 1998-07-31  0:00 UTC (permalink / raw)


Yes there is one of the get statement can use a string as in parameter
get(string=> your_string,=>item => your item,=> ..);
the same thing does exist for float, enumerations  ....






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

* Re: String to Integer conversion?
       [not found] <c1.2b8.2Lzh62$03A@zesi.ruhr.de>
@ 1998-07-31  0:00 ` Matthew Heaney
  1998-07-31  0:00   ` daniel gaudry
       [not found] ` <6ndi5d$uj3@gcsin3.geccs.gecm.com>
  1 sibling, 1 reply; 11+ messages in thread
From: Matthew Heaney @ 1998-07-31  0:00 UTC (permalink / raw)


haug@localhost.ruhr.de (Haug Buerger) writes:

>    i can't believe it, but i found no function in the Standard
> libs to convert a string, "123", to Integer(123). I found some
> GNAT internal functions that do it, but isn't there a standard
> way to do it?

Use the attribute Integer'Value.

declare 
   I : constant Integer := Integer'Value ("123");
begin


QED




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

* Re: String to Integer conversion?
       [not found] ` <6ndi5d$uj3@gcsin3.geccs.gecm.com>
@ 1998-07-31  0:00   ` Matthew Heaney
  1998-07-30  0:00     ` nabbasi
  1998-08-01  0:00     ` Robert Dewar
  0 siblings, 2 replies; 11+ messages in thread
From: Matthew Heaney @ 1998-07-31  0:00 UTC (permalink / raw)


John McCabe <john@assen.demon.co.uk> writes:

> Integer_IO provides versions of the Get and Put routines where the first 
> parameter is a string, so you need to instantiate Integer_IO for your 
> Integer Type ( or use Ada.Integer_Text_IO for the pre-defined type 
> Integer) then call the Get operation e.g.

In Ada 95 you don't need to instantiate Integer_IO on type Integer.  An
instantiation of Integer_IO, called Ada.Integer_Text_IO, comes
predefined as part of the standard library.

Ditto for type Float; there's a predefined instantiation called
Float_Text_IO.

Q for language lawyers: why no predefined instantiation of Fixed_IO for
type Duration?

As an alternative solution to the problem of converting a string to an
integer, you can use the attribute Integer'Value.





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

* Re: String to Integer conversion?
  1998-07-31  0:00   ` Matthew Heaney
  1998-07-30  0:00     ` nabbasi
@ 1998-08-01  0:00     ` Robert Dewar
  1998-08-01  0:00       ` Matthew Heaney
  1 sibling, 1 reply; 11+ messages in thread
From: Robert Dewar @ 1998-08-01  0:00 UTC (permalink / raw)


<<Q for language lawyers: why no predefined instantiation of Fixed_IO for
type Duration?
>>

Because these predefined instantiations are intended for simple student
use, and one assumes that it is unlikely that students will be mucking
with duration values!





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

* Re: String to Integer conversion?
  1998-08-01  0:00     ` Robert Dewar
@ 1998-08-01  0:00       ` Matthew Heaney
  1998-08-02  0:00         ` Robert Dewar
  0 siblings, 1 reply; 11+ messages in thread
From: Matthew Heaney @ 1998-08-01  0:00 UTC (permalink / raw)


dewar@merv.cs.nyu.edu (Robert Dewar) writes:

> <<Q for language lawyers: why no predefined instantiation of Fixed_IO for
> type Duration?
> >>
> 
> Because these predefined instantiations are intended for simple student
> use, and one assumes that it is unlikely that students will be mucking
> with duration values!

Fair enough, but it would have been helpful to have a predefined
instantiation, so that everyone (ie working programmers like me) can
share the same one.





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

* Re: String to Integer conversion?
  1998-08-01  0:00       ` Matthew Heaney
@ 1998-08-02  0:00         ` Robert Dewar
  1998-08-02  0:00           ` Matthew Heaney
  0 siblings, 1 reply; 11+ messages in thread
From: Robert Dewar @ 1998-08-02  0:00 UTC (permalink / raw)


<<Fair enough, but it would have been helpful to have a predefined
instantiation, so that everyone (ie working programmers like me) can
share the same one.
>>

Why?





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

* Re: String to Integer conversion?
  1998-08-02  0:00         ` Robert Dewar
@ 1998-08-02  0:00           ` Matthew Heaney
  1998-08-04  0:00             ` Robert Dewar
  0 siblings, 1 reply; 11+ messages in thread
From: Matthew Heaney @ 1998-08-02  0:00 UTC (permalink / raw)


dewar@merv.cs.nyu.edu (Robert Dewar) writes:

> <<Fair enough, but it would have been helpful to have a predefined
> instantiation, so that everyone (ie working programmers like me) can
> share the same one.
> >>
> 
> Why?

Perhaps this is just an Ada 83 problem, because that version of Ada
didn't have the attributes Duration'Image and Duration'Value.  Without
those attributes, there is a real need for a Duration_IO.

It may indeed be the case the neophyte programmers in a class-room
setting don't require the use of Duration.  But they can't avoid using a
delay statement forever.

In my experience, the need for manipulation of Duration strings is
_very_ common.  One thing I do quite often is to translate an
environment variable that represents the value of an entry call delay,
for example, or a timeout for I/O to an external device.  This way I can
tune delays and timeouts without recompiling anything.





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

* Re: String to Integer conversion?
  1998-08-02  0:00           ` Matthew Heaney
@ 1998-08-04  0:00             ` Robert Dewar
  1998-08-04  0:00               ` Matthew Heaney
  0 siblings, 1 reply; 11+ messages in thread
From: Robert Dewar @ 1998-08-04  0:00 UTC (permalink / raw)


Matthew says

<<In my experience, the need for manipulation of Duration strings is
_very_ common.  One thing I do quite often is to translate an
environment variable that represents the value of an entry call delay,
for example, or a timeout for I/O to an external device.  This way I can
tune delays and timeouts without recompiling anything.
>>

Sure, no one contests that it is often useful to do I/O on Duration values,
but that observation is not enough to justify putting a predefined package
for this purpose. It is also useful to sort integers, or do a binary
search, or or or or or ..... but we do not expect there to be predefined
packages for all possible useful things in advance





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

* Re: String to Integer conversion?
  1998-08-04  0:00             ` Robert Dewar
@ 1998-08-04  0:00               ` Matthew Heaney
  1998-08-04  0:00                 ` David C. Hoos, Sr.
  0 siblings, 1 reply; 11+ messages in thread
From: Matthew Heaney @ 1998-08-04  0:00 UTC (permalink / raw)


dewar@merv.cs.nyu.edu (Robert Dewar) writes:

> Sure, no one contests that it is often useful to do I/O on Duration values,
> but that observation is not enough to justify putting a predefined package
> for this purpose. It is also useful to sort integers, or do a binary
> search, or or or or or ..... but we do not expect there to be predefined
> packages for all possible useful things in advance

Agreed, but here's another argument.  My _expectation_ was that there
would be a predefined instantiation for type Duration, because other
types in Standard had predefined instantations.  If it's natural for me
to expect something to be there, then maybe it should be there.  Maybe.





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

* Re: String to Integer conversion?
  1998-08-04  0:00               ` Matthew Heaney
@ 1998-08-04  0:00                 ` David C. Hoos, Sr.
  0 siblings, 0 replies; 11+ messages in thread
From: David C. Hoos, Sr. @ 1998-08-04  0:00 UTC (permalink / raw)


Matthew Heaney wrote in message ...
>Agreed, but here's another argument.  My _expectation_ was that there
>would be a predefined instantiation for type Duration, because other
>types in Standard had predefined instantations.  If it's natural for me
>to expect something to be there, then maybe it should be there.  Maybe.
Just to put my two cents' worth in on this subject, let me relate an
experience of several years back on a large Ada83 project.

I was looking at ways to speed up compilation, reduce executable size, etc.,
and one of the discoveries I made was that there were dozens of
instantiations of Duration_IO throughout the system.  The impact of these
many instantiations is, to be sure, dependent in large degree on how the
implementation does generics.  But in this case, there was NOT ONE instance
which was necessary -- i.e., all of what was being done could have (should
have, in my opinion), and now is being done with the attributes 'image and
'value.  In other words, no one was reading or writing to or from files with
these instances, so the code for all of the file operations was wasted.

I, for one, was glad to see 'image and 'value provided for floating point
types, since many of the uses of instances of Float_IO were similarly used
for things which could be more simply done with the attributes.

David C. Hoos, Sr.







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

end of thread, other threads:[~1998-08-04  0:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <c1.2b8.2Lzh62$03A@zesi.ruhr.de>
1998-07-31  0:00 ` String to Integer conversion? Matthew Heaney
1998-07-31  0:00   ` daniel gaudry
     [not found] ` <6ndi5d$uj3@gcsin3.geccs.gecm.com>
1998-07-31  0:00   ` Matthew Heaney
1998-07-30  0:00     ` nabbasi
1998-08-01  0:00     ` Robert Dewar
1998-08-01  0:00       ` Matthew Heaney
1998-08-02  0:00         ` Robert Dewar
1998-08-02  0:00           ` Matthew Heaney
1998-08-04  0:00             ` Robert Dewar
1998-08-04  0:00               ` Matthew Heaney
1998-08-04  0:00                 ` David C. Hoos, Sr.

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