Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Graeme Geldenhuys
On 25/10/2009, Paul Ishenin  wrote:
>  I already created delphi compatible enumerator classes for the basic RTL
> lists: TFpList, TList, TStrings, TComponent and TCollection. We can inherit
> all them from the TInterfacedObject and Graeme interfaces. And list classes
> will have 2 methods: GetEnumerator: TSomeEnumerator and GetIterator:
> ISomeIterator where TSomeEnumerator implements ISomeIterator interface.

When the discussion started about for-in, I could not clearly see how.
But after reading the Delphi article (link you posted earlier) and
looking at your examples for testing for-in loop, I think we could
defiantly share some common iterator code.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] FPC 64bit and gdb on Linux

2009-10-25 Thread Martin Schreiber
On Saturday 24 October 2009 18:32:32 JoshyFun wrote:
> Hello Martin,
>
> Saturday, October 24, 2009, 10:42:27 AM, you wrote:
>
> MS> What do you recommend, should MSEide parse the gdb watch results and
> run MS> another query in order to get the values of var parameters? How
> does Lazarus MS> solve the problem?
>
> I'm working in the Lazarus GDB interface to perform such operations,
> but currently I'm working in records, classes, enums, etc but not as
> parameters. Currently some types as reevaluated to get the "usable"
> value, like pointers which are dereferenced and both data is
> displayed. Something like:
>
> Variable = ^LONGINT 0x12345678 = 5

So you plan to run a second query to show the parameter value?
BTW MSEide has some code to display dynamic arrays and the like, it is located 
in lib/common/designutils/msegdbutils.pas, function 
tgdbmi.readpascalvariable() and tgdbmi.matchpascalformat(), maybe you will 
find it useful.

Martin
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Paul Ishenin

Alexander Klenin wrote:

AFAIU, the whole point of the previous discussion is
that you do not have to implement "GetIterator" separately
from "GetEnumerator" -- you can have the same class filling both roles.
  
Yes. I think we can use some common interfaces/classes/objects in RTL 
both for the for-in loop enumerators and as iterators with all that 
methods which Graeme implemented.


I already created delphi compatible enumerator classes for the basic RTL 
lists: TFpList, TList, TStrings, TComponent and TCollection. We can 
inherit all them from the TInterfacedObject and Graeme interfaces. And 
list classes will have 2 methods: GetEnumerator: TSomeEnumerator and 
GetIterator: ISomeIterator where TSomeEnumerator implements 
ISomeIterator interface.


Graeme, what do you think?

Best regards,
Paul Ishenin.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] [fpc-pascal] mingw libraries for C API bindings

2009-10-25 Thread Wolfram Kläger
I am trying to write fpc bindings for the GraphicsMagick imaging library. Since 
it's a fork of ImageMagick, its API is basically the same. 

I know there is a similar fpc package called PascalMagick. Unfortunately, this 
seems to be an unfinished effort. Types are redefined from c  headers, but 
C-API function and procedure calls are not implemented yet.

I managed to update my MinGW installation on XP, and to install GraphicsMagick 
on top. There are a couple of dependancies. Finally calling "make check" 
reports, everything is alright.

So far, so good. The interesting (and annoying) part of the story is my attempt 
to feed fpc with all library links required. After a while, I found myself in 
an endless loop of searching for undefined symbols, dropping yet another 
linklib in my source, in case updating search paths in my fpc.cfg, and still 
receiving 

Error : Undefined symbol: __imp___iob

Now I am helpless and looking for any systematic, reliable approach to solve 
such "errors". I can't believe it's rocket science to get appropriate info 
about which libraries are exactly required. 

Five underscores per identifier let me assume, I must have entered the hardcore 
C zone. Here's my current list of already linked libs.

  {$linklib libadvapi32}
  {$linklib libbz2}
  {$linklib libbfd}
  {$linklib libcrtdll}
  {$linklib libdxerr8}
  {$linklib libdxerr9}
  {$linklib libgcc}
  {$linklib libgcc_eh}
  {$linklib libgcov}
  {$linklib libgdi32}
  {$linklib libgomp}
  {$linklib libiberty}
  {$linklib libkernel32}
  {$linklib libltdlc}
  {$linklib libmingwex} 
  {$linklib libmoldname}
  {$linklib libmsvcr70}
  {$linklib libmsvcr70d}
  {$linklib libmsvcr71}
  {$linklib libmsvcr71d}
  {$linklib libmsvcr80}
  {$linklib libmsvcr80d}
  {$linklib libmsvcr90}
  {$linklib libmsvcr90d}
  {$linklib libmsvcrt}
  {$linklib libmsvcrtd} 
  {$linklib libpthreadGC2}
  {$linklib libpthreadGCE2}
  {$linklib librapi}
  {$linklib libscrnsave}
  {$linklib libssp}
  {$linklib libuser32}
  {$linklib libwinspool}
  {$linklib libXpm}

  {$linklib libGraphicsMagick}
  {$linklib libGraphicsMagickWand}

