Re: Data table text I/O package?
- From: Robert A Duff <bobduff@xxxxxxxxxxxxxxxxxxxx>
- Date: 16 Jun 2005 08:24:32 -0400
Marius Amado Alves <amado.alves@xxxxxxxxxx> writes:
> Yes. This is interesting, useful, and easy. From the header you get the
> field names, from the first data line with deduce the data types. With
> these elements you can generate the record type and procedures to read
> the file.
Hmm. Interesting idea. But you will lose the full power of Ada's type
system. You cannot, in general, deduce the type from the data, in Ada.
I mean, 123 could be any integer type, and a typical Ada program has
many integer types.
For that matter, how do you know 123 is not intended to be Type_String,
in your example below?
>... A trick I often use to deduce data types is based on 'Value:
I believe this trick will run afoul of RM-11.6. It probably works in
practise, but I think that an implementation is allowed to return
Type_Float, no matter what string you pass to Value!
Did I mention that I don't like 11.6? ;-)
> function Get_Type (Value : String) return Data_Type is
> F : Float;
> I : Integer;
> begin
> F := Float'Value (Value);
> return Type_Float;
> exception
> when Constraint_Error =>
> begin
> I := Integer'Value (Value);
> return Type_Integer;
> exception
> when Constraint_Error =>
> return Type_String;
> end;
> end;
- Bob
.
- References:
- Data table text I/O package?
- From: Jacob Sparre Andersen
- Re: Data table text I/O package?
- From: Preben Randhol
- Re: Data table text I/O package?
- From: Jacob Sparre Andersen
- Re: Data table text I/O package?
- From: Preben Randhol
- Re: Data table text I/O package?
- From: Jacob Sparre Andersen
- Re: Data table text I/O package?
- From: Randy Brukardt
- Re: Data table text I/O package?
- From: Jacob Sparre Andersen
- Re: Data table text I/O package?
- From: Marius Amado Alves
- Data table text I/O package?
- Prev by Date: Re: Universal type in Ada
- Next by Date: Re: Data table text I/O package?
- Previous by thread: Re: Data table text I/O package?
- Next by thread: Re: Data table text I/O package?
- Index(es):
Relevant Pages
|