[fpc-devel] Re: New language feature suggestion (probably not existing in Delphi)
sergei_gorelkin at mail.ru
Fri Nov 26 18:05:13 CET 2010
Max Vlasov пишет:
> On Fri, Nov 26, 2010 at 11:42 AM, Max Vlasov <max.vlasov at gmail.com
> <mailto:max.vlasov at gmail.com>> wrote:
> An idea here is to introduce a directive (maybe something else, but
> directive looks more straightforward), let's call it readonly that
> forces the method to be able only to read the fields and properties
> of the object it belongs to and forbid any writing. Sure in this
> case it only can call only the methods also containing such directive.
> Also, one note to consider
> It is know that some of OOP concepts can be implemented with procedural
> language. For example, pseudo-encapsulation with the records.
> Ironically, this idea can be implemented using the emulation.
> procedure MyObjFind(var Rec: TMyObjData) with
> procedure MyObjFind(const Rec: TMyObjData)
> the latter is actual readonly emulation, you won't be able to change
> anything and you won't be able to pass this record by reference to any
> other procedure
I tend to think that the primary goal of introducing 'const' parameters was optimization, not access
restriction. Although I don't know exactly.
More information about the fpc-devel