[fpc-devel] Feature announcement: Type helpers
Henry Vermaak
henry.vermaak at gmail.com
Wed Feb 6 14:03:27 CET 2013
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.
Henry
More information about the fpc-devel
mailing list