Recent

Author Topic: FPC is not good designed: humble opinion  (Read 3211 times)

soerensen3

  • Full Member
  • ***
  • Posts: 161
Re: FPC is not good designed: humble opinion
« Reply #15 on: May 15, 2018, 11:37:52 am »
You can only forward declare class and pointer types. This is because when the compiler comes across declaration of a field it can always say it is the size of pointer regardless of which class it is. This is not true for all the other types so one cannot say how a type should be aligned in memory without knowing the type already. I guess you could say, why not postpone it until the type is known. This is of course possible but there is your second pass! And without forward declarations the compiler can not know if a type is a class type or a record or something else. This is why you declare
Code: Pascal  [Select]
  1. TSometype = class;
To tell the compiler it's a class type.
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

Pascal

  • Hero Member
  • *****
  • Posts: 783
Re: FPC is not good designed: humble opinion
« Reply #16 on: May 15, 2018, 12:05:35 pm »
You can only forward declare class and pointer types. This is because when the compiler comes across declaration of a field it can always say it is the size of pointer regardless of which class it is. This is not true for all the other types so one cannot say how a type should be aligned in memory without knowing the type already. I guess you could say, why not postpone it until the type is known. This is of course possible but there is your second pass! And without forward declarations the compiler can not know if a type is a class type or a record or something else. This is why you declare
Code: Pascal  [Select]
  1. TSometype = class;
To tell the compiler it's a class type.

Sure, but that is the case i mentioned (mutual referencing). No problem if it is limited to classes and pointer types. That's all i've needed so far.
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

howardpc

  • Hero Member
  • *****
  • Posts: 2835
Re: FPC is not good designed: humble opinion
« Reply #17 on: May 15, 2018, 12:07:37 pm »
You can only forward declare class and pointer types.

Notwithstanding its single-pass design, the FPC also allows forward declarations of procedures and functions (within expected restrictions).

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6629
Re: FPC is not good designed: humble opinion
« Reply #18 on: May 15, 2018, 12:11:57 pm »
You can only forward declare class and pointer types. 

And afaik within the same type block. Or at least the same unit part (interface)

soerensen3

  • Full Member
  • ***
  • Posts: 161
Re: FPC is not good designed: humble opinion
« Reply #19 on: May 15, 2018, 02:08:54 pm »
You can only forward declare class and pointer types.

Notwithstanding its single-pass design, the FPC also allows forward declarations of procedures and functions (within expected restrictions).
A procedure or function is also a pointer.
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6629
Re: FPC is not good designed: humble opinion
« Reply #20 on: May 15, 2018, 02:21:24 pm »
A procedure or function is also a pointer.

Only as far as any symbol has an address.  Handling is totally different.

And to be exact, it is a "CodePointer",  and might point to a different segment. (e.g. in 16-bit real mode)  O:-) See systemh.inc. 

Thaddy

  • Hero Member
  • *****
  • Posts: 7228
Re: FPC is not good designed: humble opinion
« Reply #21 on: May 15, 2018, 04:48:43 pm »
A procedure or function is also a pointer.
My house has an address but it is not me....It is very likely I live at my address, but it is still my address, not me.

@Marco
How do you explain dangling pointers... :-\ Are they really bums? 8-)
In a real case scenario I lived at Frederik Hendrik laan 287... Now try and find it....(useless. does not exist anymore, although the building is still standing)
« Last Edit: May 15, 2018, 04:52:02 pm by Thaddy »
inline variables like in D10.3 are a bit like Brexit: if you are given the wrong information it sounds like a good idea. Every kid loves candy, but it makes you fat and your teeth will disappear.