comp.lang.ada
 help / color / mirror / Atom feed
From: jpwoodruff <jpwoodruff@gmail.com>
Subject: Re: Does ada have a sscanf equivalent?
Date: Mon, 22 Feb 2010 18:11:34 -0800 (PST)
Date: 2010-02-22T18:11:34-08:00	[thread overview]
Message-ID: <bdcf2cf7-312e-469a-9085-ef647f69f894@g8g2000pri.googlegroups.com> (raw)
In-Reply-To: 8432d8b0-acd0-439f-8366-d72f53571f90@k18g2000prf.googlegroups.com

On Feb 22, 3:11 pm, Jerry <lancebo...@qwest.net> wrote:
> On Feb 22, 12:48 pm, jpwoodruff <jpwoodr...@gmail.com> wrote:
>
>
>
> > On Feb 22, 1:08 am, "J.s" <justin.squi...@gmail.com> wrote:
>
> > > I am trying to translate some C code that parses a string into numbers
> > > (both Integers and Floats) from an input file. Would it be easiest to
> > > just import the C function or is there an Ada equivalent?
>
> > Let me offer a product of my own devising.
>
> > "The packages Numeric_IO and Name_IO, together with their children and
> > support, assist a program to read a user’s input.  The packages are
> > intended to support numerical computation by providing Get and Put
> > procedures for floating numbers and for vectors and matrices of
> > floating numbers.
>
> > "The procedures ease an end-user’s burden in preparing inputs for
> > computational programs.  The rules for input of floating numbers are
> > relaxed so that program inputs need not conform to the strict Ada
> > syntax for floating numbers. Facilities allow input either from files
> > or interactively. Consistent policies throughout all the services
> > allow programs to address input errors, to prompt the end-user
> > interactively or to specify optional default values."
>
> > Dmitry has been kind enough to make it available.
>
> >http://www.dmitry-kazakov.de/ada/Numeric-Name-IO
>
> > --
> > John
>
> This looks pretty cool. But it doesn't seem to use the Ada 2005
> definitions for matrices and vectors. I haven't looked at the code but
> I wonder how hard it would be to create such a version. I would think
> it should be pretty easy.
>
> Jerry

There's a file in the distribution called "Guide-to-Examples" that
will shed some light on how to roll this forward to Ada 05 standards.

"As of November 2004 I am aware of six different publicly available
libraries that provide some operations on vectors and matrices.  In
the interest of offering the numeric_IO.matrix_IO services to users
who might be using one of these libraries, I have build small
demonstrations of the usage of the IO functions that conform with each
of them."

The same library worked for all cases.

One of the examples was called Ada0y as signed by Martin Dowie. I
can't claim what version that was, but if not too much has changed
since then, maybe this will still fly:


   type Real is digits 6 ;

   package Ada_Matrix is new Ada.Numerics.Generic_Real_Arrays (Real =>
Real) ;

   -- Numeric_IO services will read and write the same matrix
representation
   package Scalar_IO is new Numeric_IO (Real, Integer) ;

   package Matrix_IO is new Scalar_IO.Matrix_IO
     (Vector_Ix    => Integer,
      Vector_Type  => Ada_Matrix.Real_Vector,
      Matrix_Ix1   => Integer,
      Matrix_Ix2   => Integer,
      Matrix_Type  => Ada_Matrix.Real_Matrix) ;



I'm a retired software engineer who has decided not to follow the new
standard.  I decided that I don't need a new programming paradigm
(except maybe for prolog).  And some of my old favorites didn't work
with the '05 compiler I looked at.

This whole business dates to 1986, with an update to Ada95's generic
child packages.  Besides, I wrote in "A Family of Numeric ..." a
paragraph headed Anachronism Alert.  "... So don't read this package
for esthetics, but it seems to work OK"

John



  reply	other threads:[~2010-02-23  2:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-22  9:08 Does ada have a sscanf equivalent? J.s
2010-02-22 10:24 ` Georg Bauhaus
2010-02-22 10:42 ` Jacob Sparre Andersen
2010-02-22 15:38   ` J.s
2010-02-22 19:48 ` jpwoodruff
2010-02-22 23:11   ` Jerry
2010-02-23  2:11     ` jpwoodruff [this message]
2010-02-23  9:36       ` Conversion from Ada95 to Ada05 (Was: Does ada have a sscanf equivalent?) stefan-lucks
2010-02-23 19:48         ` Randy Brukardt
2010-02-23 21:12           ` Conversion from Ada95 to Ada05 Robert A Duff
replies disabled

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