comp.lang.ada
 help / color / mirror / Atom feed
From: "Andrew" <andrew@carroll-tech.net>
To: <comp.lang.ada@ada.eu.org>
Subject: conversion
Date: Fri, 27 Jun 2003 11:37:09 -0600
Date: 2003-06-27T11:37:09-06:00	[thread overview]
Message-ID: <mailman.21.1056734216.8204.comp.lang.ada@ada.eu.org> (raw)

Ok, so I found the ada.strings.unbounded package spec and body and took a
look
at the definition and implementation of unbounded string.  Finally I found
them!

Unbounded_string is basically an object that contains a reference to a
string.
It would be something like:

typdef struct unbounded_string{
    char* reference;
}

with methods to manipulate the structure.  My example may not be
syntactically correct
but I think I convey the basic idea.  String is an array, Unbounded_String
is an
"object" that contains a reference to an array.

So...The conversion from Unbounded_String to String is pretty easy.  Return
the
pointer de-reference.  From String to Unbounded_String is the expensive one.
In
general it is:
allocate memory
copy values from old to new
return the new.

So, using unbounded and calling to_string is relatively fast.  Good, I'm
satisfied with
that part.  I think it would be easy enough to create a slice and trim
method that
returned an unbounded_string so that I would not have to use the expensive
string to
unbounded_string conversion and that nagging inconvenience would be
pacified.

Dmitry mentioned that get_line reads in to a string buffer.  Then after the
line
was read another string could be made because the last parameter is the
length of
what was read.  Your absolutely right!  I knew that and looked right over
it.

It wasn't hard at all to write a program that uses to_string and
to_unbounded_string.
It works.  It's just that I didn't realize in design that I would need so
many conversions
and I wasn't fluent enough with all the "utility" methods like slice, trim,
head, etcetera
to really specify at design time whether I needed String or
Unbounded_String.  Once
implementation time came up I almost immediately had to go back to design
because
I was introducing so much code for the conversions.  I thought "there has to
be a better
way".

Something else I really like about Ada is separate compilation.  I can
separate subprocedures
into other files with the "is separate" and Separate(<name>) feature.  That
one thing would
make code SO much more manageable.  I could spread that thing out and assign
tasks by
function if needed.  Then, just compile!

I also was trying to get gnatmem to run but it fails.

Has anyone used the Ada Core Technologies compiler?  How does it compare to
the public
GNAT that I'm using; comes with FreeBSD Unix.

Thanks for the help!

Andrew









             reply	other threads:[~2003-06-27 17:37 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-27 17:37 Andrew [this message]
2003-06-27 17:32 ` conversion Stephen Leake
2003-06-28  2:55 ` conversion Jeffrey Carter
     [not found] <002701c33e22$8e9deaf0$0201a8c0@win>
2003-06-29 20:15 ` conversion David C. Hoos, Sr.
  -- strict thread matches above, loose matches on Subject: below --
2003-06-29  9:41 conversion Andrew
2003-07-04 10:42 ` conversion Janeit
2003-06-28  8:46 conversion Andrew
2003-06-28  9:49 ` conversion Preben Randhol
2003-06-30 14:08 ` conversion Stephen Leake
2003-06-27 10:51 conversion Andrew
2003-06-27 12:22 ` conversion Dmitry A. Kazakov
2003-06-27 12:37 ` conversion Stephen Leake
2003-06-27 14:26   ` conversion Bill Findlay
2003-06-27 17:04     ` conversion Georg Bauhaus
2003-07-04  0:21     ` conversion Dave Thompson
2003-06-27 13:25 ` conversion Robert I. Eachus
2003-06-27 18:42   ` conversion tmoran
2003-06-27 14:49 ` conversion Matthew Heaney
2003-06-27 17:10 ` conversion Georg Bauhaus
2003-06-27 17:13 ` conversion Alexander Kopilovitch
2003-06-27 17:34   ` conversion Preben Randhol
2003-06-27 22:10     ` conversion Alexander Kopilovitch
2003-06-28  9:46       ` conversion Preben Randhol
2003-06-27 22:13   ` conversion Robert I. Eachus
2003-06-30  8:52     ` conversion Dmitry A. Kazakov
2003-07-03  7:03       ` conversion Robert I. Eachus
2003-07-09  7:42         ` conversion Dmitry A. Kazakov
2003-07-09 17:04           ` conversion Robert I. Eachus
2003-07-10 10:19             ` conversion Dmitry A. Kazakov
2003-07-11  1:56               ` conversion Alexander Kopilovitch
2003-07-05  2:40     ` conversion Alexander Kopilovitch
2003-07-05  6:33       ` conversion Georg Bauhaus
2003-07-05 17:06         ` conversion Alexander Kopilovitch
2003-07-06  3:53           ` conversion Robert I. Eachus
2003-07-06  5:13             ` conversion Jeffrey Carter
2003-07-06 12:45               ` conversion Chad R. Meiners
2003-07-07  1:09             ` conversion Alexander Kopilovitch
2003-07-06 20:04           ` conversion Georg Bauhaus
2003-07-07 14:55             ` conversion Stephen Leake
2003-07-07 21:36               ` conversion Alexander Kopilovitch
1998-07-22  0:00 conversion Rick
1998-07-22  0:00 ` conversion Richard Toy
1998-07-22  0:00 ` conversion Corey Ashford
1998-07-22  0:00   ` conversion Corey Ashford
replies disabled

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