Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Vincent Snijders

Graeme Geldenhuys schreef:

On 06/01/2010, Florian Klaempfl  wrote:

That's why we've strict private/protected.


Since when is that available in FPC? I didn't know it was.


You are getting old:
http://www.mail-archive.com/fpc-devel@lists.freepascal.org/msg13343.html

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


[fpc-devel] Free Pascal Current Version in www.freepascal.org

2010-01-05 Thread Mehmet Erol Sanliturk



   Current Version

Version /2.2.4/ is the latest stable version the Free Pascal. Hit the 
download  link and select a 
mirror close to you to download your copy. The development releases have 
version numbers /2.3.x/. See the development 
 page how to obtain the latest 
sources and support development.



In the page

http://www.freepascal.org/

and in the above part

it seems that 2.2.4 needs to be 2.4.0 , and 2.3.x needs to be 2.5.x .


Thank you very much .

Mehmet Erol Sanliturk .


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


Re[2]: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Nikolai ZHUBR
Tuesday, January 05, 2010, 11:08:37 PM, Juha Manninen wrote:
> On tiistai, 5. tammikuuta 2010 20:06:42 Florian Klaempfl wrote:
>> Then do the same as in C++ and put it in different include files.

> Right, include files could solve this problem at least partly. They seem to be

Curious enough, nobody even mentioned interfaced objects (interfaces),
though they are available in both FPC and Delphi since ages.

Not that I would recommend this seriously, however here goes:
//---
unit ihelper;

interface

type
  IMyClass1 = Interface;
  IMyClass2 = Interface;

  IMyClass1 = Interface
function SomethingUsefull1: byte;
  end;

  IMyClass2 = Interface
function SomethingMuchMoreUsefull2: longint;
  end;

implementation
end.
//---
unit myunit1;

interface

uses
  classes, ihelper;

type
  Tmyclass1 = class(TInterfacedObject, IMyClass1)
  public
Fmyclass2: IMyClass2;
FSomethingUsefull1: byte;
function SomethingUsefull1: byte;
function CrossFunc1: longint;
  end;

implementation

function Tmyclass1.SomethingUsefull1: byte;
begin
  result := FSomethingUsefull1;
end;

function Tmyclass1.CrossFunc1: longint;
begin
  result := Fmyclass2.SomethingMuchMoreUsefull2;
end;

end.
//---
unit myunit2;

interface

uses
  classes, ihelper;

type
  Tmyclass2 = class(TInterfacedObject, IMyClass2)
  public
Fmyclass1: IMyClass1;
FSomethingMuchMoreUsefull2: longint;
function SomethingMuchMoreUsefull2: longint;
function CrossFunc2: byte;
  end;

implementation

function Tmyclass2.SomethingMuchMoreUsefull2: longint;
begin
  result := FSomethingMuchMoreUsefull2;
end;

function Tmyclass2.CrossFunc2: byte;
begin
  result := Fmyclass1.SomethingUsefull1;
end;

end.
//---
program circexamp;

uses
  myunit1, myunit2;

var
  c1: Tmyclass1;
  c2: Tmyclass2;
begin
  c1 := Tmyclass1.Create;
  c2 := Tmyclass2.Create;
  c1.Fmyclass2 := c2;
  c2.Fmyclass1 := c1;
  c1.FSomethingUsefull1 := 1;
  c2.FSomethingMuchMoreUsefull2 := 2;
  writeln(c1.CrossFunc1);
  writeln(c2.CrossFunc2);
end.
//---


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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Graeme Geldenhuys
On 06/01/2010, Florian Klaempfl  wrote:
>
> That's why we've strict private/protected.

Since when is that available in FPC? I didn't know it was.



-- 
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] Circular references and forward declarations

2010-01-05 Thread Florian Klaempfl
Graeme Geldenhuys schrieb:
> On 05/01/2010, Martin Sucha  wrote:
>> You should be able to achieve that by putting some ifdefs around interface 
>> and
>>  implementation (and other) parts of your autogenerated programs and then for
>>  example
> 
> True and I have done this before. BIG problem is that class visibility
> goes out the window! All classes can access ALL private and protected
> field variables or methods of other classes. NOT GOOD!

