diff --git a/CodeCompletion/CodeFormatter.cs b/CodeCompletion/CodeFormatter.cs index c26de6478..6f1418299 100644 --- a/CodeCompletion/CodeFormatter.cs +++ b/CodeCompletion/CodeFormatter.cs @@ -2790,7 +2790,9 @@ namespace CodeFormatters { //multiline_stack_push(at); visit_node(at.vars); - sb.Append(" := "); + //add_space_before = true; + add_space_after = true; + //sb.Append(" := "); visit_node(at.expr); //multiline_stack_pop(at); } @@ -2804,9 +2806,10 @@ namespace CodeFormatters /*if (i > 0) sb.Append(", ");*/ visit_node(av); + add_space_after = true; i++; } - sb.Append(")"); + //sb.Append(")"); } #endregion } diff --git a/InstallerSamples/Algorithms/Eratosthenes.pas b/InstallerSamples/Algorithms/Eratosthenes.pas index 6c03a535b..56eff74ad 100644 --- a/InstallerSamples/Algorithms/Eratosthenes.pas +++ b/InstallerSamples/Algorithms/Eratosthenes.pas @@ -1,7 +1,7 @@ -// "Решето Эратосфена" - вычисление простых чисел +// "Решето Эратосфена" - вычисление простых чисел const n = 100000; -var primes: set of integer; +var primes: set of integer; begin primes := [2..n]; diff --git a/InstallerSamples/Algorithms/Recursion/Permutations.pas b/InstallerSamples/Algorithms/Recursion/Permutations.pas index 1df728329..d8d97c9cb 100644 --- a/InstallerSamples/Algorithms/Recursion/Permutations.pas +++ b/InstallerSamples/Algorithms/Recursion/Permutations.pas @@ -1,4 +1,4 @@ -// Все перестановки +// Все перестановки const n = 4; var a: array of integer; @@ -16,6 +16,6 @@ begin end; begin - a := Range(1,n).ToArray(); // заполнение массива a числами от 1 до n + a := Range(1,n).ToArray; // заполнение массива a числами от 1 до n Perm(n); end. \ No newline at end of file diff --git a/InstallerSamples/Games/Animals/Animals.pas b/InstallerSamples/Games/Animals/Animals.pas index b8eda8322..0fc591ff7 100644 --- a/InstallerSamples/Games/Animals/Animals.pas +++ b/InstallerSamples/Games/Animals/Animals.pas @@ -1,4 +1,4 @@ -// Самообучающаяся игра "Угадай животное". +// Самообучающаяся игра "Угадай животное". // Старайтесь на вопрос "Чем отличается" вводить самый общий ответ // Например: "Чем отличается чиж от ежа" - "Умеет летать" type diff --git a/InstallerSamples/Graphics/GraphABC/Fractals/Mandelbrot.pas b/InstallerSamples/Graphics/GraphABC/Fractals/Mandelbrot.pas index 1a3a48c7a..ea950e7ed 100644 --- a/InstallerSamples/Graphics/GraphABC/Fractals/Mandelbrot.pas +++ b/InstallerSamples/Graphics/GraphABC/Fractals/Mandelbrot.pas @@ -1,8 +1,8 @@ -// Демонстрация фрактальной графики. Множество Мандельброта -// Для каждой точки комплексной плоскости z=(x,y) выполняем итерационный процесс z=z^2+c, c=(cx,cy) -// Считаем количество итераций i до тех пор пока не выполнится условие |x|>max и |y|>max -// После этого рисуем точку x,y с насыщенностью красного цвета, пропорциональной i -uses GraphABC,Utils; +// Демонстрация фрактальной графики. Множество Мандельброта +// Для каждой точки комплексной плоскости z=(x,y) выполняем итерационный процесс z=z*2+c, c=(cx,cy) +// Считаем количество итераций i до тех пор пока не выполнится условие |z|>max +// После этого рисуем точку z=(x,y) с насыщенностью красного цвета, пропорциональной i +uses GraphABC; const max = 10; @@ -20,18 +20,16 @@ begin for var ix:=0 to Window.Width-1 do for var iy:=0 to Window.Height-1 do begin - var x := 0.0; - var y := 0.0; var cx := scalex * (ix - dx); var cy := scaley * (iy - dy); + var c := Cplx(cx,cy); + var z := Cplx(0,0); + var i := 1; while i<255 do begin - var x1 := x*x-y*y+cx; - var y1 := 2*x*y+cy; - x := x1; - y := y1; - if (abs(x)>max) and (abs(y)>max) then break; + z := z*z+c; + if z.Magnitude>max then break; i += 1; end; if i>=255 then SetPixel(ix,iy,clRed) diff --git a/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc.exe b/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc.exe deleted file mode 100644 index 4ffb2e7dd..000000000 Binary files a/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc.exe and /dev/null differ diff --git a/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc.pas b/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc.pas index dd61ab6e0..f71ee1bca 100644 --- a/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc.pas +++ b/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc.pas @@ -1,10 +1,9 @@ uses GraphABC; begin - //Draw(-20,20,100,100,500,400,x->x*sin(x)); - Draw(-20,20,x->x*sin(x)); + Brush.Color := ARGB(0,0,0,0); // ïðîçðà÷íàÿ êèñòü + Draw(x->x*sin(x),-20,20); Draw(sin); Draw(cos); Draw(exp); - //Draw(x->x*sin(x)); end. \ No newline at end of file diff --git a/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc.pdb b/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc.pdb deleted file mode 100644 index f431c7660..000000000 Binary files a/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc.pdb and /dev/null differ diff --git a/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc2.pas b/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc2.pas index 4169f7747..5012ab225 100644 --- a/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc2.pas +++ b/InstallerSamples/Graphics/GraphABC/Graphics/DrawFunc2.pas @@ -15,15 +15,13 @@ begin end; begin - //Draw(-20,20,100,100,500,400,x->x*sin(x)); var r := ClientRectangle; r := r.Scale(0.5); var r1 := r.Move(r.Width,0); var r2 := r.Move(0,r.Height); var r3 := r.Move(r.Width,r.Height); - Draw(-20,20,r,x->x*sin(x)); - Draw(r1,sin); - Draw(r2,cos); - Draw(20,10,r3,exp); - //Draw(x->x*sin(x)); + Draw(x->x*sin(x),-20,20,r); + Draw(sin,r1); + Draw(cos,r2); + Draw(exp,20,10,r3); end. \ No newline at end of file diff --git a/InstallerSamples/Graphics/GraphABC/Hypno.pas b/InstallerSamples/Graphics/GraphABC/Hypno.pas index ecb95b404..f9d4ab067 100644 --- a/InstallerSamples/Graphics/GraphABC/Hypno.pas +++ b/InstallerSamples/Graphics/GraphABC/Hypno.pas @@ -1,10 +1,10 @@ -// Иллюстрация прозрачности +// Иллюстрация прозрачности uses GraphABC; begin for var Transparency:=0 to 255 do begin - Brush.Color:=ARGB(Transparency,Random(256),Random(256),Random(256)); + Brush.Color := ARGB(Transparency,Random(256),Random(256),Random(256)); FillCircle(Random(Window.Width),Random(Window.Height),Random(20,60)); sleep(100); end; diff --git a/InstallerSamples/Graphics/GraphABC/Stamps/Stamp1.pas b/InstallerSamples/Graphics/GraphABC/Stamps/Stamp1.pas index b97abd212..be42fe33c 100644 --- a/InstallerSamples/Graphics/GraphABC/Stamps/Stamp1.pas +++ b/InstallerSamples/Graphics/GraphABC/Stamps/Stamp1.pas @@ -1,17 +1,12 @@ -// Штампы - это классы графических фигур, хранящие их параметры +// Штампы - это классы графических фигур, хранящие их параметры // В любой момент можно нарисовать графическую фигуру, вызвав метод Stamp. // Класс штампа прямоугольника uses GraphABC; type - RectangleStamp = class + RectangleStamp = auto class x,y,w,h: integer; - constructor (xx,yy,ww,hh: integer); - begin - x := xx; y := yy; - w := ww; h := hh; - end; procedure Stamp; begin Rectangle(x,y,x+w,y+h); diff --git a/InstallerSamples/Graphics/GraphABC/Stamps/Stamp2.pas b/InstallerSamples/Graphics/GraphABC/Stamps/Stamp2.pas index 08aad5d4f..9b9427de1 100644 --- a/InstallerSamples/Graphics/GraphABC/Stamps/Stamp2.pas +++ b/InstallerSamples/Graphics/GraphABC/Stamps/Stamp2.pas @@ -1,28 +1,17 @@ -// Класс штампа ряда прямоугольников +// Класс штампа ряда прямоугольников uses GraphABC; type - RectangleStamp = class + RectangleStamp = auto class x,y,w,h: integer; - constructor (xx,yy,ww,hh: integer); - begin - x := xx; y := yy; - w := ww; h := hh; - end; procedure Stamp; begin Rectangle(x,y,x+w,y+h); end; end; - RowRectanglesStamp = class + RowRectanglesStamp = auto class x,y,w,h,n: integer; - constructor (xx,yy,ww,hh,nn: integer); - begin - x := xx; y := yy; - w := ww; h := hh; - n := nn; - end; procedure Stamp; begin var r := new RectangleStamp(x,y,w,h); diff --git a/InstallerSamples/Graphics/GraphABC/Stamps/Stamp3.pas b/InstallerSamples/Graphics/GraphABC/Stamps/Stamp3.pas index 8b5a79c23..e985dad42 100644 --- a/InstallerSamples/Graphics/GraphABC/Stamps/Stamp3.pas +++ b/InstallerSamples/Graphics/GraphABC/Stamps/Stamp3.pas @@ -1,26 +1,15 @@ -// Класс штампа прямоугольника с методами увеличения-уменьшения +// Класс штампа прямоугольника с методами увеличения-уменьшения uses GraphABC; type - RectangleStamp = class + RectangleStamp = auto class x,y,w,h: integer; - constructor (xx,yy,ww,hh: integer); - begin - x := xx; y := yy; - w := ww; h := hh; - end; - procedure Stamp; - begin - Rectangle(x,y,x+w,y+h); - end; + procedure Stamp := Rectangle(x,y,x+w,y+h); procedure Increase(dw,dh: integer); begin w += dw; h += dh; end; - procedure Decrease(dw,dh: integer); - begin - Increase(-dw,-dh); - end; + procedure Decrease(dw,dh: integer) := Increase(-dw,-dh); procedure MoveOn(dx,dy: integer); begin x += dx; y += dy; diff --git a/InstallerSamples/Graphics/GraphABC/Stamps/Stamp5.pas b/InstallerSamples/Graphics/GraphABC/Stamps/Stamp5.pas index 78226a572..abc6ca327 100644 --- a/InstallerSamples/Graphics/GraphABC/Stamps/Stamp5.pas +++ b/InstallerSamples/Graphics/GraphABC/Stamps/Stamp5.pas @@ -1,14 +1,9 @@ -// Класс штампа треугольника +// Класс штампа треугольника uses GraphABC; type - TriangleStamp = class + TriangleStamp = auto class x,y,w,orient: integer; - constructor (xx,yy,ww,o: integer); - begin - x := xx; y := yy; - w := ww; orient := o; - end; procedure Stamp; begin MoveTo(x,y); diff --git a/InstallerSamples/Graphics/GraphABC/Stamps/StampCross.pas b/InstallerSamples/Graphics/GraphABC/Stamps/StampCross.pas index 4b554fd12..43dbada6f 100644 --- a/InstallerSamples/Graphics/GraphABC/Stamps/StampCross.pas +++ b/InstallerSamples/Graphics/GraphABC/Stamps/StampCross.pas @@ -1,4 +1,4 @@ -// Класс штампа креста +// Класс штампа креста uses GraphABC; type @@ -33,10 +33,7 @@ type begin MoveOn(a*w,b*w); end; - function Clone(): CrossStamp; - begin - Result := new CrossStamp(x,y,w); - end; + function Clone := new CrossStamp(x,y,w); end; begin diff --git a/InstallerSamples/Graphics/GraphABC/Stamps/StampFunc.pas b/InstallerSamples/Graphics/GraphABC/Stamps/StampFunc.pas index 5d5e04cfc..9357dc657 100644 --- a/InstallerSamples/Graphics/GraphABC/Stamps/StampFunc.pas +++ b/InstallerSamples/Graphics/GraphABC/Stamps/StampFunc.pas @@ -62,18 +62,8 @@ type end; end; -function f(x: real): real; begin - Result := x*sin(5*x); -end; - -function g(x: real): real; -begin - Result := sin(3*x)+sin(4*x); -end; - -begin - var fs := new FuncStamp(10,10,310,230,0,-2*Pi,2*Pi,2*Pi,f); + var fs := new FuncStamp(10,10,310,230,0,-2*Pi,2*Pi,2*Pi,x->x*sin(5*x)); fs.Stamp; fs.MoveOn(320,0); fs.SetFuncWindow(-Pi,-1,Pi,1); @@ -84,6 +74,6 @@ begin fs.Stamp; fs.MoveOn(320,0); fs.SetFuncWindow(-2*Pi,-2,2*Pi,2); - fs.f := g; + fs.f := x->sin(3*x)+sin(4*x); fs.Stamp; end. \ No newline at end of file diff --git a/InstallerSamples/Graphics/GraphABC/Stamps/StampText.pas b/InstallerSamples/Graphics/GraphABC/Stamps/StampText.pas index d7a26fc52..71b1742ee 100644 --- a/InstallerSamples/Graphics/GraphABC/Stamps/StampText.pas +++ b/InstallerSamples/Graphics/GraphABC/Stamps/StampText.pas @@ -1,16 +1,10 @@ -// Класс штампа текста +// Класс штампа текста uses GraphABC; type - TextStamp = class + TextStamp = auto class x,y,pt: integer; Text: string; - constructor (xx,yy,ppt: integer; t: string); - begin - x := xx; y := yy; - pt := ppt; - Text := t; - end; procedure Stamp; begin Font.Size := pt; diff --git a/InstallerSamples/LINQ/Consonants.pas b/InstallerSamples/LINQ/Consonants.pas index 3b88cd93a..c73dfefc7 100644 --- a/InstallerSamples/LINQ/Consonants.pas +++ b/InstallerSamples/LINQ/Consonants.pas @@ -1,7 +1,7 @@ -// Вывод английских согласных +// Вывод английских согласных var vowel: string := 'aeiouy'; begin - var all := Range('a','z').Aggregate('',(s,x)->s+x); + var all := Range('a','z').JoinIntoString(''); all.Except(vowel).Println; end. \ No newline at end of file diff --git a/InstallerSamples/LanguageFeatures/AutoClassPoint.pas b/InstallerSamples/LanguageFeatures/AutoClassPoint.pas new file mode 100644 index 000000000..1ca23b8cb --- /dev/null +++ b/InstallerSamples/LanguageFeatures/AutoClassPoint.pas @@ -0,0 +1,13 @@ +type + Point = auto class + x,y: integer; + procedure MoveOn(dx,dy: integer) := (x,y) := (x+dx,y+dy); + function Distance(p: Point) := sqrt(sqr(x-p.x)+sqr(y-p.y)); + class function operator implicit(t: (integer,integer)): Point := new Point(t[0],t[1]); + end; + +begin + var p: Point; + p := (2,3); + Println(p); +end. \ No newline at end of file diff --git a/InstallerSamples/LanguageFeatures/DllTest/main.pas b/InstallerSamples/LanguageFeatures/DllTest/main.pas index 39a4f7e00..cb46eca8f 100644 --- a/InstallerSamples/LanguageFeatures/DllTest/main.pas +++ b/InstallerSamples/LanguageFeatures/DllTest/main.pas @@ -1,7 +1,7 @@ -// Это - главная программа +// Это - главная программа // Именами из dll-библиотеки, написанной на PascalABC.NET, можно пользоваться, // не подключая пространства имен -#reference 'mydll.dll' +{$reference 'mydll.dll'} begin PrintPascalABCNET; diff --git a/InstallerSamples/LanguageFeatures/ExtensionMethods/SwapHalfArrays.pas b/InstallerSamples/LanguageFeatures/ExtensionMethods/SwapHalfArrays.pas index 673c2f8ac..f7d855b5a 100644 --- a/InstallerSamples/LanguageFeatures/ExtensionMethods/SwapHalfArrays.pas +++ b/InstallerSamples/LanguageFeatures/ExtensionMethods/SwapHalfArrays.pas @@ -1,4 +1,5 @@ -var a: array of integer := (1,3,5,7); +// Ïîìåíÿòü äâå ïîëîâèíû ìàññèâà +var a := Arr(1,3,5,7); begin a.Skip(2).Concat(a.Take(2)).Print; diff --git a/InstallerSamples/LanguageFeatures/ForeachExamples.pas b/InstallerSamples/LanguageFeatures/ForeachExamples.pas index a227823f6..bf7a16025 100644 --- a/InstallerSamples/LanguageFeatures/ForeachExamples.pas +++ b/InstallerSamples/LanguageFeatures/ForeachExamples.pas @@ -1,12 +1,9 @@ -// Пример иллюстрирует всевозможные типы контейнеров, +// Пример иллюстрирует всевозможные типы контейнеров, // по которым можно перемещаться с помощью оператора foreach -uses System.Collections.Generic; - const n = 10; var - x: integer; a: array [1..n] of integer; b: array of integer; s: set of integer; @@ -16,8 +13,8 @@ begin for var i:=1 to n do a[i] := Random(100); // Цикл foreach по статическому массиву - foreach x in a do - write(x,' '); + foreach var x in a do + Print(x); writeln; SetLength(b,n); @@ -25,20 +22,22 @@ begin b[i] := Random(100); // Цикл foreach по динамическому массиву - foreach x in b do - write(x,' '); + foreach var x in b do + Print(x); writeln; s := [2..5,10..14]; - foreach x in s do - write(x,' '); + // Цикл foreach по множеству + foreach var x in s do + Print(x); writeln; l := new List; l.AddRange(b); l.Reverse; - foreach x in l do - write(x,' '); + // Цикл foreach по списку + foreach var x in l do + Print(x); writeln; end. \ No newline at end of file diff --git a/InstallerSamples/LanguageFeatures/ForeachForSet.pas b/InstallerSamples/LanguageFeatures/ForeachForSet.pas index 5044ff296..08b831ed5 100644 --- a/InstallerSamples/LanguageFeatures/ForeachForSet.pas +++ b/InstallerSamples/LanguageFeatures/ForeachForSet.pas @@ -1,5 +1,5 @@ -// Цикл по множеству. Порядок - не по алфавиту, поскольку множества реализованы на базе хеш-таблиц +// Цикл по множеству. Порядок - не по алфавиту, поскольку множества реализованы на базе хеш-таблиц begin - foreach c: char in ['a'..'z'] do + foreach var c in ['a'..'z'] do Write(c); end. \ No newline at end of file diff --git a/InstallerSamples/LanguageFeatures/ForeachIEnumerable.pas b/InstallerSamples/LanguageFeatures/ForeachIEnumerable.pas index 911e6c1ec..77d0b75dd 100644 --- a/InstallerSamples/LanguageFeatures/ForeachIEnumerable.pas +++ b/InstallerSamples/LanguageFeatures/ForeachIEnumerable.pas @@ -1,10 +1,8 @@ -// Пример иллюстрирует реализацию классом интерфейса IEnumerable +// Пример иллюстрирует реализацию классом интерфейса IEnumerable // для использования его в операторе foreach -uses System.Collections; - type // Генератор чисел Фибоначчи - FibGen = class(IEnumerable, IEnumerator) + FibGen = class(IEnumerable, IEnumerator) private a,b,n,i: integer; public @@ -15,37 +13,34 @@ type b := 1; Self.n := n; end; - function Get_Current: Object; + function Get_Current: integer; begin if i=0 then Result := 1 else Result := b; end; - function GetEnumerator: IEnumerator; - begin - Result := Self; - end; + function System.Collections.IEnumerator.Get_Current: object := Get_Current; + function GetEnumerator: IEnumerator := Self; + function System.Collections.IEnumerable.GetEnumerator: System.Collections.IEnumerator := Self; function MoveNext: boolean; begin i += 1; Result := i(a: array of T; val: T): integer; @@ -12,7 +12,7 @@ begin end; end; -var a: array of string := ('Ваня', 'Коля', 'Саша', 'Сережа'); +var a := Arr('Ваня', 'Коля', 'Саша', 'Сережа'); begin var s := 'Сережа'; diff --git a/InstallerSamples/LanguageFeatures/IndexProperties.pas b/InstallerSamples/LanguageFeatures/IndexProperties.pas index 7b35e9e54..649f9c638 100644 --- a/InstallerSamples/LanguageFeatures/IndexProperties.pas +++ b/InstallerSamples/LanguageFeatures/IndexProperties.pas @@ -1,4 +1,4 @@ -// Индексные свойства. Массив цветных квадратов +// Индексные свойства. Массив цветных квадратов uses GraphABC; const @@ -27,9 +27,7 @@ type public constructor (n: integer); begin - SetLength(a,n); - for var i:=0 to n-1 do - a[i] := clWhite; + a := ArrFill(n,Color.White); Draw; end; /// Рисует i-тый квадрат @@ -53,7 +51,7 @@ var arr: VisualArray; begin Window.Title := 'Иллюстрация индексных свойств'; arr := new VisualArray(dim); - SetWindowSize(sz*(dim+2),3*sz); + Window.SetSize(sz*(dim+2),3*sz); arr[0] := clGreen; // arr.Items[0] = arr[0] поскольку свойство Items является свойством по умолчанию Sleep(delay); arr[1] := clBlack; diff --git a/InstallerSamples/LanguageFeatures/ParamsConcat.pas b/InstallerSamples/LanguageFeatures/ParamsConcat.pas index 6f66ceed6..b36c1ed84 100644 --- a/InstallerSamples/LanguageFeatures/ParamsConcat.pas +++ b/InstallerSamples/LanguageFeatures/ParamsConcat.pas @@ -1,9 +1,9 @@ -// Создание функции Concat с переменным числом параметров +// Создание функции Concat с переменным числом параметров function Concat(params strs: array of string): string; begin - var sb := new System.Text.StringBuilder; - foreach x: string in strs do + var sb := new StringBuilder; + foreach var x in strs do sb.Append(x); Result := sb.ToString; end; diff --git a/InstallerSamples/LanguageFeatures/ParamsWriteln.pas b/InstallerSamples/LanguageFeatures/ParamsWriteln.pas index e31fc4699..ee15d7878 100644 --- a/InstallerSamples/LanguageFeatures/ParamsWriteln.pas +++ b/InstallerSamples/LanguageFeatures/ParamsWriteln.pas @@ -1,10 +1,10 @@ -// Создание процедуры MyWriteln с переменным числом параметров +// Создание процедуры MyWriteln с переменным числом параметров procedure MyWriteln(params args: array of object); begin - foreach x: Object in args do - System.Console.Write(x); - System.Console.WriteLine; + foreach var x in args do + Write(x); + WriteLn; end; var diff --git a/InstallerSamples/LanguageFeatures/ProcParam.pas b/InstallerSamples/LanguageFeatures/ProcParam.pas index 5a77aa708..3555e1b4c 100644 --- a/InstallerSamples/LanguageFeatures/ProcParam.pas +++ b/InstallerSamples/LanguageFeatures/ProcParam.pas @@ -1,22 +1,15 @@ -// Иллюстрация процедурных переменных как параметров подпрограмм +// Иллюстрация процедурных переменных как параметров подпрограмм // Для процедурного типа в PascalABC.NET реализована структурная эквивалентность типов // Процедурный тип реализован через делегаты .NET -procedure for_each(var a: array of real; p: procedure(var r: real)); -var i: integer; +procedure for_each(a: array of real; p: procedure(var r: real)); begin - for i := 0 to a.Length-1 do + for var i := 0 to a.Length-1 do p(a[i]); end; -procedure mult2(var r: real); -begin - r := 2*r -end; +procedure mult2(var r: real) := r := 2*r; -procedure print(var r: real); -begin - write(r,' '); -end; +procedure print(var r: real) := write(r,' '); var a: array of real := (1,2,3,6,7); diff --git a/InstallerSamples/LanguageFeatures/Students.pas b/InstallerSamples/LanguageFeatures/Students.pas index 1bb0dc994..a90af77e9 100644 --- a/InstallerSamples/LanguageFeatures/Students.pas +++ b/InstallerSamples/LanguageFeatures/Students.pas @@ -1,35 +1,18 @@ -//Перегрузка операторов +// Перегрузка операторов type - Student = class + Student = auto class Name: string; Height: integer; public - constructor(Name: string; Height: integer); - begin - Self.Name := Name; - Self.Height := Height; - end; - class function operator<(left,right: Student): boolean; // Сравнение по росту - begin - Result := left.Height < right.Height; - end; - class function operator>(left,right: Student): boolean; - begin - Result := left.Height > right.Height; - end; - function ToString: string; override; - begin - Result := string.Format('{0} ({1})', Name, Height); - end; + class function operator<(left,right: Student): boolean := left.Height < right.Height; + class function operator>(left,right: Student): boolean := left.Height > right.Height; + function ToString: string; override := string.Format('{0} ({1})', Name, Height); end; -var - s1,s2: Student; - begin - s1 := new Student('Stepa Morkovkin',188); - s2 := new Student('Petya Pomidorov',180); + var s1 := new Student('Stepa Morkovkin',188); + var s2 := new Student('Petya Pomidorov',180); Writeln('s1: ',s1); Writeln('s2: ',s2); Writeln;