Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Type STRING

DEFINITION MODULE String ("S-Type");

(* Example library for dynamic strings using operator bindings *)

TYPE String = OPAQUE;


(* length *)

PROCEDURE [LENGTH] length ( s : String ) : LONGCARD;


(* literal assignment *)

PROCEDURE [:=] assign ( VAR s : String; literal : ARRAY OF CHAR );


(* concatenation *)

PROCEDURE [+] concatenate ( s1, s2 : String ) : String;


(* relational operations *)

PROCEDURE [=] isEqual ( s1, s2 : String ) : BOOLEAN;

PROCEDURE [>] isGreater ( s1, s2 : String ) : BOOLEAN;

PROCEDURE [<] isLess ( s1, s2 : String ) : BOOLEAN;


(* IO procedures *)

PROCEDURE Read ( f : File; VAR s : String );

PROCEDURE Write ( f : File; s : String );

PROCEDURE WriteF ( f : File; fmtStr : ARRAY OF CHAR;
                   items : CARDINAL; VARIADIC v[items] OF s : String );

END String.