That's why we've strict private/protected.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Graeme Geldenhuys
On 05/01/2010, Martin Sucha  wrote:
> You should be able to achieve that by putting some ifdefs around interface and
>  implementation (and other) parts of your autogenerated programs and then for
>  example

True and I have done this before. BIG problem is that class visibility
goes out the window! All classes can access ALL private and protected
field variables or methods of other classes. NOT GOOD!


-- 
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] Circular references and forward declarations

2010-01-05 Thread Marco van de Voort
In our previous episode, Graeme Geldenhuys said:
[ Charset UTF-8 unsupported, converting... ]
> On 05/01/2010, Marco van de Voort  wrote:
> >
> >  You can only not have multiple design forms in one class, but the
> 
> That's a limitation specific to Delphi and Lazarus. Remember a Form is
> also a class. So if you can have multiple classes in a unit, why can't
> you have multiple form class in a single unit.

Sure. The whole "design" point is that this is above the language level.

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


Re: Re[2]: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Graeme Geldenhuys
On 05/01/2010, JoshyFun  wrote:
>
>  interface
>  [...]
>  {$I InterfaceOnly C:\.pas}
>  [...]
>  Implementation
>  {$I ImplementationOnly C:\.pas}
>  [...]
>
>  I think it will not include a big penalty in the parser, or maybe I'm
>  completly wrong ?


I have done with with 100's of include files. One base unit and one
include file which contains both the interface and implementation. I
had to use defines to solve the latter trick.

This gave you the impression that you are using multiple units with
circular references, but with one BIG flaw! ALL classes could access
all private fields etc. of other classes. This really broke my rules
of class design and visibility, so I stopped using that method.


-- 
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] Circular references and forward declarations

2010-01-05 Thread Graeme Geldenhuys
On 05/01/2010, Marco van de Voort  wrote:
>
>  You can only not have multiple design forms in one class, but the

That's a limitation specific to Delphi and Lazarus. Remember a Form is
also a class. So if you can have multiple classes in a unit, why can't
you have multiple form class in a single unit.

fpGUI Toolkit's UI Designer can and does handle multiple forms defined
in a single unit.


-- 
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] Circular references and forward declarations

2010-01-05 Thread Graeme Geldenhuys
On 05/01/2010, Jonas Maebe  wrote:
> two different units can both declare a different class with the same name
> (just like they can both have global variables and procedures/functions

And I would bitch-slap any developer in my team that tries that!

>  b) add some way to specify the unit name in which this external class is
> specified, or

Delphi's project file already does this (kind of). The uses clause
mentions the unit and the location of that unit.


I must say, I agree with the original poster - it would be very
useful. I have had many battles to try and overcome circular reference
issues, and I do take care in my class designs. Sometimes there are
truly valid designs where x-referencing is needed, and then I have to
find some work-around due to the Object Pascal language - which
normally ends up with lots of type casts in the implementation
section, or bunching classes in a single unit.

Don't ask me for an example, I can't think of one now, but it happened
a few times in our current work project.


-- 
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] Circular references and forward declarations

2010-01-05 Thread Marco van de Voort
In our previous episode, Juha Manninen said:
> 
> You should try to separate user interface from program logic.
> Do only strictly UI specific stuff in form class units. Keep program logic in 
> separate units (or one big separate unit :-)).
> Then program logic unit can reference freely the form units, and form units 
> can reference the logic unit only from implementation section.
> Thus, no circular reference.

If you read the helpful "add language feature" faq 

( http://www.freepascal.org/faq.var#extensionselect   )

mentioned earlier, you'll notice that it advises to work out at least a full
proposal, and keep the idle arguing to a minimum.

Note that there is also an hint about making examples with multiple units.

It's there for a reason, trust me. 

There is more to splitting source up into separately compilable files than
meets the eye, since e.g. resolving the circular dependancies between
classes must result in exactly the same the order of fields, no matter the
what the order of files is. And orders that are not possible must be flagged
as such.
7
How hard this kind of stuff is, is shown by the fact that after 25 years,
and several periods of commercial sponsorship, gcc still has no precompiled
headers standardly.   

The rules that Borland like Pascal's have (no preprocessor state per
compilation but per compilation unit), and the circular dependancy rules are
some of the rules to make this complex matrix of fog a bit more transparent.

