Re: How difficult is ada to learn?



Gene wrote:

You perfectly illustrated what I meant. The overloaded plus constructor is quite idiomatic.

And the syntax for Pascal sets isn't idiomatic??? Anyway, we're comparing apples and oranges; see my post about Ada's built-in sets.


But even the new set container looks an awful lot like Pascal. For example, the tutorial here:

http://www.geocities.com/SiliconValley/Park/3230/pas/pasl1010.html

gives these examples:

exclude(myday,Friday);
include(myday,Friday);

That's no different from:

declare
   myday : Day_Sets.Set;
begin
   ...
   Exclude (myday, Friday);
   Include (myday, Friday);
end;

Again, Ada's choice of names here is quite deliberate.

If you're a teacher, it wouldn't take any effort to provide a helper package for your students, something like:

with Ada.Containers.Ordered_Sets;
generic
   with package Sets is new Ada.Containers.Ordered_Sets (<>);
   use Sets;
package Generic_Set_Arrays is
   type Element_Array is
     array (Positive range <>) of Sets.Element_Type;

   function To_Set (Element : Sets.Element_Type) return Set;
   function To_Set (Elements : Element_Array) return Set;
   function "+" (E : EA) return Set renames To_Set;

   function "and" (L : Set; R : EA) return Set;
   function "or" (L : Set; R : EA) return Set;
   ...

   function "and" (L, R : EA) return Set;
   function "or" (L, R : ET) return Set;
   ...
end Generic_Set_Arrays;

Given overloadings like these, it's not even necessary to use the "+" conversion operator:

declare
   S1 : Set := To_Set (1);
   S2 : Set := S1 and (2, 3, 4);
   S3 : Set := S2 or (4, 5);
   S4 : Set := (6, 7) and (7, 8);
begin ...

I can't imagine students who are struggling with the syntax for Ada sets to have an easier go of it in similar languages as C++, Java, etc, which are also taught in contemporary CS curricula.

Yes, Pascal has slightly more built-in support for sets than Ada does (i.e. syntax for a set literal), but sooner or later students will have a need for a more sophisticated set, that can store more than elements of a discrete type with small range of values. And eventually they'll need a map or a list, and then what will they do?
.