Recent

Author Topic: Constant variables specific to inheritance level but not the instance ?  (Read 5855 times)

Nitorami

  • Sr. Member
  • ****
  • Posts: 481
Hmhm... just a quickie before I leave for the beergarden: I still don't understand how to use this in a working Class. You access the range from the outside, and that works...

Code: Pascal  [Select][+][-]
  1.   writeln(Low(TFirstClass.Level));

but how would I access it from within the Class ?

Code: Pascal  [Select][+][-]
  1.       procedure TBaseClass<T>.Show;
  2.       begin
  3.         writeln (low(level));  //<---- type mismatch
  4.       end;
  5.  

I tinkered a bit, tried low(T) and low (<T>), and ran into internal error 2014050901. Not surprising really as I don't know what I'm doing.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
I really don't know an example that is easier than I gave you.
PascalDragon seems to agree, but note his remark: he implemented this.
Once you have a class instance, you will be able to access it.
« Last Edit: July 24, 2018, 08:31:46 pm by Thaddy »
Specialize a type, not a var.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Just as a heads up: best not to use class variables with generics currently, at least until #28911 is solved.
I don't think my code should be affected. Or am I wrong, Sven?
If you have the same inline specialization in two different units then they'll have different class var "instances". If you only use an explicit type declaration in some third unit you won't have the problem.

 

TinyPortal © 2005-2018