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

Max Vlasov max.vlasov at gmail.com
Fri Nov 26 17:36:41 CET 2010


On Fri, Nov 26, 2010 at 11:42 AM, Max Vlasov <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.

Compare

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

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


More information about the fpc-devel mailing list