[fpc-pascal] class constants

Vinzent Hoefler JeLlyFish.software at gmx.net
Fri Jan 25 07:59:12 CET 2008


On Thursday 24 January 2008 20:27, Marco van de Voort wrote:
> > On 24 Jan 2008, at 19:45, Marco van de Voort wrote:
> > >> constants.
> > >
> > > A constant is already in a scope, the unit.
> >
> > So are constants local to a function. Being able to restrict the
> > scope to a certain function or group of functions is nevertheless
> > useful.
>
> To be honest, if we wouldn't be able to do that now, and a request
> for implementation came, my answer would be pretty much the same.

Oh, well. That would make my logging much harder.

|unit
|   Foo;
|
| ...
|
|const
|   MODULE_PREFIX = 'Foo.';
|
|procedure Foobar;
|const
|   PROC_PREFIX = MODULE_PREFIX + 'Foobar';
|begin
|   ...

I would have to declare a different name for each subroutine and they 
wouldn't have the local scope (in case the subroutine gets refactored, 
the log name should also be changed).

Names of nested subroutines would be almost impossible to maintain.

Of course, this is of no practical use. It's just in about 70K lines of 
code of a real world project. Yes, I'm being a bit cynic here.

Regarding class constants: I missed them, too, already, although not too 
much. ;)


Vinzent.



More information about the fpc-pascal mailing list