From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,aa8786249f0c751f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeeds.sol.net!posts.news.twtelecom.net!nnrp2.twtelecom.net!not-for-mail Date: Thu, 30 Jun 2005 15:32:48 -0400 From: Matthew Heaney Organization: On2 Technologies, Inc User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How difficult is ada to learn? References: <1120092264.749327.16210@z14g2000cwz.googlegroups.com> <1120141150.107320.139080@f14g2000cwb.googlegroups.com> <42c40313$0$32193$39cecf19@news.twtelecom.net> <1120156696.672010.281140@z14g2000cwz.googlegroups.com> In-Reply-To: <1120156696.672010.281140@z14g2000cwz.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <42c448e0$0$32193$39cecf19@news.twtelecom.net> NNTP-Posting-Date: 30 Jun 2005 19:32:48 GMT NNTP-Posting-Host: a56821b9.news.twtelecom.net X-Trace: DXC=97bmeAD;2I8i_U\QU:i6Z3C_A=>8kQj6==_1NR_H?JP=MOnPQP8Mgg4dYZAA8S: 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?