Delphi 6 Personal と Turbo Explorer と 10.1 Berlin Starter Edition の違い
ざっくり言うと...
Windows
文字コード
VCL ソースコード
FireMonkey
コンポーネントインストール
複数パーソナリティ
商用利用
Delphi 6 Personal
2000 / Me 対応
ANSI
×
×
〇
―
不可
Turbo Explorer
XP 対応
ANSI
〇
×
×
標準では不可能
可能
10.1 Berlin Starter Edition
Windows 10 対応
Unicode
×
〇
〇
なぜか可能
年 $1000 以内 で可能
Delphi StarterとC++Builder Starterの両方を購入して1つのマシンにインストールして「Mini RAD Studio」のように使うことはできますか?
本来はできないハズですが何故かできてしまいます。エンバカデロのブログでもやり方が公開されています。
Delphi と C++Builder の旧プロジェクトを 10.1 Berlin Starter で使用できますか?
はい、できます。10.1 Berlin では、Turbo Explorer や旧バージョンのプロジェクトを開くことができます(他社製コンポーネントなど、サポートされていない機能を含む場合には、利用できない場合があります)。
uses
..., Types;
function Stride(from: Integer; through: Integer; by: Integer = 1): TIntegerDynArray;
var
i, Cnt: Integer;
Direction: Boolean;
begin
SetLength(result, 0);
Cnt := 0;
// 方向 from < through で順方向 (True)
Direction := (from <= through);
// 無限ループになる場合には抜けるif by = 0then
Exit;
case Direction of
True:
if by < 0then Exit;
elseif by > 0then Exit;
end;
// 開始値
i := from;
// 大まかな配列を確保
SetLength(result, (Abs(through - from) div Abs(by)) + 1);
// ループwhile true dobeginif (Direction and (i > through)) or
((not Direction) and (i < through)) then
Break;
result[Cnt] := i;
Inc(Cnt);
Inc(i, by)
end;
SetLength(result, Cnt);
end;
この関数を使えば、
var
i: Integer;
begin// 0..10for i in Stride(0, 10) do
Writeln(i);
// -10..10for i in Stride(-10, 10) do
Writeln(i);
// 0..100 Step 3for i in Stride(0, 100, 3) do
Writeln(i);
// 10..0 (downto)for i in Stride(10, 0, -1) do
Writeln(i);
end;
unit uStride;
interfaceuses
SysUtils, Types;
type
TStrideEnumerator = class;
TStride = recordprivate
Ffrom: Integer;
Fthrough: Integer;
Fby: Integer;
FDirection: Boolean;
publicconstructor Create(from: Integer; through: Integer; by: Integer = 1);
function GetEnumerator: TStrideEnumerator;
end;
TStrideEnumerator = class
Container: TStride;
Index: Integer;
publicconstructor Create(AContainer : TStride);
function GetCurrent: Integer;
function MoveNext: Boolean;
property Current: Integer read GetCurrent;
end;
implementation{ TStride }constructor TStride.Create(from, through, by: Integer);
begin
Ffrom := from;
Fthrough := through;
Fby := by;
FDirection := (Ffrom <= Fthrough);
end;
function TStride.GetEnumerator: TStrideEnumerator;
begin
Result := TStrideEnumerator.Create(Self);
end;
{ TStrideEnumerator }constructor TStrideEnumerator.Create(AContainer: TStride);
begininherited Create;
Container := AContainer;
Index := -1;
end;
function TStrideEnumerator.GetCurrent: Integer;
begin
Result := Container.Ffrom + (Index * Container.FBy)
end;
function TStrideEnumerator.MoveNext: Boolean;
var
dValue: Integer;
begin
result := False;
if (Container.Fby = 0) then
Exit
elsebegin
dValue := Container.Ffrom + ((Index + 1) * Container.FBy);
case Container.FDirection of
True:
if (Container.FBy < 0) or (dValue > Container.Fthrough) then
Exit;
elseif (Container.FBy > 0) or (dValue < Container.Fthrough) then
Exit;
end;
end;
result := True;
Inc(Index);
end;
end.
この unit を uses に加えると、
var
i: Integer;
begin// 0..10for i in TStride.Create(0, 10) do
Writeln(i);
// -10..10for i in TStride.Create(-10, 10) do
Writeln(i);
// 0..100 Step 3for i in TStride.Create(0, 100, 3) do
Writeln(i);
// 10..0 (downto)for i in TStride.Create(10, 0, -1) do
Writeln(i);
end;
こんな記述が可能になります (swift の Stride で to ではなく through を使ったのと同等です...多分)。ネストしたループとかでもメモリリークは起こらないハズです。普通の for to do / for downto do の方が高速でメモリも消費しないとは思いますけれど、こんな書き方ができても面白いですよね。「俺ならもっとエレガントにやれるぜ!」ってなテクニックや情報をお持ちの方は出し惜しみせずに教えてくださいお願いします m(_ _)m
unit uStride;
interfaceuses
SysUtils, Types;
type
TStrideEnumerator = class;
TStride = recordprivate
Ffrom: Integer;
Fthrough: Integer;
Fby: Integer;
FDirection: Boolean;
publicconstructor Create(from: Integer; through: Integer; by: Integer = 1);
function GetEnumerator: TStrideEnumerator;
end;
TStrideEnumerator = class
Container: TStride;
Index: Integer;
publicconstructor Create(AContainer : TStride);
function GetCurrent: Integer;
function MoveNext: Boolean;
property Current: Integer read GetCurrent;
end;
function Stride(from: Integer; through: Integer; by: Integer = 1): TStride; // 追記implementation{ 追記: BEGIN }function Stride(from, through, by: Integer): TStride;
begin
Result := TStride.Create(from, through, by);
end;
{ 追記: END }{ TStride }constructor TStride.Create(from, through, by: Integer);
begin
Ffrom := from;
Fthrough := through;
Fby := by;
FDirection := (Ffrom <= Fthrough);
end;
function TStride.GetEnumerator: TStrideEnumerator;
begin
Result := TStrideEnumerator.Create(Self);
end;
{ TStrideEnumerator }constructor TStrideEnumerator.Create(AContainer: TStride);
begininherited Create;
Container := AContainer;
Index := -1;
end;
function TStrideEnumerator.GetCurrent: Integer;
begin
Result := Container.Ffrom + (Index * Container.FBy)
end;
function TStrideEnumerator.MoveNext: Boolean;
var
dValue: Integer;
begin
result := False;
if (Container.Fby = 0) then
Exit
elsebegin
dValue := Container.Ffrom + ((Index + 1) * Container.FBy);
case Container.FDirection of
True:
if (Container.FBy < 0) or (dValue > Container.Fthrough) then
Exit;
elseif (Container.FBy > 0) or (dValue < Container.Fthrough) then
Exit;
end;
end;
result := True;
Inc(Index);
end;
end.
こうしちゃえば、最初の関数版みたいに書ける、と。
var
i: Integer;
begin// 0..10for i in Stride(0, 10) do
Writeln(i);
// -10..10for i in Stride(-10, 10) do
Writeln(i);
// 0..100 Step 3for i in Stride(0, 100, 3) do
Writeln(i);
// 10..0 (downto)for i in Stride(10, 0, -1) do
Writeln(i);
end;
@ht_deko まあ僕の場合ネタ元のPythonがfor i in range(10)みたいな書き方でそれを真似てただけなので、使い勝手まで考えてそうなってたかは怪しいところですが…w