Inheritance in Sets lazarus / 62-General ---------------------------------------------------------------------- Weitentaaal · 2021-12-23 06:44 Hello, So i wanted to ask if there exists an inheritance in Sets. for Example "Superset" Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TCarSpeed= (SpSlow, SpFast);   TCarSpeedSet= set of TCarSpeed;  "SubSet" Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TCarWithAdditionalSpeedOption = (SpVeryFast); //Should inherit the TCarSpeedSet   TCarWithAdditionalSpeedOptionSet = set of TCarWithAdditionalSpeedOption; ---------------------------------------------------------------------- howardpc · 2021-12-23 08:09 Short answer: no. However you can do this sort of thing, since the sets are compatible: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; {$mode objfpc}{$H+} type TSpeed = (SpSlow, SpFast, spVeryFast); TMidRangeSpeed = SpSlow..SpFast; TMidRangeSpeedSet = set of TMidRangeSpeed; TFullRangeSpeedSet = set of TSpeed; function ReportSpeed(aSet: TFullRangeSpeedSet): String;var  sp: TSpeed;  s: String;begin  Result := '[';  for sp in aSet do    begin      WriteStr(s, sp);      Result := Result + s + ', ';    end;  if Result[Length(Result)] = ' ' then    delete(Result, Pred(Length(Result)), 2);  Result := Result + ']';end; var  mid:  TMidRangeSpeedSet;  full: TFullRangeSpeedSet; begin  mid := [];  full := [SpFast];  WriteLn('Mid and full are identical? - ', mid = full,' (mid: ',ReportSpeed(mid),' full: ',ReportSpeed(full),')');  mid := [SpFast];  WriteLn('Mid and full are identical? - ', mid = full,' (mid: ',ReportSpeed(mid),' full: ',ReportSpeed(full),')');  Include(full, spVeryFast);  WriteLn('Mid and full are identical? - ', mid = full,' (mid: ',ReportSpeed(mid),' full: ',ReportSpeed(full),')');  ReadLn;end. ---------------------------------------------------------------------- Weitentaaal · 2021-12-23 09:30 Thank you @howardpc what does that do: "TMidRangeSpeed = SpSlow..SpFast;" take out all Set-Items from the range SpSlow to SpFast ? ---------------------------------------------------------------------- MarkMLl · 2021-12-23 10:25 Quote from: Weitentaaal on December 23, 2021, 10:30:25 amThank you @howardpc what does that do: "TMidRangeSpeed = SpSlow..SpFast;" take out all Set-Items from the range SpSlow to SpFast ? It defines a new enumerated type with (hopefully) the overlapping values in the right places. The issue here isn't really one of inheriting set types, but inheriting/propagating the underlying enumerated type. I've raised this in the past in the context of defining driver units which conform to some existing template, and while there is no inheritance per se enumerations do have the capability of being forced to a numeric value: see https://www.freepascal.org/docs- html/current/ref/refsu4.html#x26-280003.1.1 Hence you should be able to have Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TSpeed= (SpStill= 0, SpMoving= 1); TDrive= (SpPark= 0, SpDrive= 1, spOverdrive= 2);  or similar with guaranteed equivalence, and while this isn't as elegant as some form of inheritance it should be reliable. I don't know whether saying "we need extensible enumerations to allow us to define inherited sets" is reasonable, or if such a thing would be considered "eye candy" by the core team since there is a workaround of sorts. MarkMLl ---------------------------------------------------------------------- howardpc · 2021-12-23 10:35 Quote from: Weitentaaal on December 23, 2021, 10:30:25 amwhat does that do: "TMidRangeSpeed = SpSlow..SpFast;" It defines what the docs describe as a "subrange type", i. e. a derived enumeration type with the specified limiting values for the lowest and highest values the type can hold. You can define a subrange type for any ordinal type (signed and unsigned integers, enumerations, boolean, char). ---------------------------------------------------------------------- Weitentaaal · 2021-12-23 10:55 Thank you guys for  the detailed answers