Hello,
I was surfing the internet and came across this structure Delphi:
TJSONPair = class sealed(TJSONAncestor)
So, what is this?
Link:
http://docwiki.embarcadero.com/Libraries/XE3/en/API:Data.DBXJSON.TJSONPair

Mailing lists / fpc-pascal / 2013-10
13 messages · 7 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hello,
I was surfing the internet and came across this structure Delphi:
TJSONPair = class sealed(TJSONAncestor)
So, what is this?
Link:
http://docwiki.embarcadero.com/Libraries/XE3/en/API:Data.DBXJSON.TJSONPair
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
2013/10/7 Sven Barth
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
2013/10/7 Sven Barth
:D
Well, the opinion whether this feature is wonderful or not differs among FPC/Delphi users…
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
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
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 <
May I know the usual use of such feature? I can only think of library vendors want to…
FPC/Delphi users :P
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
Simple: You are not allowed to create child classes of sealed classes (the compiler…
Does it prevent the creation of class helpers?
Simple: You are not allowed to create child classes of sealed classes (the compiler…
Sven Barth wroteSimple: 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 -
Does it prevent the creation of class helpers? Mark Morgan Lloyd markMLl .AT.…
Am 08.10.2013 09:12 schrieb "Mark Morgan Lloyd" <
(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
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 пишет:
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