Strings does not fit Oakwood guidelines

All except GUI problems
Post Reply
User avatar
Ivan Denisov
Posts: 358
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Strings does not fit Oakwood guidelines

Post by Ivan Denisov »

Oakwood standard Strings module includes Delete and Insert procedures
https://oberoncore.ru/library/the_oakwo ... developers

What is your opinion, should Strings module of BlackBox also include these procedures?

Code: Select all

DEFINITION Strings;
PROCEDURE Length (s: ARRAY OF CHAR): INTEGER;
PROCEDURE Insert (source: ARRAY OF CHAR; pos: INTEGER; VAR dest: ARRAY OF CHAR);
PROCEDURE Append (extra: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR);
PROCEDURE Delete (VAR s: ARRAY OF CHAR; pos, n: INTEGER);
PROCEDURE Replace (source: ARRAY OF CHAR; pos: INTEGER; VAR dest: ARRAY OF CHAR);
PROCEDURE Extract (source: ARRAY OF CHAR; pos, n: INTEGER; VAR dest: ARRAY OF CHAR);
PROCEDURE Pos (pattern, s: ARRAY OF CHAR; pos: INTEGER): INTEGER;
PROCEDURE Cap (VAR s: ARRAY OF CHAR);
END Strings
HansKlaver
Posts: 16
Joined: Sun Oct 13, 2013 10:46 pm
Location: Aerdenhout, The Netherlands

Re: Strings does not fit Oakwood guidelines

Post by HansKlaver »

As is hinted at in the documentation of Strings both Insert and Delete can be implemented trivially in terms of procedure Replace. So maybe it is enough to stress this in the documentation by printing these words in bold typeface:

Hint: if len = 0 then rep is inserted in s at position pos. If LEN(rep$) = 0 then the stretch [pos, MIN(pos+len, LEN(s$))) is deleted from s.
User avatar
Ivan Denisov
Posts: 358
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Re: Strings does not fit Oakwood guidelines

Post by Ivan Denisov »

HansKlaver wrote: Mon Mar 28, 2022 7:50 pm As is hinted at in the documentation of Strings both Insert and Delete can be implemented trivially in terms of procedure Replace. So maybe it is enough to stress this in the documentation by printing these words in bold typeface:

Hint: if len = 0 then rep is inserted in s at position pos. If LEN(rep$) = 0 then the stretch [pos, MIN(pos+len, LEN(s$))) is deleted from s.
Thanks a lot, there is also in-code comment about this extra semantics. I agree, this should be highlighted in documentation.

Code: Select all

	PROCEDURE Replace* (VAR s: ARRAY OF CHAR; pos, len: INTEGER; IN rep: ARRAY OF CHAR);
		(* replace stretch s[pos]..s[pos+len-1] with rep *)
		(* insert semantics if len = 0; delete semantics if LEN(rep$) = 0 *)
Post Reply