FPC New Features Trunk

This is an old revision of FPC New Features Trunk, edited by Mattias2 at . The current revision is 71454.

/* Support for NameOf() */

About this page

Below you can find a list of new features introduced since the previous release, along with some background information and examples. Note that since svn trunk is by definition still under development, some of the features here may still change before they end up in a release version.

A list of changes that may break existing code can be found here.

All systems

Compiler

fpcres can compile RC files

Language

Support for "volatile" intrinsic

Support for "noinline" modifier

Support for multiple active helpers per type

Support for custom attributes

program tcustomattr;

{$mode objfpc}{$H+}
{$modeswitch prefixedattributes}

type
  TMyAttribute = class(TCustomAttribute)
    constructor Create;
    constructor Create(aArg: String);
    constructor Create(aArg: TGUID);
    constructor Create(aArg: LongInt);
  end;

  {$M+}
  [TMyAttribute]
  TTestClass = class
  private
    fTest: LongInt;
  published
    [TMyAttribute('Test')]
    property Test: LongInt read fTest;
  end;
  {$M-}

  [TMyAttribute(1234)]
  [TMy('Hello World')]
  TTestEnum = (
    teOne,
    teTwo
  );

  [TMyAttribute(IInterface), TMy(42)]
  TLongInt = type LongInt;

constructor TMyAttribute.Create;
begin
end;

constructor TMyAttribute.Create(aArg: String);
begin
end;

constructor TMyAttribute.Create(aArg: LongInt);
begin
end;

constructor TMyAttribute.Create(aArg: TGUID);
begin
end;

begin

end.

Support for constant parameters in generics

Support for "IsConstValue" intrinsic

Copy supports Open Array parameters

procedure Test(aArg: array of LongInt);
var
  arr: array of LongInt;
begin
  arr := Copy(aArg, 3, 5);
end;

Array constructors for static arrays

"Align" modifier support for record definitions

Support for binary literals in Delphi mode

{$mode Delphi}
var
  b: byte;
begin
  b:=%11001001;
end.

Support for Digit Separator

{$mode Delphi}
var
  i: Integer;
  r: Real;
begin
  i := %1001_1001;
  i := &121_102;
  i := 1_123_123;
  i := $1_123_123;  
  r := 1_123_123.000_000;
  r := 1_123_123.000_000e1_2;
end.

Support for if-expression / ternary operator

{$mode Delphi}
var
  X, Left: integer;
begin
  X := if Left < 100 then 22 else 45;
end;

Support for case-expression

{$ModeSwitch StatementExpressions}
type TMyEnum = (meFirst, meSecond, meLast);
var
  s: String;
begin
  s := case meSecond of
    meFirst: 'Foo';
    meSecond: 'Bar';
    meLast: 'FooBar';
  end;
end;

Support for try-except-expression

{$Mode ObjFPC}
{$ModeSwitch StatementExpressions}
var
  s: String;
begin
  s := try Fly() except 'Error' end;
  s := try GetSomethingRisky() except on o: EReadError do 'Read failed' else 'Error' end;
end;

Support for forward declarations of generic types

{$mode objfpc}
type
  generic TTest<T> = class;
  generic TFoo<T: class> = class;
  generic TBar<const N: LongInt> = class;

  TSomething = class
    fTest: specialize TTest<LongInt>;
    fFoo: specialize TFoo<TObject>;
    fBar: specialize TBar<42>;
  end;

  generic TTest<T> = class end;
  generic TFoo<T: class> = class end;
  generic TBar<const N: LongInt> = class end;

begin
end.

Support for Function References and Anonymous Functions

Descendant type helpers can extend type aliases

Support for Unicode RTL

Support for Extended RTTI

Support for NameOf()

// fetch a field value from a dataset without magic string
UserEmail := FieldByName(NameOf(TUser.Email)).AsString;

// Mapping properties in an ORM definition
ORMMap.BindProperty(NameOf(TCustomer.Address), 'db_column_address');

// logging
Logger.Debug('Connection status: ' + NameOf(FIsConnected) + ' = ' + BoolToStr(FIsConnected, True));

Units

DaemonApp

Additional control codes on Windows

Classes

Naming of Threads

Objects

TRawByteStringCollection
TUnicodeStringCollection
TStream methods for reading and writing RawByteString and UnicodeString
FUNCTION TStream.ReadRawByteString: RawByteString;
FUNCTION TStream.ReadUnicodeString: UnicodeString;
PROCEDURE TStream.WriteRawByteString (Const S: RawByteString);
PROCEDURE TStream.WriteUnicodeString (Const S: UnicodeString);

RawByteStrings are written to the stream as a 16-bit code page, followed by 32-bit length, followed by the string contents. UnicodeStrings are written as a 32-bit length (the number of 16-bit UTF-16 code units needed to encode the string), followed by the string itself in UTF-16.

Free Vision

Unicode support

Video

Unicode output support

Keyboard

Unicode keyboard input support
 TEnhancedKeyEvent = record
   VirtualKeyCode: Word;    { device-independent identifier of the key }
   VirtualScanCode: Word;   { device-dependent value, generated by the keyboard }
   UnicodeChar: WideChar;   { the translated Unicode character }
   AsciiChar: Char;         { the translated ASCII character }
   ShiftState: TEnhancedShiftState;
   Flags: Byte;
 end;

TEnhancedShiftState is a set of TEnhancedShiftStateElement, which is defined as:

 TEnhancedShiftStateElement = (
   essShift,             { either Left or Right Shift is pressed }
   essLeftShift,
   essRightShift,
   essCtrl,              { either Left or Right Ctrl is pressed }
   essLeftCtrl,
   essRightCtrl,
   essAlt,               { either Left or Right Alt is pressed, but *not* AltGr }
   essLeftAlt,
   essRightAlt,          { only on keyboard layouts, without AltGr }
   essAltGr,             { only on keyboard layouts, with AltGr instead of Right Alt }
   essCapsLockPressed,
   essCapsLockOn,
   essNumLockPressed,
   essNumLockOn,
   essScrollLockPressed,
   essScrollLockOn
 );

A special value NilEnhancedKeyEvent is used to indicate no key event available in the result of PollEnhancedKeyEvent:

 { The Nil value for the enhanced key event }
 NilEnhancedKeyEvent: TEnhancedKeyEvent = (
   VirtualKeyCode: 0;
   VirtualScanCode: 0;
   UnicodeChar: #0;
   AsciiChar: #0;
   ShiftState: [];
   Flags: 0;
 );

fcl-fpterm package

libjack package

Darwin/macOS platforms

Support for symbolicating Dwarf backtraces

New compiler targets

Support for code generation through LLVM

Support for address sanitizer (asan) through LLVM

Support for the Z80

Support for the WebAssembly target

Support for the PlayStation 1

Lazarus - Release Notes and GIT Branch with Release Fixes

Release notes for Version:

0.9.24 | 0.9.26 | 0.9.28 | 0.9.28.2 | 0.9.30 | 1.0 | 1.2 | 1.4 | 1.6 | 1.8 | 2.0 | 2.2 | 3.0 | 4.0 | 5.0

Fixes branch (How to merge):

0.9 | 1.0 | 1.2 | 1.4 | 1.6 | 1.8 | 2.0 | 2.2 | 3.0 | 4.0

Free Pascal Compiler - User Changes (Release Notes)