Which is why FPC DOES have precompiled headers since before I can remember
(97/98).



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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Juha Manninen
On tiistai, 5. tammikuuta 2010 19:48:39 Horacio Jamilis wrote:

> In my case, my classes are defined in a form unit, so I can not have
> more than 1 class per file (this is a Lazarus project)...
> I know that I should have more divided the visible editing and the class
> itself, and I did, with some tricks, but I continue with the 1 file per
> class implementation.
> so the idea to have 1 big file is not possible ... and if it where, i
> will not like it anyway.
> When I asked for this possibility, I was told to create one big unit
> with abstract classes definitions... that may help me, but never had the
> time to test it...
> I am casting everywhere... It´s ugly and error prone, but is what works.
> 
> So this feature could make my life a lot easier ... but I don´t know how
> to implement it... else I would do it.

That is more about separating user interface from program logic which is a 
fundamental problem with RAD (rapid application development) tools. Many 
people don't like RAD for that reason.
In practice that problem leads to circular reference problems, too.

You should try to separate user interface from program logic.
Do only strictly UI specific stuff in form class units. Keep program logic in 
separate units (or one big separate unit :-)).
Then program logic unit can reference freely the form units, and form units 
can reference the logic unit only from implementation section.
Thus, no circular reference.

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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Vincent Snijders

Martin Sucha schreef:

Hello,

On Tuesday 05 January 2010 20:44:06 JoshyFun wrote:

In the past I had some autogenerated pascal programs, but to include
them in another unit I must manually split the files in interface and
implementation. Would be possible to do something like:




An example is:
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/gtk2/src/gtk%2B/gtk/gtk2.pas?view=markup

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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Martin Sucha
Hello,

On Tuesday 05 January 2010 20:44:06 JoshyFun wrote:
> In the past I had some autogenerated pascal programs, but to include
> them in another unit I must manually split the files in interface and
> implementation. Would be possible to do something like:
> 
> interface
> [...]
> {$I InterfaceOnly C:\.pas}
> [...]
> Implementation
> {$I ImplementationOnly C:\.pas}
> [...]
> 
You should be able to achieve that by putting some ifdefs around interface and 
implementation (and other) parts of your autogenerated programs and then for 
example

interface

{$define InterfaceOnly}
{$I file.pas}
{$undefine InterfaceOnly}

implementation

{$define ImplementationOnly}
{$I file.pas}
{$undefine ImplementationOnly}

Regards,

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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Juha Manninen
On tiistai, 5. tammikuuta 2010 20:06:42 Florian Klaempfl wrote:

> Then do the same as in C++ and put it in different include files.

Right, include files could solve this problem at least partly. They seem to be 
used for actual program code with FPC. Are they treated differently from 
Delphi's include files or is it just convention?

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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Juha Manninen
On tiistai, 5. tammikuuta 2010 20:58:11 Vincent Snijders wrote:
> Florian Klaempfl schreef:
> > Juha Manninen schrieb:
> >> I think it would be EASY to implement.
> >
> > Then propose a patch.
> 
> It surely would prove how easy it would be to implement.
> 
> And if it was rejected, which I doubt, if it were implemented correctly,
> I assume the maintainers of troll pascal would sure accept it :-)
> 
> See also:
> http://www.freepascal.org/faq.var#extensionselect

