Re: [fpc-pascal]Delphi "9" language features...

2004-08-13 Thread Florian Klaempfl
Matt Emson wrote:
I don't like the very unspecific implementation. In [SNIP, as this is a
matter of opinion, replace this with "other"]
That's what I meant however my keyboard ate it ;)

languages/libraries there are several kinds of iterators, see e.g. the
STL.
Exactly, which is why I prefer the idea Borland has gone for. The STL is not
a good idea.
The behaviour of the d9 iterators appear to me very unspecific. In which 
order does it iterate through the elements? What happens if I delete an 
element while iterating, maybe even the current. Does an iterator stay 
valid if I remove the element from the container? How can I change how 
the iterator behaves? etc.

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Delphi "9" language features...

2004-08-13 Thread Dean Zobec
Matt Emson wrote:
Exactly, which is why I prefer the idea Borland has gone for. The STL is not
a good idea.
Delphi doesn't have a decent containers library. TObjectList is derived 
from TList instead as being designed as a wrapper (if Borland had read 
the Danny Thorpe's book they would not implement it this way :-). 
TStringList is a cute class (I like it very much) and is an swiss army 
knife for Delphi, but nothing more, there are cases where other 
containers could do better.
Where are Hash Tables, B-Trees, etc?  A simple interface for lists is 
not an innovation IMHO.
Ciao, Dean

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]Delphi "9" language features...

2004-08-13 Thread Thomas Schatzl
Hello,
Exactly, which is why I prefer the idea Borland has gone for. The STL 
is not
a good idea.

The behaviour of the d9 iterators appear to me very unspecific. In which 
I think this is because the origin of this information is only a blog 
entry, no specification...

order does it iterate through the elements? What happens if I delete an 
element while iterating, maybe even the current. Does an iterator stay 
valid if I remove the element from the container? 
See below.
How can I change how the iterator behaves? etc.
Implement the interface methods for iterating over the class according 
to one's wishes I suppose.

---
For Arrays: as indicated it's just a shorthand for a "for i := low(arr) 
to high(arr) "

For IEnumerable: I guess they'll comply to the behaviour of the 
IEnumerable interface of .NET, so have a look there:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsienumeratorclasstopic.asp
Outline:
- if the collection is changed while iterating over it, IEnumerable 
throws an exception
- no inherent thread safety
- behaviour (e.g. iteration order) specific to implementation

I think this syntactic sugar construct is better than nothing: At least 
I make a lot of mistakes regarding lost "-1" when specifying the upper 
bound when writing code to iterate over a TStringList or similar - or 
the imo stupid and repetitive "for i := low(xy) to high(xy) do begin" 
sequences all over the place in case of normal arrays.

What's more interesting for me is that it seems that there will be a 
Delphi compiler emitting native code again... :-)

Regards,
  Thomas
One cent...
___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal