[M3devel] AND (…, 16_ff)… Not serious - or so I hope!

Rodney M. Bates rodney_bates at lcwb.coop
Wed Jun 27 22:10:42 CEST 2012


Yes, this is a disturbing quirk, and quite out of character with the
nature of Modula-3.  It would be consistent to say that CHAR<:WIDECHAR,
and apply the usual assignability rules.  That would make this a runtime
range error.

On 06/26/2012 05:18 AM, Dragiša Durić wrote:
> This piece of code, from TextClass.m3, disturbs me… a lot.
>
> If we are to use WIDECHAR, I think we must be a lot more serious than this.
>
> Probably, text pieces are limited to 128 bytes by design, somewhere. But - whose idea was to "narrow" by ignoring everything except 8 LSB's? By mapping set of 2^20 elements to set of 2^8 elements.
>
> Probably by someone whose mother tongue is fully writeable with ASCII :).
>
> ====
> PROCEDURE GetChars (t: TEXT;  VAR a: ARRAY OF CHAR;  start: CARDINAL) =
>   VAR
>     info : Info;
>     cnt  : INTEGER;
>     next : CARDINAL := 0;
>     buf  : ARRAY [0..127] OF WIDECHAR;
>   BEGIN
>     t.get_info (info);
>     cnt := MIN (NUMBER (a), info.length - start);
>     WHILE (cnt>  0) DO
>       t.get_wide_chars (buf, start);
>       FOR i := FIRST (buf) TO LAST (buf) DO
>         IF (cnt = 0) THEN RETURN END;
>         a[next] := VAL (Word.And (ORD (buf[i]), 16_ff), CHAR);
>         INC (next);  DEC (cnt);
>       END;
>       INC (start, NUMBER (buf));
>     END;
>   END GetChars;
> ====
>
>



More information about the M3devel mailing list