Recent

Author Topic: [Solved] RTL type helpers conflict with mines  (Read 5091 times)

guest58172

  • Guest
[Solved] RTL type helpers conflict with mines
« on: December 29, 2016, 09:14:48 am »
How can I disable the type helpers defined in syshelp ? TStringHelper conflicts with mine, which I extensively use for path manipulation, which does not the RTL version.

Tell me it's possible please...even if

https://github.com/graemeg/freepascal/blob/ae38cbc2d8a20fc3e6059ee7d77916efcb4fed1b/rtl/objpas/sysutils/sysutils.inc#L43

leads me to think it's not.


guest58172

  • Guest
Re: RTL type helpers conflict with mines
« Reply #1 on: December 29, 2016, 09:22:52 am »
It's hardly believable.

You (RTL devels) should put the helpers in a separate unit. Now each time someone uses sysutils he has those helpers. The worst is that there can only be one helper per type.

guest58172

  • Guest
Re: RTL type helpers conflict with mines
« Reply #2 on: December 29, 2016, 09:31:40 am »
Never mind, with helper inheritence this works, although unit order matters, e.g

Code: Pascal  [Select][+][-]
  1. uses myunit, sysutils;

helper of "myunit" doesn't work

Code: Pascal  [Select][+][-]
  1. uses sysutils, myunit;

helper of "myunit" work


Thaddy

  • Hero Member
  • *****
  • Posts: 14363
  • Sensorship about opinions does not belong here.
Re: RTL type helpers conflict with mines
« Reply #3 on: December 29, 2016, 11:41:31 am »
As usual this is also documented.
There's even a feature for it: prefix the helper you want with its unit name and a dot.

Not to put too fine a dot/point to it, but that has been the case for scope resolution for a looooooonnnnnnggggg time.   >:D

Why do people hate reading simple and good documentation, well written, clear....
« Last Edit: December 29, 2016, 11:44:47 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: RTL type helpers conflict with mines
« Reply #4 on: December 29, 2016, 02:29:32 pm »
IIRC

type Thehelpername = unit.thehelpername;

in the using program/unit avoids having to prefix them all with unitname, and is still protected against accidental rearranging of the uses clause

Thaddy

  • Hero Member
  • *****
  • Posts: 14363
  • Sensorship about opinions does not belong here.
Re: RTL type helpers conflict with mines
« Reply #5 on: December 29, 2016, 02:46:29 pm »
Marco, that does not work for two helpers for the same class in different units. It works with the prefix. It is also bad design. But anyway, even helpers are bad design ;/
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: RTL type helpers conflict with mines
« Reply #6 on: December 29, 2016, 03:01:36 pm »
Marco, that does not work for two helpers for the same class in different units. It works with the prefix. It is also bad design. But anyway, even helpers are bad design ;/
Weird, it should get that helper to the local scope that is higher than any of the imported units.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5462
  • Compiler Developer
Re: RTL type helpers conflict with mines
« Reply #7 on: January 07, 2017, 02:15:07 pm »
@Marco: at first I would have said it's a bug in FPC, cause helpers require a bit of special handling, but a quick check with Delphi showed that they don't do that either.

@BBasile: Helper types follow common scoping rules: The helper from the last included unit wins.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: RTL type helpers conflict with mines
« Reply #8 on: January 07, 2017, 03:17:27 pm »
@Marco: at first I would have said it's a bug in FPC, cause helpers require a bit of special handling, but a quick check with Delphi showed that they don't do that either.

IMHO it is still a bug in FPC (and thus in delphi too :)

PascalDragon

  • Hero Member
  • *****
  • Posts: 5462
  • Compiler Developer
Re: RTL type helpers conflict with mines
« Reply #9 on: January 07, 2017, 03:32:58 pm »
If we agree on that I'd of course be inclined to fix it in FPC ;)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: RTL type helpers conflict with mines
« Reply #10 on: January 07, 2017, 08:04:37 pm »
If we agree on that I'd of course be inclined to fix it in FPC ;)

If you can't see a reason why Delphi does it the way it does it sounds like a lack of orthogonality, and I can't see a reason how a change like this would blow up in our face.

 

TinyPortal © 2005-2018