misc type comments

Alan Grover awgrover@umich.edu
Mon, 9 Mar 1998 09:33:30 -0500


I wanted to declare a type like this:
	:: OSType = {#Char,#Char,#Char,#Char}
by which I mean a string of exactly four characters. I wanted it to be a
string so I could use all the string functions.

I realize I could define some algebraic type or a tuple, and write
appropriate functions. I ended up using a synomym for now (as String).

---

Clean provides a type synonym construct, but this does not provide distinct
types thus inhibiting overloading. This is a terrible problem in C++ with
many libraries using "typedef" (compare OSType with int, AppleEvent with
AEDesc) making it impossible to write overloaded functions that can
distinguish between the types. C++ actually provides a workaround with
something like:
	class OSType : public int { ...appropriate constructors here... }
Please consider allowing (encouraging) non-synonym typedefs.

This has been covered before, on the mailing list.

---

Please make Char distinct from Byte. Byte should have numeric semantics
(like multiply, etc.), while Char should have operations like
diff,offset,pred,succ (overloaded as -,+,++,--), toInt, Int->Char, etc.. C
offers an excellent demonstration of why the two kinds of things should be
distinct.

---
"Alan Grover, Technical Pb" awgrover@umich.edu
+1 (743) 647-5778
Project Leader
Health Media Research Lab, Cancer Center
5D04 North Ingalls Building, Mail Stop 0471
300 North Ingalls
Ann Arbor, MI 48109-0471