[fpc-devel] New language feature suggestion (probably not existing in Delphi)

Max Vlasov max.vlasov at gmail.com
Fri Nov 26 17:19:09 CET 2010

On Fri, Nov 26, 2010 at 6:57 PM, Sergei Gorelkin <sergei_gorelkin at mail.ru>wrote:

> Max Vlasov пишет:
>>   > Speaking of new features, I remember the bunch of them were introduced
>> with Delphi 1.0 and many of them were inspired by other languages and
>> dialects. I admit that frequent implementing of features like the one I
>> suggested will make fpc more experimental and less solid. So consider it an
>> idea just thrown in the wild to see whether it will survive or not :)
>>  This particular idea probably won't survive. In 'unsafe' language with
> pointers, there's no way to enforce the restriction you suggest. It will
> only cause annoyance and make people implement 'workarounds'.
Sergei, around what code? if implemented, by default all methods read/write.
If a developer restricts readonly directive to its own method, it is his own
decision. For example, you're writing method Find, you understand that it
hasn't change anything in the object state, you apply this directive to help
yourself in the future :) if you talk about virtual readonly method someone
introduced, it's similar to private section of object, you can love it or
hate it, but this features exists (sure sometimes bringing real pain :)
restricting usage of this method in other units.

Another example, you successfully wrote first version of a method with
reaonly directive, you try to change something several months later and one
of your changes is try to change a field inside method implementaion, the
compiler points out to the restriction and stops. You have two options: beat
yourself for this silly change or understand that the state changing is
really needed. If the latter, ok, press ctrl-shift-up, and delete reaonly
directive, no problem :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20101126/0acddaf0/attachment.html>

More information about the fpc-devel mailing list