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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f51e93dacd9c7fca X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-20 11:20:46 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: 18k11tm001@sneakemail.com (Russ) Newsgroups: comp.lang.ada Subject: Re: status of Ada STL? Date: 20 Jun 2002 11:20:44 -0700 Organization: http://groups.google.com/ Message-ID: References: NNTP-Posting-Host: 63.194.87.148 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1024597246 15376 127.0.0.1 (20 Jun 2002 18:20:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 20 Jun 2002 18:20:46 GMT Xref: archiver1.google.com comp.lang.ada:26507 Date: 2002-06-20T18:20:46+00:00 List-Id: Dmitry A.Kazakov wrote in message news:... > Russ wrote: > > Let me postulate a rule of good programming practice, and you can let > > me know if you agree with it or not. If I define an assignment > > operation for a particular type or between any two types, and if I > > also define an equality test between them, then immediately after the > > assignment is executed for instances of those two types, the equality > > test should evaluate to true. For example: > > > > type1 A; > > type2 B; > > ... > > A = B; > > if ( A == B ) ... // true or you goofed somewhere, dude! > > It is a good rule for 80% cases. Unfortunately it is not always possible to > follow it. The real-world is more complicated than one might think. A pair > examples: > > 1. A refers a hardware register. So A = 2, initiates I/O (read from A/D > converter port Base + 2) and as a result A becomes 123! > > 2. A is a fuzzy set, then A==B is a pair of confidence factors, which > cannot be tested in "if". > > and so on and so far. If my rule doesn't apply, then I don't think that assignment and/or equality test operators should be used. Appropriate functions should be defined instead. > >> You can start to define what is equality of two fuzzy sets. What is > >> equality of two floating-point numbers. What is equality of two remote > >> servers. What is equality of two people. Go on. > > > > As I'm sure you well know, good programmers rarely test for exact > > equality of two floating point numbers. And if you can test for exact > > equality of two fuzzy sets, how "fuzzy" can they be? Perhaps I am > > missing your point here. Do you have one? > > The point is that though a set-theoretic equality might be defined, for > some types it might appear unusable for them, like for floating-points or > fuzzy sets. For other things it cannot be defined at all, yet alternative > equality definitions might have sense for them. So there are situations > when reasonable defined assignment and equality are not conformant with > your proposition. Again, I contend that if my rule (requiring consistency of assignment and equality testing) does not apply, then those operators are inappropriate anyway. You shouldn't use "==" (or whatever your symbol is) for comparing two "fuzzy" sets unless you are testing for exact equality. Is you are merely testing for similarity, than you should write a function called "areSimilar" or some such thing. Otherwise, YOU are the one abusing mathematical notation. So were back to the original point. Assignment and equality testing are very tightly related, and using "=" for assignment is perfectly reasonable.