[Lazarus] [fpc-devel] win64 dwarf patch

Michael Van Canneyt michael at freepascal.org
Sat Oct 16 14:52:09 CEST 2010



On Sat, 16 Oct 2010, And3mD wrote:

> OK, I understand. The terrible thing is that I saw using Tag as Pointer in 
> some delphi books.

The authors of these books are advocating wrong things.
It is wrong to follow or encourage this practice.
They get away with it because delphi is 32-bit only.

In a cross-platform world, advocating this is simply criminal.

> That's implicate a lot of code with Tag as pointers. Maybe adding non 
> streamed TagPtr:PtrInt will be the best compromise?

No. for several reasons:

a) Pascal is a typesafe language.
    Using Tag as a Pointer is simply wrong and goes against all Pascal stands for.

b) Adding this adds another 8 bytes to each and every component in memory.
   Increasing memory usage to encourage wrong programming practice would be
   very bad practice indeed.

Borland should have done the right thing and add something to TComponent like
   Property CustomData : TObject 
or so, as a public property.

Normally I would propose this, but point b) still needs to be taken into account.

Michael.

>
> Andrzej Kilijański
>
>
> Dnia 16-10-2010 o 12:57:44 Michael Van Canneyt <michael at freepascal.org> 
> napisał(a):
>
>>
>>
>> On Sat, 16 Oct 2010, Hans-Peter Diettrich wrote:
>>
>>> And3mD schrieb:
>>>> I added bug report about using Tag as Pointers in IDE
>>>>  http://bugs.freepascal.org/view.php?id=17642
>>>
>>> For some reason (read-only???) I could not add a note there, so I'll 
>>> present my ideas here:
>>>
>>> IMO Tag should become an int64 for all components, to overcome platform 
>>> and streaming problems. More properties can be introduced, for best 
>>> compatibility with existing code (Tag64, TagPtr). These properties 
>>> could be based on the same int64 field, i.e. r/w part of it, and only 
>>> that field is streamed. And when we just are extending the type, we 
>>> also could consider to make it big enough to hold a method reference...
>>
>> Using tag as a pointer is plain wrong coding, so this change will not 
>> make it.
>>
>> Moreover, streaming it is pure nonsense: There is no guarantee that your 
>> pointer
>> will point to the same object, or indeed whether it will exist at all 
>> when the program is run.
>>
>> The IDE code is simply wrong, and should be fixed properly by creating a 
>> TMenuItem descendent that contains a reference to the notebook page, and 
>> use that class when constructing the menu.
>>
>> Michael.
>>
>> --
>> _______________________________________________
>> Lazarus mailing list
>> Lazarus at lists.lazarus.freepascal.org
>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>


More information about the Lazarus mailing list