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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 5b1e799cdb,3ef3e78eacf6f938,start X-Google-Attributes: gid5b1e799cdb,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!feeder.erje.net!feeder.eternal-september.org!eternal-september.org!not-for-mail From: Colin Paul Gloster Newsgroups: comp.lang.eiffel,comp.lang.ada,comp.programming Subject: Re: Alternatives to C: ObjectPascal, Eiffel, Ada or Modula-3? Date: Tue, 21 Jul 2009 17:48:36 +0000 Organization: A noiseless patient Spider Message-ID: References: Reply-To: Colin Paul Gloster Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: news.eternal-september.org U2FsdGVkX19GRcMymt1RQRmsj1Oeld2IQBLFVWsNqX+Wa0JsQbHbgCcdGzhIBswA5Xd9VoImabVWSe/6Ou6J0Q/gnGbaML5ze812P9M1jqUjXbnR5PfMxWNvEWyvyIqHyVsdg7pyhqv3al3REtVw5g== X-Complaints-To: abuse@eternal-september.org NNTP-Posting-Date: Tue, 21 Jul 2009 16:47:55 +0000 (UTC) In-Reply-To: X-Auth-Sender: U2FsdGVkX1+cZFwHZw6eAQnyhKMX/Hde05n7I2IOzuht62DrDT/Tog2cz2l53tyAWAtth9lItM4= Cancel-Lock: sha1:3WHJ9Ca4UdbrYOHExRdCHoWKElc= X-X-Sender: Colin_Paul@Bluewhite64.example.net User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) Xref: g2news2.google.com comp.lang.eiffel:382 comp.lang.ada:7255 comp.programming:11958 Date: 2009-07-21T17:48:36+00:00 List-Id: On Tue, 21 Jul 2009, Cesar Rabak wrote: |-----------------------------------------------------------------------------------| |"[..] | | | |> | |> |-------------------------------------------------------------------------------|| |> |"[..] | |> | | |> | | |> | | |> |As for normalization, IMNHO it has to be done in the constructor of the | |> | | |> |class/object, and not as an (external) wrapper." | |> | | |> |-------------------------------------------------------------------------------|| |> | |> I did not necessarily prohibit that. The wrapper could be called by | |> the constructor. The wrapper is external to the floating point Ada | |> type Radians or Magnitude or X_Coordinate or Y_Coordinate, which | |> itself could be restricted to the internals of a client's class, much | |> as a C++ std::string might use a char* internally. | | | |Notice that all this would be unnecessary if the language's needs did not | |entered into the problem: once an internal representation for the type Point had | |been chosen, the constructors would accept the values and do the conversion, | |which in case of the representation would be done as part of the | |constructor job. | | | |> | |> If normalization is required, it might not be ideal to keep it in the | |> constructor because a variable could be constructed whose value is | |> changed later, for example | |> --Call a constructor for Radius but do not give it a value yet. | |> [..] | |> for some_iterations loop | |> Radius := Get_Current_Radius; | |> --Do stuff. | |> end loop; | | | |The example must be too contrived and I have not code Ada for years to | |understand it, but again it seems to be more an Ada technology related issue | |than a fundamental aspect. | | | |[..]" | |-----------------------------------------------------------------------------------| No, it is not contrived. Unlike a functional language in which every so-called variable is actually constant, Ada is an imperative language in which it is common to assign a different value to a variable after it has already been assigned an earlier value. In this example, a variable was declared and it was assigned many values in a loop (perhaps from a GUI). Unless you meant something else by constructor, checking for errors should not be performed just in the constructor when the variable begins to exist. Regards, Colin Paul Gloster