Ok, I will study the FPC source some day to understand the problems associated 
with circular reference better.

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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Juha Manninen
On tiistai, 5. tammikuuta 2010 20:20:16 Jonas Maebe wrote:
> It would have at least two consequences (there are undoubtedly more that
>  I'm not thinking of currently): a) all forward-declared types from the
>  interface would have to be resolved after the uses-clause in the
>  implementation has been parsed (because only at that point all classes
>  would be known) b) this would cause the interface crc of those units to
>  change (since the types change once they are resolved), which means that
>  every unit containing such a construct (and every unit depending on them,
>  even if they don't touch these types) would be recompiled at least once
>  (some immediately in case of circular interface-implementation unit
>  references, some only when you recompile the project)
> 
> This wouldn't double the compilation time, but it would probably slow down
>  things quite a bit. I'm also not sure whether the ppu storing/logic logic
>  would still work if it could be called at a point where not all
>  forward-declared types are resolved. It would probably require special
>  code for that situation.

I realize that you know the compiler better than me, but some more thoughts of 
mine anyway:

The only information needed for the interface section is that the variable's 
type is object (class instance). It could be treated as TObject during the 
interface parsing. The same thing as when forward declaring a class inside a 
unit. The forward declaration only says it is a class, no mention of its 
ancestor, data members or methods.
The class's members are used only in implementation section, but there the 
class's "home unit" is included in uses clause already and it is no different 
from the current situation.

Ok, I understand the class's member info is stored somewhere at the end of 
interface section, the compiler would need more fundamental changes if that 
info was not available then.
But still, the same space is reserved for a variable of any object, be it 
TObject or TMyClass. If I only could tell the compiler that my variable is 
actually TMyClass, not TObject, and then use code completion features and 
avoid casting.
Hey, there could be an Alias syntax. First, in interface:
  MyVar: TObject;
Then in implementation section:
  MyVar = alias TMyClass

... not very good. The point is anyway that my variable is basically a pointer 
to an object and the compiler should understand that.


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


Re[2]: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread JoshyFun
Hello Florian,

Tuesday, January 5, 2010, 7:06:42 PM, you wrote:

FK> I never looked at VirtualTreeView but I doubt that the 34k line source
FK> is a language problenm.
>> Programmer should have a choice to split it
FK> Good languages prevent programms to do ugly things :)
>> if he wants.

This is not 100% related with topic, but I would ask if one proposal
have sense in the Pascal "spirit".

In the past I had some autogenerated pascal programs, but to include
them in another unit I must manually split the files in interface and
implementation. Would be possible to do something like:

interface
[...]
{$I InterfaceOnly C:\.pas}
[...]
Implementation
{$I ImplementationOnly C:\.pas}
[...]

I think it will not include a big penalty in the parser, or maybe I'm
completly wrong ?

-- 
Best regards,
 JoshyFun

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


Re: [fpc-devel] Free Pascal 2.4.0 released

2010-01-05 Thread Vincent Snijders

Marco van de Voort schreef:

Downloads are available at:

In ftp://freepascal.stack.nl/pub/fpc/dist/2.4.0/x86_64-linux/ there are 
no debs for amd64. Will the fpc team provides these in the near future 
or do we have to wait until a fpc user will build them or until they are 
in debian sid?


Vincent


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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Horacio Jamilis

El 05/01/2010 15:48, Marco van de Voort escribió:

In our previous episode, Horacio Jamilis said:
   

I need this feature too, and I like this proposed syntax.

In my case, my classes are defined in a form unit, so I can not have
more than 1 class per file (this is a Lazarus project)...
 

It's perfectly possible to have more than 1 class per file. Also in Lazarus.

You can only not have multiple design forms in one class, but the designer
in those other languages almost sure can't handle circular classes either.
   


In my project, each class is linked to one form, and defined in the same 
unit as the form.


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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Vincent Snijders

Florian Klaempfl schreef:

Juha Manninen schrieb:

If I create a feature request issue for this, does it have any chance of being 
implemented? 


No.


I think it would be EASY to implement.


Then propose a patch.


It surely would prove how easy it would be to implement.

And if it was rejected, which I doubt, if it were implemented correctly, 
I assume the maintainers of troll pascal would sure accept it :-)


See also:
http://www.freepascal.org/faq.var#extensionselect

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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Marco van de Voort
In our previous episode, Horacio Jamilis said:
> I need this feature too, and I like this proposed syntax.
> 
> In my case, my classes are defined in a form unit, so I can not have 
> more than 1 class per file (this is a Lazarus project)...

It's perfectly possible to have more than 1 class per file. Also in Lazarus.

