Forwarded message from patterns mailing list... 
Author Message
 Forwarded message from patterns mailing list...

I saw this message in the "patterns" mailing list. Perhaps if some-
one can comment here, because he raises what seems to me to be
solved problems in APL.

-- Begin Forwarded Message ------------
Date: Mon, 12 Dec 94 10:50:37 EST

Subject: numbers, complex vs real, which is the subclass?

This issue has nagged at me for a long time, also, but I think the
solution might be different.  I'm sure this idea is not new, (q.v.
numeric type(s) in APL, J, and some LISPs), but this is the first I
remember it being presented in an OO context.

Rather than making the class-subclass relationship match the subset
relationship of the different numeric representations, show the user
a class/type called "number", and have the implementation choose an
internal representation as needed, invisible to the user.  The
various numeric types (complex, real, integer, boolean, complex
integer, ...) can be subclasses of number, but do not need to be.
The important feature is that the user/client does not see the
subtypes as data types, only as the one type "number".

Of course, it may be useful to provide test methods that ask whether
a number is an integer or complex value, but the representation is
still hidden from the user-- a complex representation with a zero
imaginary part (or zero theta) should respond TRUE to a real() query.
If the fractional part is zero, a real representation should respond
TRUE to an integer() query.  Note also that an integer representation

will respond TRUE to a real() query.  The important feature of this
idea is to provide a tool (uniform interface) for computation that
matches the mathematical rules, without the customer worrying about
the data storage (different representations).

I think there might even be a pattern here, if I could extract the
"to subclass or not to subclass" question away from the specific
issue of numbers, but I haven't yet read the GOF or other patterns
books, so I'm not sufficiently versed with pattern descriptions to
do it now.


------- End Forwarded Message --------------------------

|\/| Randy A MacDonald       |"You just ASK them?"

     BSc(Math) UNBF '83      | APL: If you can say it, it's done.
     Natural Born APL'er     |
------------------------------------------------------------{ gnat }-

Sat, 31 May 1997 04:04:20 GMT  
 [ 1 post ] 

 Relevant Pages 

1. How to retrive forwarded message from multipart message body

2. Eiffel Patterns Mail List

3. send mail using SMTP Send Message when mail server is unknown

4. Forwarded mail for Nathan Bohlman

5. Forwarded Mail

6. forwarded mail

7. forwarded mail

8. Forwarding message 22.03.00 from Jonathan Cunningham

9. forwarding message from Jonathan Cunningham (with comments)

10. forwarding message from Steve Leach re Running Pop-11

11. forwarded (for David Young) Re: your mail

12. forwarded message suppressing write errors on sockets


Powered by phpBB® Forum Software