On 17.10.2015 09:28, Sven Barth wrote:
Also for numbers and enums?

> It still looks strange to me.

Well... It's a logical extension of the type helpers however (and Delphi compatible). The only critical part is that literal constants don't have a type per se and thus the chosen helper might be different :/ (e.g. an Int16 helper when one expected an Int32 one or so...)


For numbers, IMO it is over-complicated... Code like
15.Power2;
seems strange to me as well.

But it is definitely needed for enums:

program project1;

{$mode delphi}

type
  TMyEnum = (eOne, eTwo, eThree);

  TMyEnumHelper = record helper for TMyEnum
  public
    class function One: TMyEnum; static;
  end;

{ TMyEnumHelper }

class function TMyEnumHelper.One: TMyEnum;
begin
  Result := eOne;
end;

var
  e: TMyEnum;
begin
  e.|
  TMyEnum.|;
end.

-> doesn't work for me. (I am not sure if it is a regression, though. I don't remember everything. Nevertheless, it should work.)

Ondrej


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to