You can only not have multiple design forms in one class, but the designer
in those other languages almost sure can't handle circular classes either.

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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Florian Klaempfl
Jonas Maebe schrieb:
> On 05 Jan 2010, at 17:45, Juha Manninen wrote:
> 
>> On tiistai, 5. tammikuuta 2010 18:14:53 Jonas Maebe wrote:
>>> The reason that they are conceptually not the same thing is that
>>> in Pascal two different units can both declare a different class
>>> with the same name (just like they can both have global variables
>>> and procedures/functions in the interface with the same name).
>>> You would at least have to do something like one of the following
>>>  a) use one global name space for all classes (i.e., forbid that
>>> two different units used in a program declare a class with the
>>> same name anywhere), or b) add some way to specify the unit name
>>> in which this external class is specified, or
>>> 
>>> There might be other solutions (maybe some kind of class-specific
>>>  namespace support), but it would definitely require some more
>>> language features rather than merely accepting anonymous class
>>> definitions anywhere. Otherwise the type checking is going to run
>>> completely haywire.
>> Yes, I even suggested a syntax: TMyClass = class; defined in
>> "MyUnit.pas"
> 
> You're right, sorry.
> 
>> which would solve the namespace issue. It is the case b) you
>> listed. It could also be: MyUnit.TMyClass = class;
>> 
>> which is similar than syntax referencing global variables from
>> another unit.
> 
> It would have at least two consequences (there are undoubtedly more
> that I'm not thinking of currently): a) all forward-declared types
> from the interface would have to be resolved after the uses-clause in
> the implementation has been parsed (because only at that point all
> classes would be known) b) this would cause the interface crc of
> those units to change (since the types change once they are
> resolved), which means that every unit containing such a construct
> (and every unit depending on them, even if they don't touch these
> types) would be recompiled at least once (some immediately in case of
> circular interface-implementation unit references, some only when you
> recompile the project)
> 
> This wouldn't double the compilation time, but it would probably slow
> down things quite a bit. I'm also not sure whether the ppu
> storing/logic logic would still work if it could be called at a point
> where not all forward-declared types are resolved. It would probably
> require special code for that situation.

Defining forward types in a different unit breaks completly with the
spirit how object pascal is designed and I fear it will break much more
stuff in the compiler. Changing interface CRCs are probably only one of
the prominent problems. Resolving cyclic forward class references
between units will be probably a real nightmare.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Jonas Maebe

On 05 Jan 2010, at 17:45, Juha Manninen wrote:

> On tiistai, 5. tammikuuta 2010 18:14:53 Jonas Maebe wrote:
>> The reason that they are conceptually not the same thing is that in
>> Pascal two different units can both declare a different class with the
>> same name (just like they can both have global variables and
>> procedures/functions in the interface with the same name). You would
>> at least have to do something like one of the following
>> a) use one global name space for all classes (i.e., forbid that two
>> different units used in a program declare a class with the same name
>> anywhere), or
>> b) add some way to specify the unit name in which this external class
>> is specified, or
>> 
>> There might be other solutions (maybe some kind of class-specific
>> namespace support), but it would definitely require some more language
>> features rather than merely accepting anonymous class definitions
>> anywhere. Otherwise the type checking is going to run completely
>> haywire.
> 
> Yes, I even suggested a syntax:
>  TMyClass = class; defined in "MyUnit.pas"

You're right, sorry.

> which would solve the namespace issue. It is the case b) you listed.
> It could also be:
>  MyUnit.TMyClass = class;
> 
> which is similar than syntax referencing global variables from another unit.

It would have at least two consequences (there are undoubtedly more that I'm 
not thinking of currently):
a) all forward-declared types from the interface would have to be resolved 
after the uses-clause in the implementation has been parsed (because only at 
that point all classes would be known)
b) this would cause the interface crc of those units to change (since the types 
change once they are resolved), which means that every unit containing such a 
construct (and every unit depending on them, even if they don't touch these 
types) would be recompiled at least once (some immediately in case of circular 
interface-implementation unit references, some only when you recompile the 
project)

This wouldn't double the compilation time, but it would probably slow down 
things quite a bit. I'm also not sure whether the ppu storing/logic logic would 
still work if it could be called at a point where not all forward-declared 
types are resolved. It would probably require special code for that situation.


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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Florian Klaempfl

