[fpc-devel] class abstract, class sealed implementation. please review.

dmitry boyarintsev skalogryz.lists at gmail.com
Tue Oct 20 08:59:02 CEST 2009


On Tue, Oct 20, 2009 at 4:59 AM, Paul Ishenin <ip at kmiac.ru> wrote:
> What we will get in the result of this language simplification? Yes,
> extremely fast and easy compiler but do you like it?

Maybe the syntax should be simplified, rather than following new
delphi's .Nettist growing style? AFAIK, it's been discussed about
using class attributes.
Delphi has:
  TMyHelper = class helper of TParent
     ...methods...
  end;

  TAbstractClass = abstract class(TSomething)
     ...methods...
  end;

  TSealedClass = sealed class(TSomething)
     ...methods...
  end;


but FPC can use
  TMyHelper = class(TParent)
    [helper]
     ...methods...
  end;

  TAbstractClass = class(TSomething)
    [abstract]
     ...methods...
  end;

  TSealedClass = class(TParent)
    [sealed]
     ...methods...
  end;

Using attributes makes language, simplier, because user don't need to
learn new constructions, they might need to learn *possible*
attribute, modifiers.
Let's say, thay FPC packages are finally implemented, and helper and
sealed classes are supported. The final syntax of the class would be:

  TSealedClass = class(TParent)
    [sealed, external]
     ...methods...
  end;

With new features added to the FPC, will be easily added for classes:
  TMyCoolClass = class(TParent)
    [feature1, feature2... etc]
     ...methods...
  end;

Such syntax also makes parsers' job easier. Because, they don't need
to be aware of new structures, but treat anything inside '[..]' as set
of modifiers or strings separated by commas.
"attributes" and "stringed attributes" are already used in Interfaces
declaration:
  IMyInterface = interface
     ['{2EC9224F-3D48-4CD3-80E7-2EF7441C0DD5}']
     procedure Method;
  end;

Of course the primary reason for adding new structures
(helpers/abstract/sealed) to the compiler is delphi compatibility,
they can be left for {$mode delphi} only.

thanks,
dmitry



More information about the fpc-devel mailing list