[fpc-devel] Some compiler changes...
Michael Van Canneyt
michael at freepascal.org
Tue Jan 23 21:12:11 CET 2007
On Tue, 23 Jan 2007, Luiz Americo Pereira Camara wrote:
> Daniƫl Mantione wrote:
> > Op Tue, 23 Jan 2007, schreef Luiz Americo Pereira Camara:
> >
> >
> > > Ale? Katona wrote:
> > >
> > > > I agree. I'm starting to feel sick of all the compat crap you guys put
> > > > up with playing the bitch of delphi. The problem is that now delphi is
> > > > the bitch of .net so I think wisest would be to implement 100% compat up
> > > > to delphi 7 and be done with it. Then just document the fact and point
> > > > people to mode objfpc and our new stuff.
> > > >
> > > >
> > > This makes me remenber of copying weird behaviors of Delphi. As an example
> > > see
> > > the code:
> > >
> > > AList:=TStringList.Create;
> > > with AList do
> > > begin
> > > writeln('Set a string with space (aaaa;bb bb;cccc) to DelimitedText');
> > > DelimitedText:='aaaa;bb bb;cccc';
> > > writeln('Count: ',Count);
> > > writeln('Delimited text: ',DelimitedText);
> > > writeln('Strings: ');
> > > for i:= 0 to Count - 1 do
> > > writeln(' ',Strings[i]);
> > > Destroy;
> > > end;
> > >
> > > Output:
> > > Set a string with space (aaaa;bb bb;cccc) to DelimitedText
> > > Count: 4
> > > Delimited text: aaaa;bb;bb;cccc
> > > Strings:
> > > aaaa
> > > bb
> > > bb
> > > cccc
> > >
> > >
> > > The space is used as a hardcoded delimiter being necessary to enclose with
> > > ".
> > > This limits the use of DelimitedText as a generic approach since is
> > > necessary
> > > to preprocess the strings being added though DelimitedText.
> > >
> > > The argument to keep such behavior is compatibility but there will be
> > > always
> > > differences when porting code and the programmer must be aware. What is
> > > necessary is to document the differences. So in resume i think that fpc
> > > must
> > > not follow strictly Delphi, and in some situations, where appropriated,
> > > fpc
> > > can/must do things different/better than Delphi.
> > >
> >
> > Yes, but unless it is clearly a Delphi bug, it is better to keep the Delphi
> > compatible procedure or class and write a new clean one. Wether something is
> > a bug or intended behaviour usually becomes clear after reading the the
> > documentation.
> >
> Ok. Apart from the Delimiter issue, i've heard some complaints about the
> design of TStringList that would not be scalable etc (a quote of a email sent
> to fpc-devel below). Maybe is time to add to fpc a new class to store strings,
> fixing the design flaws? Anyone already has such a base?
Not really.
I don't believe there is an optimal design. It depends on what you want
to use the StringList for. For generic use in the VCL (memo, combobox,
listbox, params), TStrings is well suited. Some of the choices Borland made
when implementing auxiliary methods are unfortunate, but they can be replaced
with better methods, if needed, or new methods can be added. I'm always open
for suggestions. But compatibility should be maintained.
For handling large amounts of strings or stringlists for special purposes,
it's usually better to write a specialized class. FPC meanwhile contains
enough container classes to make this possible.
Michael.
More information about the fpc-devel
mailing list