Any hints out there, what I am still missing?

Thanks in advance
Wolfram
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Alexander Klenin
On Sun, Oct 25, 2009 at 20:05, Graeme Geldenhuys
 wrote:
> On 25/10/2009, Alexander Klenin  wrote:
>>
>> IMHO, Reset/JumpToBack should not be used inside "for..in" loop -- they are
>>  analogous to "goto" inside for loop.
>>  If "for .. in .. index" extension is implemented, it may be used to call
>
>
> As I explained in my previous reply to Paul - I did not expect for-in
> to support everything I use with Iterators. I simply wanted to find
> out if the for-in implementation is going to clash with my idea of
> implementing GetIterator() in RTL's container classes. So far I don't
> see any problems, and I can't see why we can't implement both. There
> are use-cases for both.  I see for-in as a "lite" version of Iterator,
> but I still have a need for a more "full" implementation as well -
> supporting a larger method interface.

AFAIU, the whole point of the previous discussion is
that you do not have to implement "GetIterator" separately
from "GetEnumerator" -- you can have the same class filling both roles.

-- 
Alexander S. Klenin
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Graeme Geldenhuys
On 25/10/2009, Vincent Snijders  wrote:
>
>  I would call it PeekNext, PeekPrevious, ...


You are correct...


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Graeme Geldenhuys
On 25/10/2009, Alexander Klenin  wrote:
 >
 > IMHO, Reset/JumpToBack should not be used inside "for..in" loop -- they are
 >  analogous to "goto" inside for loop.
 >  If "for .. in .. index" extension is implemented, it may be used to call


 As I explained in my previous reply to Paul - I did not expect for-in
 to support everything I use with Iterators. I simply wanted to find
 out if the for-in implementation is going to clash with my idea of
 implementing GetIterator() in RTL's container classes. So far I don't
 see any problems, and I can't see why we can't implement both. There
 are use-cases for both.  I see for-in as a "lite" version of Iterator,
 but I still have a need for a more "full" implementation as well -
 supporting a larger method interface.


 > It does not. I dislike the "Enumerator" term too, but this is how it
 >  is called in Delphi :-(

 Java uses both, that is why I asked. But yes, I kind-of expected them
 to be the same thing, but just wanted to make sure.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Graeme Geldenhuys
On 25/10/2009, Alexander Klenin  wrote:
>
> IMHO, Reset/JumpToBack should not be used inside "for..in" loop -- they are
>  analogous to "goto" inside for loop.
>  If "for .. in .. index" extension is implemented, it may be used to call


As I explained in my previous reply to Paul - I did not expect for-in
to support everything I use with Iterators. I simply wanted to find
out if the for-in implementation is going to clash with my idea of
implementing GetIterator() in RTL's container classes. So far I don't
see any problems, and I can't see why we can't implement both. There
are use-cases for both.  I see for-in as a "lite" version of Iterator,
but I still have a need for a more "full" implementation as well -
supporting a larger method interface.


> It does not. I dislike the "Enumerator" term too, but this is how it
>  is called in Delphi :-(

Java uses both, that is why I asked. But yes, I kind-of expected them
to be the same thing, but just wanted to make sure.


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Vincent Snijders

Graeme Geldenhuys schreef:

use, like: PeakNext, PeakPrevious, Remove, JumpToBack, etc...



I would call it PeekNext, PeekPrevious, ...

Vincent
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Graeme Geldenhuys
2009/10/25 Paul Ishenin :
>
> To use it in the for-in loop you need to add a function MoveNext: Boolean
> (you can choose any other name but you need to mark it using 'enumerator
> MoveMext' modifier) and property Current: TObject (you can choose any other
> name but you need to mark it using 'enumerator Current' modifier).


Thanks Paul, now I have a much better idea of for-in loop (I started
getting confused during this message thread discussion and lost
track).  As I mentioned in my previous post, I did not expect my idea
of Iterators to work with for-in.  Looking at your examples, I still
agree with my assessment.

for-in can be considered a "lite" version of Iterators. The for-in
syntax however does not replace the need for full Iterator support. By
"full Iterator" I mean having a large set of methods that the user can
use, like: PeakNext, PeakPrevious, Remove, JumpToBack, etc...

So I will continue with my work of Iterator support in all RTL
container classes and use the GetIterator method to create an Iterator
instance. This means the user can decide which method they want to use
to iterate over their container classes and how much control they need
in the looping code. It they only need a front-to-back loop, they can
use for-in syntax,but if they want more control, they can request a
Iterator via GetIterator method.


BTW:
Reading that Delphi article about Enumerators, I must say that your
Implementation seems a lot more flexible by not hard-coding method
names etc... Clearly it pays to discuss ideas first before jumping
into the implementation. CodeGear certainly can learn something from
FPC developers! :-)

-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Alexander Klenin
On Sun, Oct 25, 2009 at 16:49, Paul Ishenin  wrote:
>> When I use
>> iterators, I would like to have the ability to use Current, HasNext,
>> HasPrevious, PeakNext, PeakPrevious, Reset, JumpToBack, pass a filter
>> to GetIterator... etc.
>
> I don't argue but how do you think to use HasPrevious, PeakNext,
> PeakPrevios, Reset, JumpToBack in the for-in loop? Can you suggest a syntax?

IMHO, Reset/JumpToBack should not be used inside "for..in" loop -- they are
analogous to "goto" inside for loop.
If "for .. in .. index" extension is implemented, it may be used to call
HasPrevious, PeakNext, PeakPrevious and other functions that do not
change iterator position.

>> Also, I referred to them in my implementation as Iterators - as per
>> the Iterator design pattern. How does Enumerator differ from Iterator?

It does not. I dislike the "Enumerator" term too, but this is how it
is called in Delphi :-(

-- 
Alexander S. Klenin
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Graeme Geldenhuys
2009/10/25 Paul Ishenin :
>
> I don't argue but how do you think to use HasPrevious, PeakNext,
> PeakPrevios, Reset, JumpToBack in the for-in loop? Can you suggest a syntax?

I did not expect for-in loop to support all the methods I require (or
use), hence the reason I ask, and why I still would like to extend the
list/container classes in the RTL to support those. I googled a bit
more and found that java actually supports both Iterator and
Enumerator in it's container classes. Clearly there is a use-case for
each, and one does not necessarily replace the other.

So if the for-in loop uses GetEnumerator, I can still implement the
GetIterator without conflicting with your implementation.  Looking
more at the Java class documentation, it seems Enumerator is a "lite"
version of Iterator an only supports a  small subset of Iterator
features. This same idea could be applied to the RTL, and for users
that don't want to use for-in loop syntax.


> Delphi enumerator pattern is a structure with one boolean function MoveNext
> and one property Current.  More info is here:

Thanks for the link, I'll go take a look at it shortly...


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New feature discussion: for-in loop

2009-10-25 Thread Paul Ishenin

Graeme Geldenhuys wrote:

Also, I referred to them in my implementation as Iterators - as per
the Iterator design pattern. How does Enumerator differ from Iterator?
  
I have looked at you interfaces. They are needs to be changed a bit to 
use then in the for-in loop. For example:


 ITBIterator = interface(IInterface)
 ['{9C2BC10D-54C8-4B59-88B5-A564921CF0E3}']
   functionHasNext: Boolean;
   functionNext: TObject;
   functionHasPrevious: Boolean;
   functionPrevious: TObject;
 end;

To use it in the for-in loop you need to add a function MoveNext: 
Boolean (you can choose any other name but you need to mark it using 
'enumerator MoveMext' modifier) and property Current: TObject (you can 
choose any other name but you need to mark it using 'enumerator Current' 
modifier).


Look at 
http://svn.freepascal.org/svn/fpc/branches/paul/features/tests/test/tforin8.pp 
and 
http://svn.freepascal.org/svn/fpc/branches/paul/features/tests/test/tforin9.pp 
for examples.


Best regards,
Paul Ishenin.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel