Peter Popov пишет:


if OOP is about data encapsulation, why are we using global constants and
types?

You forget that units already provide one encapsulation level. This has been a distinct feature of Pascal long before C++ introduced namespaces. This means that Unit1.PI and Unit2.PI are two different entities. I think that is more than enough, as far as constants are concerned. So, what the class constant really implements is an inline function, returning a fixed value. Thus, the mechanism is already there and providing a meaningless language expansion goes the C++ way: every programming paradigm can be done in several different ways. This confuses the inexperienced mind and leads to the above mentioned absurdities.

While this is true, it is also true that Pascal unit encapsulation level was introduced also long before objects/classes appeared in the very same Pascal. Today, classes serve as namespaces of their own, but these namespaces are limited in comparison with unit namespaces, because they can contain only methods, fields and properties.

Also, there are not only 'true' constants, but typed constants, too. I believe that nothing technically prevents using space of class VMT for storing not only method pointers, but other data as well.

Regards,
Sergei
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to