[fpc-devel] Feature announcement: Type helpers

Sven Barth pascaldragon at googlemail.com
Wed Feb 6 14:30:20 CET 2013


Am 06.02.2013 14:26, schrieb Ludo Brands:
> On 02/06/2013 01:12 PM, 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 :) )
>>
> Funny to see that all these fans of a strongly typed pascal prefer
> Format() that is using variants, has an undetermined number of
> parameters, doesn't give the compiler any opportunity to check the types
> used and causes runtime errors when a wrong type or a wrong number of
> parameters is passed ;)
But you seperate the view (the format string) from the model (the data 
which is passed in), which is good :)

Regards,
Sven



More information about the fpc-devel mailing list