BP string compatibility

Frank Heckenbach heckenb at mi.uni-erlangen.de
Tue Nov 18 13:31:25 CET 1997


The African Chief wrote:

> Problem:
> Under BP, one can do;
>  Var S:String;
>  Count:Integer;
>  ....
>  Dec(S[0], Count);
> 
> This does not compile under GPC, but "Dec(Length(S), Count)"
> compiles, and seems to work okay.
 
Then I think this is a bug in GPC, and must be prevented. The Length
field of a string should only be accessible read-only.

However, there is (in the current developer version, not yet in the
last beta) a built-in function AssignLength which is the proper way
to directly wirte to the length field of a string (if messing with
the length can be called proper at all... ;-)

> Observation: 
> This is an incompatbility b/w BP and GPC - probably
> because of the way strings are implemented under GPC.
 
Right.

> Questions:
> 1. Is GPC ever going to support the BP syntax "Dec(S[0], Count);"
> ?

Short answer, yes, sometime. More details can be found in some other
discussions in the list.

> 2. Is it desirable to do so ?

Yes. Mainly for the reason you described.

> (obviously this would entail changes to the internal GPC string
> format ???)
 
Not changes to the "real" Pascal strings; rather, it would mean
introducing a new string type with automatic conversions as far
as possible.
 
-- 
Frank Heckenbach, Erlangen, Germany
fjf at gmx.de
http://home.pages.de/~fjf/links.htm




More information about the Gpc mailing list