Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-10

[OT] sealed?

13 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Barth
to silvioprog
silvioprog wrote 9 lines
Hello, I was surfing the internet and came across this structure Delphi: TJSONPair= class sealed(TJSONAncestor) So, what is this?

Simple: You are not allowed to create child classes of sealed classes (the compiler enforces this). FPC supports this since 2.4.2.

Regards,
Sven

silvioprog
to Sven Barth

2013/10/7 Sven Barth

Show quoted text 18 lines
On 07.10.2013 19:29, silvioprog wrote: > Hello, > > I was surfing the internet and came across this structure Delphi: > > > TJSONPair= class sealed(TJSONAncestor) > > > So, what is this? > Simple: You are not allowed to create child classes of sealed classes (the compiler enforces this). FPC supports this since 2.4.2. Regards, Sven

Perfect!

It tested it:

  TBaseClass = class
  end;
  TOtherClass = class sealed(TBaseClass)
  end;
  TFooClass = class(TOtherClass)
  end;

and:

unit1.pas(24,32) Error: Cannot create a descendant of the sealed class
"TOtherClass"

It is wonderful, thank you very much Sven! :)

Silvio Clécio My public projects - github.com/silvioprog
Sven Barth
to silvioprog
silvioprog wrote 42 lines
2013/10/7 Sven Barth < > On 07.10.2013 19:29, silvioprog wrote: Hello, I was surfing the internet and came across this structure Delphi: TJSONPair= class sealed(TJSONAncestor) So, what is this? Simple: You are not allowed to create child classes of sealed classes (the compiler enforces this). FPC supports this since 2.4.2. Regards, Sven Perfect! It tested it: TBaseClass = class end; TOtherClass = class sealed(TBaseClass) end; TFooClass = class(TOtherClass) end; and: unit1.pas(24,32) Error: Cannot create a descendant of the sealed class "TOtherClass" It is wonderful, thank you very much Sven! :)

Well, the opinion whether this feature is wonderful or not differs among FPC/Delphi users :P

Regards,
Sven

silvioprog
to Sven Barth

2013/10/7 Sven Barth

Show quoted text 52 lines
On 07.10.2013 20:38, silvioprog wrote: > 2013/10/7 Sven Barth < > < >> > > On 07.10.2013 19:29, silvioprog wrote: > > Hello, > > I was surfing the internet and came across this structure Delphi: > > > TJSONPair= class sealed(TJSONAncestor) > > > So, what is this? > > > Simple: You are not allowed to create child classes of sealed > classes (the compiler enforces this). FPC supports this since 2.4.2. > > Regards, > Sven > > > Perfect! > > It tested it: > > TBaseClass = class > end; > > TOtherClass = class sealed(TBaseClass) > end; > > TFooClass = class(TOtherClass) > end; > > and: > > unit1.pas(24,32) Error: Cannot create a descendant of the sealed class > "TOtherClass" > > It is wonderful, thank you very much Sven! :) > Well, the opinion whether this feature is wonderful or not differs among FPC/Delphi users :P Regards, Sven

:D

Silvio Clécio My public projects - github.com/silvioprog
Dennis Poon
to Sven Barth: Well, the opinion whether this feature is wonderful or not differs among FPC/Delphi users…
Show quoted text 8 lines
It is wonderful, thank you very much Sven! :) Well, the opinion whether this feature is wonderful or not differs among FPC/Delphi users :P Regards, Sven

May I know the usual use of such feature? I can only think of library vendors want to seal a class to prevent users from modifying it without paying for an upgraded/better version of such class.

Dennis

Show quoted text 11 lines
_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal ----- No virus found in this message. Checked by AVG - www.avg.com Version: 2013.0.3408 / Virus Database: 3222/6731 - Release Date: 10/07/13
Dmitry Boyarintsev
to Dennis Poon

A well written class doesn't need to be sealed. As well as doesn't require an inheritance.

IIRC, "sealed" was added to delphi language at the time of the delphi .nettism. Correct me, if I'm wrong but Delphi-net is dead (replaced by Oxygen, which is not delphi or pascal).
However, since the keyword was introduced in the some point of the language, the support was provided in the next versions of the Delphi language/compiler.
Since FPC announces Delphi-compatibility on syntax level, the keyword was introduced in FPC as well.

Usefulness of the "sealed" (as some other .nettish syntax, i.e. class helpers) is questionable and further discussion is probably better for fpc-other list. So feel free to use it for good or bad.

thanks,
Dmitry

Dennis Poon wrote 31 lines
> It is wonderful, thank you very much Sven! :) > > Well, the opinion whether this feature is wonderful or not differs among > FPC/Delphi users :P > > Regards, > Sven > > May I know the usual use of such feature? I can only think of library vendors want to seal a class to prevent users from modifying it without paying for an upgraded/better version of such class. Dennis ______________________________**_________________ > fpc-pascal maillist - > http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal> > > > ----- > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2013.0.3408 / Virus Database: 3222/6731 - Release Date: 10/07/13 > > > ______________________________**_________________ fpc-pascal maillist - http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal>
Dmitry Boyarintsev
to Dmitry Boyarintsev

