I always use the one from generics.collections
- Original Message -
From: Alexey T. via fpc-pascal
To: FPC-Pascal users discussions
Sent: Saturday, January 11, 2025, 17:32:49
Subject: [fpc-pascal] Set limitations
> so it makes more sense
> to use a dedicated type instead (e.g. a hash s
Kurz via fpc-pascal schrieb am
Sa., 2. Nov. 2024, 18:47:
> when I make a record type managed by adding an `Initialize` operator
> according to [1], can I rely on the record being initialized at the
> beginning of a function in which the record is the function result?
> Example:
Do you have `{$MODESWITCH TYPEHELPERS}`?
- Original Message -
From: Adriaan van Os via fpc-pascal
To: FPC-Pascal users discussions
Sent: Saturday, November 2, 2024, 16:05:35
Subject: [fpc-pascal] type helpers in trunk
Has something changed for type helpers in fpc trunk ? I don 't see
Hello,
when I make a record type managed by adding an `Initialize` operator according
to [1], can I rely on the record being initialized at the beginning of a
function in which the record is the function result?
Example:
type TRec = record
// whatsoever
class operator Initialize(var aRec:
I'm trying to post this message again. I got no responses in August, maybe I
have better luck now :))
- Original Message -
From: Thomas Kurz via fpc-pascal
To: FPC-Pascal users discussions
Sent: Tuesday, August 20, 2024, 18:16:05
Subject: [fpc-pascal] Understanding error messag
Hello,
a quick question: how do I define a generic type helper?
Example:
type generic TArray = array of T;
type generic TArrayHelper = type helper for TArray
function Count: Cardinal;
function Contains (AItem: T): Boolean;
end;
This doesn't work, but I don't know how to do it properly.
Tha
Hello,
I am trying to statically link OpenSSL. I'm using the Win64 full installer from
https://slproweb.com/products/Win32OpenSSL.html which includes precopmiled
static libraries which were compiled with VC using the /MT, /MD, /MTd and /MDd
switches. This obviously stands for:
/MDCreates a
Great!
Is this Json Typedef as described here? https://jsontypedef.com/
Thomas
- Original Message -
From: Michael Van Canneyt via fpc-pascal
To: Lazarus mailing list
Sent: Saturday, August 17, 2024, 16:52:32
Subject: [fpc-pascal] JSON-Schema added
Hi,
I added a JSON-Schema class t
Hello,
in
`https://www.freepascal.org/docs-html/current/rtl/sockets/netaddrtostr6.html`,
it is written:
NetAddrToStr6 converts the IPV6 network address in Entry to a string
representation in human-readable form.
Basically, it is the same as NetAddrToStr6, but with the bytes in correct order.
> For constants, the compiler will choose a type and consequently the
> precision.
> Jonas and others have explained the rules that the compiler uses.
>
> If you don't like the rules that the compiler uses, you can set a type for
> your
> constants. When you explicitly set a type, you are also s
via fpc-pascal wrote:
>> If you're using Win64, then the answer is simple: x86_64-win64 unlike
>> any
>> other x86 target does not support Extended, so neither the compiler
>> nor the
>> code in runtime will ever calculate anything with that precision.
> That
> for example, here on Earth, (7 decimal places) 0.001 degree latitude is
> ""only"" 1cm... (8 decimal places) 0.0001 degree latitude is ""only""
> 1mm...
> longitude, on the other hand, is variable such that 7 decimal places at the
> equator is the same as latitude but as you move towa
> If you're using Win64, then the answer is simple: x86_64-win64 unlike any
> other x86 target does not support Extended, so neither the compiler nor the
> code in runtime will ever calculate anything with that precision.
That's another thing I've never understood. How can it depend on the OS? It'
> But, sorry, because we are talking about compile time math, performance
(nanoseconds) in this case doesn't count, IMO.
That's what i thought at first, too. But then I started thinking about how to
deal with it and sumbled upon difficulties very soon:
a) 8427.0 + 33.0 / 1440.0
An easy case: al
>> You cannot do this in Pascal. The evaluation of the expression on the
>> right of := does not
>> know (and should not know) what the type is of the expression on the left.
> It's even theoretically impossible to do in case the result is passed to
> a function or intrinsic that is overloaded w
I wouldn't say so. Or at least, not generally. Why can't the compiler do what
the programer intends to do:
var
s: single;
d: double;
e: extended;
begin
s := 8427.0 + 33.0 / 1440.0; // treat all constants all "single"
d := 8427.0 + 33.0 / 1440.0; // treat all constants all "double"
Hello Martin,
I've been using Pascal for more than 30 years now, but I must admit I've never
before seen the construct you posted.
And it doesn't compile either:
project1.lpr(4,4) Error: Syntax error, "." expected but ";" found
Kind regards,
Thomas
- Original Message -
From: Martin
Hello all,
I'm unsure about whether or not to report this as a bug. Imho, it is a bug, but
maybe there's a good reason to handle this.
Please take the following example:
---start---
program test;
begin
end.
{
---end---
Result:
Z:\>ppc386.exe testproj.pas
Free Pascal Compiler version 3.2.2
I think the reason why this new behavior doesn't occur with 1440.1 is that this
number cannot be reduced to "single" precision. It will keep "double" precision.
Consider this instead:
program TESTDBL1 ;
var TT : double ; EE: double;
begin (* HAUPTPROGRAMM *)
TT := 8427 + 33 / 1440.5 ;
EE
r able to get far enough in to realize this is what was
happening. It's very frustrating indeed and I think if something can be
done to save others this frustration and unexpected behavior, it would be
helpful.
James
-Original Message-
From: fpc-pascal On Behalf Of
Thomas Kurz via fpc-
I'd like to apologize, because my intention hasn't been to raise controverse
discussions. I'm very thankful about the explanation. From the beginning, I
knew that the error was on my side, but I didn't know *what* I'm doing wrong.
Again, thanks for helping.
Kind regards,
Thomas
- Origina
Thank you all
Finally I understand what's going wrong and can take care of that.
I'm now using the "{$MINFPCONSTPREC 64}" and have the correct result. Again,
thank you for pointing me to that behavior!
- Original Message -
From: Adriaan van Os via fpc-pascal
To: FPC-Pascal users
a fpc-pascal:
> On Sat, Jan 27, 2024 at 6:23 PM Thomas Kurz via fpc-pascal
> wrote:
>> Hmmm... I don't think I can understand that. If the precision of "double"
>> were that bad, it wouldn't be possible to store dates up to a precision of
>> millisecon
scal
To: FPC-Pascal users discussions
Sent: Saturday, January 27, 2024, 17:03:15
Subject: [fpc-pascal] Floating point question
On Sat, Jan 27, 2024 at 1:40 PM Thomas Kurz via fpc-pascal
wrote:
> My problems are:
> 1. The "writeln" in line 32 correctly prints "0." wh
Hello,
I'm facing some strange floating-point issues and cannot find what's actually
wrong. OS is win64, but I'm even getting different results when targeting to
win32.
Please consider the following program:
program test1;
{$mode objfpc}
function maketime (ayear, amonth, aday, ahour, aminute
Hello,
I'm using a declaration like this
TYPE TRSMControl = FUNCTION (AData: PtrInt): PtrInt; CDECL; VARARGS;
VAR RSMControl: TRSMControl;
to make calls to a DLL function which expects a variable number of arguments.
For example:
RSMControl (PtrInt(1), PtrInt(2), PtrInt(3))
On win32, this wor
omething else I
need to do?
Thank you,
kind regards,
Thomas
- Original Message -
From: Marco van de Voort via fpc-pascal
To: fpc-pascal@lists.freepascal.org
Sent: Friday, December 29, 2023, 12:37:54
Subject: [fpc-pascal] Daily snapshots?
Op 27/12/2023 om 12:38 schreef Thomas Kurz
I think he wants to define his own procedure.
The nearest thing that comes into my mind is using ARRAY OF CONST, but the call
requires square brackets, then:
procedure myproc (x: string; y: array of const);
begin ... end;
myproc ('Hello world', ['Number 1', 'Number 2', 3, 4.0]);
- Origina
Hello,
as it seems to take longer for the next major release, I'd appreciate if
automated snapshots could be provided either daily or weekly.
In the documentation, I found a link to
ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/ but I cannot login. I tried
with user=anynous and password=my-e
> An exception or an internal error during compilation should *always* be
> reported.
> Please also provide a minimal, self contained example that shows the
> problem.
This is not always trivial because the internal errors are sometimes quite
fiddly. I have a project in which an internal error oc
> Does this mean I can code an application in Pascal and use webassembly
to turn it into a web application? If so, could you please point me to
some simple examples?
Without having WebAssembly used yet: As far as I understand, that should be
possible.
The "entry point" is here: https://wiki.free
I have to extend code from QuickBasic and am using the "msdos" target from FPC
3.2 for that purpose. The resulting exe file is linked with Microsoft Linker
for DOS version 5.10. It links *.a files created both from QuickBasic and FPC.
The memory model is i8086-small.
Basically, it works well.
fpJson fully supports JSON:
https://www.freepascal.org/docs-html/fcl/fpjson/index.html
https://wiki.lazarus.freepascal.org/JSON
There's also JSON support in the LGenerics package, but it's not a bundled
package as far as I know.
Thomas
- Original Message -
From: Darius Blaszyk via fp
Dear all,
I have spent 2 days now tracking an access violation in my app which I couldn't
debug well because it occured somewhere where no debug info was available, but
obviously during a call to FreeLibrary.
I don't know whether I am allowed to do this or not, but as far as I have read
from t
I'm certainly not the expert in FPC's details, so maybe there'll you'll get a
better answer. I just tell you my point of view.
>> It's an array with a terminator
>>string? Probably the length of the array should be set instead of
>>doing string compares every loop.
>
> I need to set it in the var
I do not think that this discussion is of any value. If you need to care for
every byte, you'd better consider using asm. In times of e-mail clients using
far more than 100 MB of disk and RAM memory or simple Android apps having
several dozens of megabytes because of the included trackers, it se
It's part of generics.collections and located in
fpc\3.2.2\source\packages\rtl-generics\src\*
- Original Message -
From: Hairy Pixels via fpc-pascal
To: FPC-Pascal users discussions
Sent: Friday, May 12, 2023, 14:59:11
Subject: [fpc-pascal] Multiple enumerators per class
> On May 12
> I would expect the type helper to remain functional. The types are the same
> for all purposes except they have a different RTTI entry.
But this behaviour seems inconsistent to me. For example:
With "var x:double" I can use "x.IsNan". With TDateTime, which is defined as
"type TDateTime = type
pply to
TVec3f at all because TSomething is defined as a new type, not only an alias
for TVec3f.
- Original Message -
From: Michael Van Canneyt via fpc-pascal
To: Thomas Kurz via fpc-pascal
Sent: Tuesday, May 9, 2023, 23:55:47
Subject: [fpc-pascal] Record Constructors which differ in pa
Hello,
let's take the following example:
program Project1;
{$MODE OBJFPC}
{$MODESWITCH ADVANCEDRECORDS}
{$MODESWITCH TYPEHELPERS}
type TVec3f = record
x, y, z: Double;
constructor Create (a1, a2, a3: Double);
end;
type TSomething = type TVec3f;
type TSomethingHelper = type helper for TSom
Just a very minor question:
Is it intentional that StrIComp (from the strings unit) gives an access
violation if one of its arguments is NIL?
I hardly work with PChars so this is a serious question from me.
___
fpc-pascal maillist - fpc-pascal@lists
I always use ScanDateTime for such purposes:
https://www.freepascal.org/docs-html/rtl/dateutils/scandatetime.html
You can explicitly define the pattern.
- Original Message -
From: Bo Berglund via fpc-pascal
To: fpc-pascal@lists.freepascal.org
Sent: Monday, April 24, 2023, 20:08:01
S
Hello,
I have seen that the functions for dealing with modified Julian dates are
documented as "not yet implemented". Is there a particular reason for that? If
not, I'd make an implementation and post it on Gitlab.
Kind regards,
Thomas
___
fpc-pascal
Didn't know that either:
"It should be stressed that typed constants are automatically initialized at
program start. This is also true for local typed constants and initialized
variables. Local typed constants are also initialized at program start. If
their value was changed during previous inv
There will surely be better responses than mine, but imho there is an
inconsistency in your code: Near/Far calls are a relict of the 16-bit
DOS/Win3.x era. The {$F+} switch should be completely obsolete for both Win32
and Win64 executables.
.obj files are compiled code (pieces) which are not ye
Dear all,
I'm testing FPC-trunk and I'm especially interested in using anonymous
functions because they should simplify working with TThread.Synchronize and
others a lot.
I stumbled upon an issue which I'd like to post here first because I am not
sure whether it's a bug or just a wrong usage o
Understood, ok. Thanks for your explanation.
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Hello,
by chance, I stumbled upon a strange behavior in floating-point calculation.
Here's the example:
program Project1;
var
f: double;
n: integer = 1758;
m: integer = 0;
begin
f := n * 1.2E6 + (2*m+1) * 50E3; // 2109650048
f := Double(n) * 1.2E6 + Double(2*m+1) * 50E3; // 210965000
I don't know whether this is actually a bug or not but I cannot find a hint in
the documentation.
It seems that methods assigned to an event handler are not allowed to be
overloaded. Or, to be more precise, FPC always uses the first declaration
regardless whether it fits or not.
Example:
pro
If you just don't like the "-1" for readability, you might also wan't to
consider using
for i := 0 to Pred(f.Count) do ...
- Original Message -
From: Thomas Kurz via fpc-pascal
To: 'FPC-Pascal users discussions'
Sent: Saturday, September 10, 2022, 21:3
Try this (note the "modeswitch"):
program Project1;
{$modeswitch typehelpers}
uses
Classes,
SysUtils;
type TStringListHelper = class helper for TStringList
function High: NativeInt;
end;
function TStringListHelper.High: NativeInt;
begin
Exit (Self.Count-1);
end;
var
f: TStringList =
Another alternative would be declaring a helper:
type TStringListHelper = class helper for TStringList
function High: NativeInt;
end;
function TStringListHelper.High: NativeInt;
begin
Exit (Self.Count-1);
end;
- Original Message -
From: James Richters via fpc-pascal
To: 'FPC-Pascal
I currently have only a few missing symbols, mostly math related:
Hint: (11030) Start of reading config file
P:\Lazarus\fpc\3.2.2\bin\x86_64-win64\fpc.cfg
Hint: (11031) End of reading config file
P:\Lazarus\fpc\3.2.2\bin\x86_64-win64\fpc.cfg
Warning: (11018) You are using the obsolete switch -St
?
- Original Message -
From: Sven Barth via fpc-pascal
To: FPC-Pascal users discussions
Sent: Friday, June 24, 2022, 10:43:55
Subject: [fpc-pascal] Operator not overloaded
Thomas Kurz via fpc-pascal schrieb am
Do., 23. Juni 2022, 19:45:
> When compiling, I get this error:
> pathfindi
Hello,
I have tried to create an example as minimalistic as possible. I have three
files:
*** file: pathfinding.pas ***
unit PathFinding;
{$mode objfpc}
interface
type generic TAStar = class (TObject)
public function FindPath (const AStart: T; const ADestination: T): Boolean;
virtual;
end
Hello,
in my program I have need for checking floating-point precision. I'm internally
using floating-points for calculations, but in the end I have to use integer
numbers. I cannot use Round() because I have to check for thresholds. I.e. that
I wish to accept a value of 1. as being ">=
This is horrendous code, especially the last example. Looks like PHP or
JavaScript, which I hate because their code is hard to read. I'm using pascal
because I like its clean and easy-to-read syntax.
"-1" is a statement that should give a compiler error. "Result" and "Exit(x)"
are established c
Great!!! Thank you very very much :)))
- Original Message -
From: Sven Barth via fpc-pascal
To: fpc-annou...@lists.freepascal.org
Sent: Thursday, May 26, 2022, 21:47:06
Subject: [fpc-pascal] Feature Announcement: Function References and Anonymous
Functions
Dear Free Pascal Community,
Dear all,
please consider the following code:
program Project1;
{$booleval off}
var
v1, v2: variant;
a: boolean;
b: integer;
begin
a := true;
b := 0;
// this works as expected:
if a and (b > 0) and ((0+1) mod b = 0) then Writeln ('ok');
v1 := true;
v2 := 0;
// this gives
end;
procedure TMyData.Run;
begin
method (a);
Self.Free;
end;
...
MyData := TMyData.Create;
MyData.a := ...;
MyData.method := @SomeMethodWithParameters;
TThread.ForceQueue (NIL, @MyData.Run)
- Original Message -
From: Michael Van Canneyt via fpc-pascal
To: Th
;
MyData.a := ...;
MyData.method := @SomeMethodWithParameters;
TThread.Synchronize(NIL, @MyData.Run)
- Original Message -
From: Michael Van Canneyt via fpc-pascal
To: Thomas Kurz via fpc-pascal
Sent: Monday, April 25, 2022, 16:58:26
Subject: [fpc-pascal] Correct way for using TThread.ForceQu
readMethod = procedure of object".
- Original Message -
From: Mattias Gaertner via fpc-pascal
To: fpc-pascal@lists.freepascal.org
Sent: Monday, April 25, 2022, 16:12:40
Subject: [fpc-pascal] Correct way for using TThread.ForceQueue?
On Mon, 25 Apr 2022 15:47:57 +0200
Tho
Hello,
my question is about using the TThread.Synchronize, Queue and ForceQueue
methods. Unfortunately, the parameter they take is of type TThreadMethods which
allows calling only methods having no parameters at all. I assume this is done
to simplify the implementation on client-side but causes
Dear all,
I'm not sure whether or not this is an issue with fpdebug, so I'd like to
describe it here first:
I have a main program (Win32 GUI running on Win 8.1) which loads and unloads a
DLL dynamically. I know that fpdebug is currently not able to debug DLLs, but
imho I don't do so, but the i
Thank you for continuously enhancing Free Pascal. Happy to see every new
feature :)
Is there any work ongoing about overloaded properties? E.g.
property x: integer read GetX;
property x[aindex: integer]: integer write SetX;
I know that declaring the property only once and overloading the getter
> The "Reference to procedure" that will be part of anonymous functionswill do
> this for you.
What release are anonymous functions planed for? FPC 3.4.0?
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/
Consider the following code:
***
PROGRAM project1;
{$mode objfpc}
{$longstrings on} // see output below
{$modeswitch advancedrecords}
USES Variants, Generics.Collections, SysUtils;
TYPE TRecord = PACKED RECORD
FID: NativeUInt;
FKey: String;
CONSTRUCTOR Create (AID: NativeUInt; AKey: Strin
67 matches
Mail list logo