Re: How difficult is ada to learn?



Gene wrote:

Most people who start with Borland Pascal miss the built-in set and string data types. Ada gets the same effects with packages, but the syntax is far less elegant and readable.

I haven't done any Pascal in a while, so I don't remember the syntax for set manipulation, but Ada 2005 will have a set container type. It's an abstract data type, declared in a package in the normal way. It supports union, intersection, etc.


If not having "built-in" syntax is a hardship, then you can always define array-based set operations yourself. For example, suppose we have a set whose element type is Integer, then we can do this:

type Integer_Array is array (Positive range <>) of Integer;

function "+" (IA : Integer) return Integer_Sets.Set is
  S : Set;
begin
  for Indx in IA'Range loop
     S.Include (IA (Indx));
  end loop;

  return S;
end;

Now you can say:

declare
   S1 : Set := +(1, 2, 3);
   S2 : Set := +(2, 3, 4);
   S3 : Set := S1 or S2;
   S4 : Set := S3 and +(1, 3);
   S5 : Set := +(42, 43) or +(44, 45);
begin  ...;

That's not that inelegant.  Not much different from Pascal, as I recall...
.



Relevant Pages

  • Re: default formal parameters in generic declarations
    ... Ada currently has neither formal defaults for types or ... packages; ... that, at the cost of some contortion of syntax, but that's not ... Certainly the point about nesting you make is true. ...
    (comp.lang.ada)
  • Re: check for duplicates
    ... unique index on the combination of fields (btw, ... the above syntax in the DCount() assumes that both ProjNo and PartNo ... in the table are Number data types. ...
    (microsoft.public.access.forms)
  • How to handle data types in custom Max/Min function?
    ... I would like to write a custom Max function to return the largest of ... The syntax would be something like: ... best way to handle the data types. ... (as variant), then convert it to the speficied type. ...
    (microsoft.public.vb.general.discussion)
  • Re: Create View in SQL Server with data types
    ... Aren't those JD Edwards column names a drag? ... realize that JDE could handle anything beyond EBCDIC or ASCII. ... CREATE VIEW does not allow for specifying the data types in the VIEW ... It is not part of the syntax. ...
    (comp.databases.ms-sqlserver)
  • Re: double re, im; re(r), im(i) vs re=r, im=i
    ... > With plain old data types like double it may not be clear why you would ... > use the syntax re. ... A theoretical explanation would be nice. ...
    (comp.lang.cpp)