Actually, it's useful when used a platform-specific keyword (i.e. for declaring an external Java-class, which can be finalized). It was introduced for platform-specific needs (delphi.net), but became a part of the language.

thanks,
Dmitry

On Tue, Oct 8, 2013 at 12:14 AM, Dmitry Boyarintsev <

Show quoted text 57 lines
wrote: A well written class doesn't need to be sealed. As well as doesn't require an inheritance. IIRC, "sealed" was added to delphi language at the time of the delphi .nettism. Correct me, if I'm wrong but Delphi-net is dead (replaced by Oxygen, which is not delphi or pascal). However, since the keyword was introduced in the some point of the language, the support was provided in the next versions of the Delphi language/compiler. Since FPC announces Delphi-compatibility on syntax level, the keyword was introduced in FPC as well. Usefulness of the "sealed" (as some other .nettish syntax, i.e. class helpers) is questionable and further discussion is probably better for fpc-other list. So feel free to use it for good or bad. thanks, Dmitry On Mon, Oct 7, 2013 at 11:22 PM, Dennis Poon wrote: > > It is wonderful, thank you very much Sven! :) > >> >> Well, the opinion whether this feature is wonderful or not differs among >> FPC/Delphi users :P >> >> Regards, >> Sven >> >> May I know the usual use of such feature? I can only think of library > vendors want to seal a class to prevent users from modifying it without > paying for an upgraded/better version of such class. > > Dennis > > > ______________________________**_________________ >> fpc-pascal maillist - >> http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal> >> >> >> ----- >> No virus found in this message. >> Checked by AVG - www.avg.com >> Version: 2013.0.3408 / Virus Database: 3222/6731 - Release Date: 10/07/13 >> >> >> ______________________________**_________________ > fpc-pascal maillist - > http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal> >
Sven Barth
to Dennis Poon: May I know the usual use of such feature? I can only think of library vendors want to…
"Dennis Poon" wrote 5 lines
> It is wonderful, thank you very much Sven! :) > > > Well, the opinion whether this feature is wonderful or not differs among

FPC/Delphi users :P

Show quoted text 5 lines
> > Regards, > Sven > May I know the usual use of such feature? I can only think of library

vendors want to seal a class to prevent users from modifying it without paying for an upgraded/better version of such class.

That's why I implied that the usefulness is highly debated...

Regards,
Sven

Mark Morgan Lloyd
to Sven Barth: Simple: You are not allowed to create child classes of sealed classes (the compiler…
Sven Barth wrote 13 lines
On 07.10.2013 19:29, silvioprog wrote: > Hello, > > I was surfing the internet and came across this structure Delphi: > > > TJSONPair= class sealed(TJSONAncestor) > > > So, what is this? Simple: You are not allowed to create child classes of sealed classes (the compiler enforces this). FPC supports this since 2.4.2.

Does it prevent the creation of class helpers?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
Graeme Geldenhuys
to Sven Barth: Simple: You are not allowed to create child classes of sealed classes (the compiler…
Sven Barth wrote
Simple: You are not allowed to create child classes of sealed classes (the compiler enforces this). FPC supports this since 2.4.2.

All good and well, but I really don't see the point of a class that you can't extend. The original developer can never foresee all possible use cases in the future. We already have issues with some classes defining fields or methods and private, when they would have been better suited as protected. Sealed classes are just going to make matters worse. It defeats the whole purpose of OOP.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
Sven Barth
to Mark Morgan Lloyd: Does it prevent the creation of class helpers? Mark Morgan Lloyd markMLl .AT.…

Am 08.10.2013 09:12 schrieb "Mark Morgan Lloyd" <

Show quoted text 18 lines
: Sven Barth wrote: > > On 07.10.2013 19:29, silvioprog wrote: >> >> Hello, >> >> I was surfing the internet and came across this structure Delphi: >> >> >> TJSONPair= class sealed(TJSONAncestor) >> >> >> So, what is this? > > > Simple: You are not allowed to create child classes of sealed classes

(the compiler enforces this). FPC supports this since 2.4.2.

Does it prevent the creation of class helpers?

At least not in FPC. AFAIK I didn't test whether Delphi forbids it...

Regards,
Sven

Paul Ishenin
to Graeme Geldenhuys: All good and well, but I really don't see the point of a class that you can't extend. The…

08.10.2013 17:35, Graeme Geldenhuys пишет:

Show quoted text 7 lines
All good and well, but I really don't see the point of a class that you can't extend. The original developer can never foresee all possible use cases in the future. We already have issues with some classes defining fields or methods and private, when they would have been better suited as protected. Sealed classes are just going to make matters worse. It defeats the whole purpose of OOP.

Just open the old mail thread - the question was discussed there with your participation (as I remember). There is no need to repeat it again.

Best regards,
Paul Ishenin