comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <mheaney@on2.com>
Subject: Re: How difficult is ada to learn?
Date: Thu, 30 Jun 2005 15:32:48 -0400
Date: 2005-06-30T19:32:48+00:00	[thread overview]
Message-ID: <42c448e0$0$32193$39cecf19@news.twtelecom.net> (raw)
In-Reply-To: <1120156696.672010.281140@z14g2000cwz.googlegroups.com>

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?



  reply	other threads:[~2005-06-30 19:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-30  0:44 How difficult is ada to learn? Sm704
2005-06-30  5:11 ` Ludovic Brenta
2005-06-30  6:15   ` Preben Randhol
2005-06-30 14:19 ` Gene
2005-06-30 14:34   ` Matthew Heaney
2005-06-30 15:00     ` Duncan Sands
2005-06-30 18:38     ` Gene
2005-06-30 19:32       ` Matthew Heaney [this message]
2005-06-30 18:59     ` Randy Brukardt
2005-06-30 19:36       ` Matthew Heaney
2005-06-30 15:01   ` Matthew Heaney
2005-06-30 22:35     ` Robert A Duff
2005-07-15  2:27       ` Waldek Hebisch
2005-07-15  5:14         ` Ludovic Brenta
2005-07-01  5:37     ` Jeffrey Carter
2005-06-30 16:43 ` Martin Krischik
2005-06-30 19:36 ` svaa
2005-06-30 22:53 ` chris
2005-06-30 22:54   ` chris
2005-07-01  5:39   ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox