[fpc-devel] Feature announcement: Type helpers

Michael Van Canneyt michael at freepascal.org
Wed Feb 6 12:26:46 CET 2013



On Wed, 6 Feb 2013, Henry Vermaak wrote:

> On Wed, Feb 06, 2013 at 11:52:27AM +0100, Michael Van Canneyt wrote:
>> On Wed, 6 Feb 2013, Marco van de Voort wrote:
>>
>>> In our previous episode, Michael Van Canneyt said:
>>>>> Well, newbies are not to strong in knowing what is which unit either :-)
>>>>
>>>> If we're talking newbies and IDE:
>>>>
>>>> They don't need to, if the IDE puts the unit in the uses clause to start with...
>>>
>>> That's completely new functionality. Afaik most unit adding of IDEs is
>>> hardcoded?.
>>
>> I know. The codetools need to recognize type helpers in the first
>> place.
>>
>> Then we can start thinking about changing the default unit uses clause.
>> For instance in the package lazarusforeducation or so.
>>
>> Anyway, I just wanted to point out which advantages I see (or do not see) in type helpers.
>
> 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]);
>
> What I'm trying to say with this (admittedly contrived) example is that
> when you are forced to read the docs to find out which functions you can
> use for converting numbers to strings, you'll probably discover
> functions like Format.  At least in my case, the most useful tricks I
> learn come from reading the documentation for something, then exploring
> a bit.

True. It gets worse:

One can wonder whether

   s:='(%d, %d)'.format([x, y]);

is more or less clear than

   s := Format('(%d, %d)', [x, y]);

:-)

Michael.



More information about the fpc-devel mailing list