Content deleted Content added
Added comparison with Delphi (new features) |
→Differences between Delphi and PascalABC.NET: Added changed features and not implemented features |
||
Line 37:
=== New features ===
'''•''' <code>loop</code>
loop 10 do
Write('*');
</syntaxhighlight> '''•''' <code>for</code> loop with a step<syntaxhighlight lang="delphi">
for var i:=1 to 20 step 2 do
Print(i);
</syntaxhighlight> '''•''' <code>foreach</code> loop with an index<syntaxhighlight lang="delphi">
foreach var c in Arr('a'..'z') index i do
if i mod 2 = 0 then
Print(c);
</syntaxhighlight> '''•''' <code>a..b</code> ranges<syntaxhighlight lang="delphi">
(1..10).Printlines
</syntaxhighlight> '''•''' short function definition syntax<syntaxhighlight lang="delphi">
function Sum(a,b: real) := a + b;
</syntaxhighlight> '''•''' method implementation can be placed inside a class definition<syntaxhighlight lang="delphi">
type Point = class
x,y: real;
Line 59:
end;
end;
</syntaxhighlight> '''•''' <code>sequence of T</code> type as an abstraction of arrays, lists and sets<syntaxhighlight lang="delphi">
var seq: sequence of integer := Arr(1..10);
seq.Println;
seq := Lst(11..100); seq.Println;
seq := HSet(1..20); seq.Println;
</syntaxhighlight> '''•''' [[Anonymous function|lambda functions]]<syntaxhighlight lang="delphi">
var a := ArrGen(10,i -> i*i);
</syntaxhighlight> '''•''' auto classes - classes with an automatically generated constructor<syntaxhighlight lang="delphi">
type Point = auto class
x,y: real;
end;
var p := new Point(2,5);
</syntaxhighlight> '''•''' one-dimentional and multi-dimentional array slices<syntaxhighlight lang="delphi">
var m: array [,] of integer := MatrGen(3,4, (i,j) -> i+j+1);
Println(m); // [[1,2,3,4],[2,3,4,5],[3,4,5,6]]
Line 77:
</syntaxhighlight>
===
* strings in <code>case</code> statements
* sets based on arbitrary type: <code>set of string</code>
* constructors can be invoked with <code>new T(...)</code> syntax
* type extension methods instead of class helpers
* modules can be defined in a simplified form (without <code>interface</code> and <code>implementation</code> sections
=== Not implemented features ===
* records with variant parts
* open arrays
* nested class definitions
* [[Inline assembler|inline assembly code]]
== Functional style features ==
In PascalABC.NET, functions are [[First-class citizen|first-class objects]]. They can be assigned to variables, passed as parameters, and returned from other functions. Functional type is set in the form <code>T -> Res</code>. An [[anonymous function]] can be assigned to the variable of this type:
<syntaxhighlight lang="delphi">
|