[M3devel] Some earlier work

Rodney Bates rodney_bates at lcwb.coop
Mon Jul 2 17:09:25 CEST 2012


Hmm.  This looks very much like original Text.i3, with CHAR replaced by UText.Char.  
Dare I infer that is was inspired that way?  It presents just the abstraction that
I think Text itself should present.  



-Rodney Bates

--- dragisha at m3w.org wrote:

From: Dragiša Durić <dragisha at m3w.org>
To: m3devel <m3devel at elegosoft.com>
Subject: [M3devel] Some earlier work
Date: Sat, 30 Jun 2012 10:56:27 +0200

This is how we implemented UTF8 strings over current TEXTs. Current implementation is UNSAFE and uses glibc utf8 methods. Nothing too complicated and nothing we can't implemented in Modula-3/portable C.

=====
INTERFACE UText;

TYPE
  T = TEXT;
  Char = CARDINAL;

PROCEDURE Cat(t, u: T): T;

PROCEDURE Equal(t, u: T): BOOLEAN;

PROCEDURE GetChar(t: T; i: CARDINAL): Char;

PROCEDURE ByteSize(t: T): CARDINAL;

PROCEDURE Length(t: T): CARDINAL;

PROCEDURE Empty(t: T): BOOLEAN;

PROCEDURE Sub(t: T; start: CARDINAL; length: CARDINAL := LAST(CARDINAL)): T;

PROCEDURE SetChars(VAR a: ARRAY OF Char; t: T);

PROCEDURE FromChar(ch: Char): T;

PROCEDURE FromChars(READONLY a: ARRAY OF Char): T;

PROCEDURE Hash(t: T): Word.T;

PROCEDURE Compare(t1, t2: T): [-1..1];

PROCEDURE FindChar(t: T; ch: Char; start: CARDINAL := 0): INTEGER;

PROCEDURE FindCharR(t: T; ch: Char; start: CARDINAL := LAST(INTEGER)): INTEGER;

END UText.



More information about the M3devel mailing list