[clean-list] isLower isUpper

F.S.A.Zuurbier@inter.nl.net F.S.A.Zuurbier@inter.nl.net
Wed, 8 May 2002 13:35:19 UT


This is a multi-part message in MIME format.

--_----------=_1020864919610221
Content-Disposition: inline
Content-Length: 2226
Content-Transfer-Encoding: binary
Content-Type: text/plain

Would th following be possible to solve the prolem?

On opening a file, we should be able to indicate what ‘code page’ the characters are in. The type of the existing Clean function is:

class FileSystem f where
	fopen :: !{#Char} !Int !*f -> (!Bool,!*File,!*f)

The proposed new types are:

class FileSystem f where
	fopenASCII ::		!{#Char} !Int !*f -> (!Bool,!*File A,!*f)
	fopenUnicode ::		!{#Char} !Int !*f -> (!Bool,!*File U,!*f)
	fopenMac ::		!{#Char} !Int !*f -> (!Bool,!*File M,!*f)
	fopenWindows ::	!{#Char} !Int !*f -> (!Bool,!*File W,!*f)

So *File is now a type that takes one type variable that indicates the code page. As a consequence, all functions that manipulate files should get a different type:

freadi		:: (!*File c) -> (!Bool,!Int,!*File c)
fwriter		:: !Real (!*File c) -> *File c

Functions that indeed read or write characters, should propagate the code page information:

freadc		:: (!*File c) -> (!Bool,!Char c,!*File c)
fwritec		:: (!Char c) !*File -> *File c
freads		:: (!*File c) !Int -> (!*{#Char c},!*File c)
fwrites		:: !{#Char c} (!*File c) -> *File c

And we will need conversion functions to convert characters and strings from one code page to another.

The functions that triggered this thread would get the types:

isUpper		:: (!Char c) -> Bool
isLower		:: (!Char c) -> Bool

They would be methods in a class, with instances for all code pages.

This way, it should be possible to use the type system to process different character code pages correctly. I would rather have that code page information would be part of the file information, but this, I guess, is not reality.

How does this work out on the screen? Clean already has a module deltaSystem.icl that contains platform-dependent stuff such as WinGetHorzResolution. Maybe that would be the place to put a platform’s display code page type (i.e. A, U, M, or W).

I realize that changing the types of File and Char may not be really necessary. We already stuff an object of type File with information that controls subsequent read and write operations: FReadData etc. But that way, programming errors generate a runtime error, and are not caught at compile time.

Regards Erik Zuurbier

--_----------=_1020864919610221--