Juha Manninen schrieb:

On tiistai, 5. tammikuuta 2010 19:16:25 Florian Klaempfl wrote:

See e.g. the compiler, but how does a big source file hurt anyways?
Today, navigation is done by the IDE and cvs times are also gone when
big files were a problem to commit. I consider class reference refering
some external files not better than one big file if this is really
needed. Things being interwinded can also end in the same file.


Ok, that is a good point but then we are talking about a different thing 
already. Now the question is whether a huge source file is a bad thing or not.
IMO, the compiler should not force a programmer to make a 34 000 lines source 
file (like VirtualTreeView has). 


I never looked at VirtualTreeView but I doubt that the 34k line source 
is a language problenm.


Programmer should have a choice to split it 


Good languages prevent programms to do ugly things :)


if he wants.


Then do the same as in C++ and put it in different include files.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Juha Manninen
On tiistai, 5. tammikuuta 2010 19:16:25 Florian Klaempfl wrote:
> See e.g. the compiler, but how does a big source file hurt anyways?
> Today, navigation is done by the IDE and cvs times are also gone when
> big files were a problem to commit. I consider class reference refering
> some external files not better than one big file if this is really
> needed. Things being interwinded can also end in the same file.

Ok, that is a good point but then we are talking about a different thing 
already. Now the question is whether a huge source file is a bad thing or not.
IMO, the compiler should not force a programmer to make a 34 000 lines source 
file (like VirtualTreeView has). Programmer should have a choice to split it 
if he wants.

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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Horacio Jamilis

El 05/01/2010 13:07, Juha Manninen escribió:

Why is it not allowed from another unit? They are conceptually the same thing!
The problem could be solved easily if there was a forward declaration saying:
   TMyClass = class; defined in "MyUnit.pas"
   


I need this feature too, and I like this proposed syntax.

In my case, my classes are defined in a form unit, so I can not have 
more than 1 class per file (this is a Lazarus project)...
I know that I should have more divided the visible editing and the class 
itself, and I did, with some tricks, but I continue with the 1 file per 
class implementation.
so the idea to have 1 big file is not possible ... and if it where, i 
will not like it anyway.
When I asked for this possibility, I was told to create one big unit 
with abstract classes definitions... that may help me, but never had the 
time to test it...

I am casting everywhere... It´s ugly and error prone, but is what works.

So this feature could make my life a lot easier ... but I don´t know how 
to implement it... else I would do it.


It is with no doubt in my wish list.

Good luck on this

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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Florian Klaempfl

Juha Manninen schrieb:

On tiistai, 5. tammikuuta 2010 18:39:21 Florian Klaempfl wrote:

I knew all the reasoning, but honestly, I don't see a point in it. I
used C++ for years professionally and I always avoided circular
references/implementing classes in different files than the header is
named so I see no need in pascal either (and I never needed it).


Hmmm...
In real programs there are classes that are big and are logically their own 
entities (or how to put it), but still they must refer to other similar 
classes in other units. I don't know how you have solved this without putting 
everything into one big file.


See e.g. the compiler, but how does a big source file hurt anyways?
Today, navigation is done by the IDE and cvs times are also gone when
big files were a problem to commit. I consider class reference refering
some external files not better than one big file if this is really
needed. Things being interwinded can also end in the same file.


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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Juha Manninen
On tiistai, 5. tammikuuta 2010 18:39:21 Florian Klaempfl wrote:
> I knew all the reasoning, but honestly, I don't see a point in it. I
> used C++ for years professionally and I always avoided circular
> references/implementing classes in different files than the header is
> named so I see no need in pascal either (and I never needed it).

Hmmm...
In real programs there are classes that are big and are logically their own 
entities (or how to put it), but still they must refer to other similar 
classes in other units. I don't know how you have solved this without putting 
everything into one big file.

