[fpc-devel] Feature announcement: Type helpers
Sven Barth
pascaldragon at googlemail.com
Wed Feb 6 14:33:09 CET 2013
Am 06.02.2013 14:03, schrieb Henry Vermaak:
> On Wed, Feb 06, 2013 at 01:12:59PM +0100, Sven Barth wrote:
>> Am 06.02.2013 12:13, schrieb Henry Vermaak:
>>> Thanks for pointing out the advantages. I can see the point, but can't
>>> help to think that I'll be reading code like this soon:
>>>
>>> s := '(' + x.ToString + ', ' + y.ToString + ')';
>>>
>>> Instead of
>>>
>>> s := Format('(%d, %d)', [x, y]);
>> I suppose there are quite some people (especially newbies ^^) who
>> write it like this:
>>
>> s := '(' + IntToStr(x) + ', ' + IntToStr(y) + ')';
>>
>> And here I would prefer the "ToString" variant (but my personal
>> favorit is the "Format" one :) )
> No, you miss my point. Let me put it this way: You're trading one type
> of discoverability for another.
>
> With type helpers, it becomes easy to discover that I can type
> x.<Ctrl-Space> and immediately see ToString. But I'll never learn of
> Format(), Trim(), etc. this way.
>
> With IntToStr, the initial discoverability is hard, since I need to know
> about IntToStr in the first place. But when I <Ctrl-Click> on IntToStr,
> I immediately see Format(), Trim(), AdjustLineBreaks(), etc.
But he might or might not scroll far enough to see these methods... and
even then it is not known whether he'll immediately relate "Format" to
"I can get a string from e.g. Integers".
Note: As I've wrote, I personally prefer Format, so I'm not necesserily
defending the use of type helpers...
Regards,
Sven
More information about the fpc-devel
mailing list