Forum > FPC development

Binary literals in Dephi mode

(1/2) > >>

VisualLab:
Is there a chance that the Free Pascal compiler will allow the use of literals in binary notation in a Delphi compliant compilation mode, ie: {$ mode Delphi}. I mean something like this:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---...{$mode Delphi}...const  SMyValue = %1011;var  A: Integer;begin  A := %1001101;...
The reason I am asking is because, for some time now, the Delphi compiler has finally accepts literals in binary notation in the source code. This appears to have been introduced in Delphi 10.4 (Sydney). This reference is in the Delphi help system on the Embarcadero website:

https://docwiki.embarcadero.com/RADStudio/Sydney/en/Fundamental_Syntactic_Elements_(Delphi)

in the section: "Binary Literals and Digit Separator").

There are also mentions of this on the website:

https://docwiki.embarcadero.com/RADStudio/Alexandria/en/What%27s_New

in the section: "Binary Literals and Digit Separator" and in the Alister Christie podcast:

https://www.youtube.com/watch?v=MskLyUagI8Y

Such a possibility would allow a set of different constants, classes using generics and declared constants to be placed in one module. I use this notation in the code of my own library supporting embedded devices (RPi, UP Squared). At the same time, the code of classes using generics is clearer and simpler in the variant proposed by Embarcadero (at least for me). In any case, I currently have to split the source code between two separate modules, even though it relates to the same topic/subject.

AlexTP:
Done in last days
https://gitlab.com/freepascal.org/fpc/source/-/commit/25eab57a582a022f3336e052971fd56d9d3cbfd9

VisualLab:
A very nice news :-) So it remains patient to wait for Lazarus with a compiler version that supports this possibility.

Remy Lebeau:

--- Quote from: VisualLab on January 07, 2022, 08:36:23 pm ---Is there a chance that the Free Pascal compiler will allow the use of literals in binary notation in a Delphi compliant compilation mode

--- End quote ---

I wouldn't hold my breath for it, considering {$mode Delphi} doesn't support most of the newer language features introduced after Delphi 7. The only new Delphi language feature added to FPC in recent years is UnicodeString, introduced in Delphi 2009, but that doesn't work in {$mode Delphi}, it requires {$mode DelphiUnicode}/{$modeswitch UnicodeStrings}.


--- Quote from: VisualLab on January 07, 2022, 08:36:23 pm ---The reason I am asking is because, for some time now, the Delphi compiler has finally accepts literals in binary notation in the source code.

--- End quote ---

"for some time now" being only 4 months.


--- Quote from: VisualLab on January 07, 2022, 08:36:23 pm ---This appears to have been introduced in Delphi 10.4 (Sydney).

--- End quote ---

Actually, it was introduced in Delphi 11.0 Alexandria:

https://docwiki.embarcadero.com/RADStudio/Alexandria/en/What%27s_New#Binary_Literals_and_Digit_Separator


--- Quote from: VisualLab on January 07, 2022, 08:36:23 pm ---This reference is in the Delphi help system on the Embarcadero website:

https://docwiki.embarcadero.com/RADStudio/Sydney/en/Fundamental_Syntactic_Elements_(Delphi)

--- End quote ---

The Sydney documentation is wrong.  The feature was not available until Alexandria.


--- Quote from: VisualLab on January 07, 2022, 08:36:23 pm ---There are also mentions of this ... in the Alister Christie podcast:

https://www.youtube.com/watch?v=MskLyUagI8Y

--- End quote ---

That video even says Delphi 11.


--- Quote from: VisualLab on January 07, 2022, 08:36:23 pm ---Such a possibility would allow a set of different constants, classes using generics and declared constants to be placed in one module.

--- End quote ---

What do you mean?


--- Quote from: VisualLab on January 07, 2022, 08:36:23 pm ---I use this notation in the code of my own library supporting embedded devices (RPi, UP Squared). At the same time, the code of classes using generics is clearer and simpler in the variant proposed by Embarcadero (at least for me). In any case, I currently have to split the source code between two separate modules, even though it relates to the same topic/subject.

--- End quote ---

Can you provide an example?

Remy Lebeau:

--- Quote from: Remy Lebeau on January 10, 2022, 02:29:15 am ---I wouldn't hold my breath for it, considering ...

--- End quote ---

I stand corrected...


--- Quote from: Alextp on January 07, 2022, 08:39:38 pm ---Done in last days
https://gitlab.com/freepascal.org/fpc/source/-/commit/25eab57a582a022f3336e052971fd56d9d3cbfd9

--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version