I mentioned 2 examples, Virtaual TreeView and Lazarus that have huge source 
files. My own programs suffer from the same thing (but they are not published, 
can't show them now).


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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Marco van de Voort
In our previous episode, Jonas Maebe said:
> There might be other solutions (maybe some kind of class-specific  
> namespace support), but it would definitely require some more language  
> features rather than merely accepting anonymous class definitions  
> anywhere. Otherwise the type checking is going to run completely  
> haywire.

It would also change how the compiler finds files. In Java the namespace can
be distilled from the classpath hierarchies, in FPC there is no such helper.
The compiler only gets some dirs and main .dpr and must be able to derive
how to compile all units in the correct order.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Juha Manninen
On tiistai, 5. tammikuuta 2010 18:14:53 Jonas Maebe wrote:
> On 05 Jan 2010, at 17:07, Juha Manninen wrote:
> > Forward declaration of a class is allowed inside a unit. There can
> > be a
> > reference to a class before it is defined! Like:
> >  TMyClass = class;
> >
> > Why is it not allowed from another unit? They are conceptually the
> > same thing!
> 
> The reason that they are conceptually not the same thing is that in
> Pascal two different units can both declare a different class with the
> same name (just like they can both have global variables and
> procedures/functions in the interface with the same name). You would
> at least have to do something like one of the following
> a) use one global name space for all classes (i.e., forbid that two
> different units used in a program declare a class with the same name
> anywhere), or
> b) add some way to specify the unit name in which this external class
> is specified, or
> 
> There might be other solutions (maybe some kind of class-specific
> namespace support), but it would definitely require some more language
> features rather than merely accepting anonymous class definitions
> anywhere. Otherwise the type checking is going to run completely
> haywire.

Yes, I even suggested a syntax:
  TMyClass = class; defined in "MyUnit.pas"

which would solve the namespace issue. It is the case b) you listed.
It could also be:
  MyUnit.TMyClass = class;

which is similar than syntax referencing global variables from another unit.


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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Florian Klaempfl
Juha Manninen schrieb:
> On tiistai, 5. tammikuuta 2010 18:07:38 Florian Klaempfl wrote:
>> Juha Manninen schrieb:
>>> If I create a feature request issue for this, does it have any chance of
>>> being implemented?
>> No.
> 
> Well thanks, that was a quick answer. According to timestamp you answered my 
> mail before I sent it!
> In this virtual internet reality everything is possible. :-)
> 
> I hope you read my reasoning, too. 

I knew all the reasoning, but honestly, I don't see a point in it. I
used C++ for years professionally and I always avoided circular
references/implementing classes in different files than the header is
named so I see no need in pascal either (and I never needed it).

> I wrote the mail after reading many related 
> discussions and after being frustrated many times because of this limitation. 
> So, this was not one of the "me too, I found something to complain" messages 
> but a real problem.


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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Juha Manninen
On tiistai, 5. tammikuuta 2010 18:07:38 Florian Klaempfl wrote:
> Juha Manninen schrieb:
> > If I create a feature request issue for this, does it have any chance of
> > being implemented?
> 
> No.

Well thanks, that was a quick answer. According to timestamp you answered my 
mail before I sent it!
In this virtual internet reality everything is possible. :-)

I hope you read my reasoning, too. I wrote the mail after reading many related 
discussions and after being frustrated many times because of this limitation. 
So, this was not one of the "me too, I found something to complain" messages 
but a real problem.

Regards,
Juha Manninen
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Jonas Maebe


On 05 Jan 2010, at 17:07, Juha Manninen wrote:

Forward declaration of a class is allowed inside a unit. There can  
be a

reference to a class before it is defined! Like:
 TMyClass = class;

Why is it not allowed from another unit? They are conceptually the  
same thing!


The reason that they are conceptually not the same thing is that in  
Pascal two different units can both declare a different class with the  
same name (just like they can both have global variables and  
procedures/functions in the interface with the same name). You would  
at least have to do something like one of the following
a) use one global name space for all classes (i.e., forbid that two  
different units used in a program declare a class with the same name  
anywhere), or
b) add some way to specify the unit name in which this external class  
is specified, or


There might be other solutions (maybe some kind of class-specific  
namespace support), but it would definitely require some more language  
features rather than merely accepting anonymous class definitions  
anywhere. Otherwise the type checking is going to run completely  
haywire.



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


Re: [fpc-devel] Circular references and forward declarations

