Re: Array slices and types
- From: Maciej Sobczak <see.my.homepage@xxxxxxxxx>
- Date: Thu, 21 Aug 2008 14:16:20 -0700 (PDT)
On 20 Sie, 22:45, Adam Beneschan <a...@xxxxxxxxxx> wrote:
Do you really need a new *type*, as opposed to:
subtype Name is String (1 .. 10);
???
Good question. If I make it a subtype, then I have no protection
against mixing First_Name with Device_Name with File_Name with
Signal_Name with Any_Other_Name - and that would defeat the whole
purpose of defining them.
Consider:
declare
subtype First_Name is String (1 .. 4);
subtype Device_Name is String (1 .. 4);
Someone : First_Name := "Adam";
Something : Device_Name := "usb1";
begin
Someone := Something; -- oops
end;
That's why I was thinking about distinct types. I'm OK with type casts
when assigning them from regular String.
--
Maciej Sobczak * www.msobczak.com * www.inspirel.com
Database Access Library for Ada: www.inspirel.com/soci-ada
.
- References:
- Array slices and types
- From: Maciej Sobczak
- Re: Array slices and types
- From: Adam Beneschan
- Array slices and types
- Prev by Date: Re: Access to function returning class-wide type
- Next by Date: Re: Status of ayacc and aflex?
- Previous by thread: Re: Array slices and types
- Next by thread: Re: Array slices and types
- Index(es):
Relevant Pages
|