Re: Easy question about Character manipulation



On Mon, 2007-01-29 at 21:17 +0100, Dmitry A. Kazakov wrote:
On 29 Jan 2007 12:01:00 -0800, mark wrote:

I am quite newbie to ada. I have declared something like that:
size: Integer := 9;
emptySpaces : array (0..size) of Character := "0123456789";
textLine : array (0..size * 3) of Character;

(must be (size+1)*3-1. Indexing from 0 is an evil thing, trust me! (:-))

Now I would like to have the possibility to initialize textLine
variable, but when I write:
textLine := "9876543210" & emptySpaces & "9876543210";

I got an error 'expected type of textLine' ,'found type od
emptySpacs...'. I know it is connected with very deep contstaint
checks

Yes, emptySpaces and textLine have different types.

Yes, and these two different types are *anonymous* types.
This means, you have not given them (the types) a name. The
array (...) of
both "look" like some array of characters, and they are.
But they are not the same array type because there is no
type name. (Only the object names "emptySpace" and "textLine".)

Unlike Pascal, for example, types in Ada are different when
they have different names. The types of emptySpace and
textLine have no names at all, being anonymous (unnamed)
array types. So they don't have the same name, so to speak.

Consider this

declare
type My_Array is array (1 .. 10) of Character;
type Your_Array is array (1 .. 10) of Character;
x: My_Array;
y: Your_Array;
begin
x := y;
end;

This won't compile. Ada doesn't permit assignment for objects (x, y)
of different types (My_Array, Your_Array) even when they show the
same structure (array (1 .. 10) of Character)--but different names.



.



Relevant Pages

  • Re: String literals and wide_string literals - how?
    ... But I'll bet it _seems_ weird to anyone who doesn't know Ada well. ... Character, or derived from it. ... And STRING as array of char, although it ...
    (comp.lang.ada)
  • Re: Is there an end of string like in C
    ... You can define your own character types and your own string types. ... type String is array of Character; ... The C approach is referred to in Ada as a bounded string; the logical value can vary in length from zero to some maximum number of characters. ...
    (comp.lang.ada)
  • Re: Need help with textboxes
    ... character into the input box. ... one of assigning the reference to a variable: ... All forms and their children are stored in an array ... No. Bracket property accessors allow their argument to be any string value. ...
    (comp.lang.javascript)
  • Help in Spanish translation of the description of UDFs
    ... functions of minimum / maximum values among elements of an array column. ... GETALLWORDS- Inserts the words from a string into a global dimensioned ... WORDTRAN- Searches a character string for occurrences of a first word, ... ARRAYSUM- Returns the sum of all or a specified range of numeric (and/or ...
    (microsoft.public.fox.helpwanted)
  • Re: Pointer
    ... require in input a pointer char: ... unsafe public static extern int OpenFile; ... What is it pointing to exactly, is it pointing to a "Unicode character" array or is it pointing to a "Single byte character" array or is it pointing to something else? ...
    (microsoft.public.dotnet.languages.csharp)