2010-01-05 Thread Florian Klaempfl
Juha Manninen schrieb:

> 
> If I create a feature request issue for this, does it have any chance of 
> being 
> implemented? 

No.

> I think it would be EASY to implement.

Then propose a patch.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] Circular references and forward declarations

2010-01-05 Thread Juha Manninen
Hello.

My proposal:
Please allow a forward declaration of a class which is defined in another 
unit, maybe using a new syntax for the declaration.
Alternatively, allow circular references just like other programming languages 
do.

Forbidden circular references is a major annoyance in Object Pascal and one of 
the main (!) reasons why it is not popular for big projects.
I remember comments from other programmers like: "Delphi is not suitable for 
serious SW projects because the source files can't reference each other and 
you must put everything into one big file."
Then I was arguing that no, it is not true, there are ways to go around it. 
Later I did some "serious SW projects" with Delphi and changed my mind.

The problem is about referencing classes between units. Say you have unit 
MyUnit defining class TMyClass. In a typical circular reference situation you 
must define a variable MyVar as TObject (although it's actually TMyClass) and 
then cast it in the implementation section as TMyClass(MyVar).
Very clumsy! And worse, you can't use the nice code completion features of 
your IDE when the variable is defined as "TObject".

One suggestion has been to create an abstract base class into a separate unit 
and reference that in both the inherited class's unit and in the dependent 
unit. Well, I tried that.
First, it creates a completely useless unit, making the code harder to 
understand.
Second, it didn't solve the problem. In REAL programming situations I 
sometimes had to refer to data members in the inherited class (not included in 
the abstract base class to avoid circular reference). Then I again had to cast 
the variable which effectively nullified the whole effort. I could have used 
the "TObject method" as well.

Finally I gave up and copy-pasted everything into one big unit. That's 
apparently what all "serious" Object Pascal projects must do. Virtual TreeView 
is one big file. Lazarus has units of almost 20 000 lines. It is really too 
much. Or, it would be ok if the programmer really wanted to do so but the 
compiler should not force it!

Think of this:
Forward declaration of a class is allowed inside a unit. There can be a 
reference to a class before it is defined! Like:
  TMyClass = class;

Why is it not allowed from another unit? They are conceptually the same thing!
The problem could be solved easily if there was a forward declaration saying:
  TMyClass = class; defined in "MyUnit.pas"
or 
  TMyClass = class; defined outside
or whatever...
That would not create a circular reference error because MyUnit would not be 
in uses clause. IMO, simply allowing circular reference would be the easiest 
solution but maybe it creates some technical problem which I don't know 
about... Well, most other languages can do it...

Many people asked about circular reference in Delphi mailing lists. The 
answers were basically like: "This is the way it is defined and it will not 
change."
Most programmers have switched to some other programming language.
What a surprise!

If I create a feature request issue for this, does it have any chance of being 
implemented? I think it would be EASY to implement. Some other features like 
generics and closures (anonymous functions) need much more effort.


Yours,
Juha Manninen
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] custom ThreadManager and MemoryMutexManager for hard realtime

2010-01-05 Thread Stefan Kisdaroczi
hi,

to create hard realtime linux programs with freepascal and xenomai [1] in 
userspace
I'm installing a custom ThreadManager and a MemoryMutexManager on program init 
like this:
  SetThreadManager( XenoThreadManager );
  SetMemoryMutexManager( XenoMemoryMutexManager );

This worked until 2.2.4. With fpc 2.4.0, TMemoryMutexManager was removed with 
commit
"r7407 20.5.2007 + heap manager now per thread, reduce heap lock contention"

Looking at rtl/inc/heap.inc from 2.4.0 it seems that the locking is now done 
using "CriticalSections",
is that true ?

To adapt my ThreadManager for 2.4.0 I think I have to:
- remove the SetMemoryMutexManager() call
- implement the *CriticalSection() calls in my XenoThreadManager

Has someone any hints, comments or concerns about the approach ?
Anyone else interested in building hard realtime programs using fpc and xenomai 
?

thank you
kisda

[1] Xenomai Real-Time Framework for Linux - www.xenomai.org



signature.asc
Description: OpenPGP digital signature
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel