Re: [fpc-pascal] Caller agnostic procedure variables

2022-02-15 Thread Thomas Kurz via fpc-pascal
> 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

[fpc-pascal] Strange behavior in generics.collections TDictionary

2022-01-26 Thread Thomas Kurz via fpc-pascal
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:

Re: [fpc-pascal] What is webasssembly?

2023-10-12 Thread Thomas Kurz via fpc-pascal
> 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:

Re: [fpc-pascal] Error: compilation raised exception internally

2023-10-21 Thread Thomas Kurz via fpc-pascal
> 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

[fpc-pascal] Possible fpdebug issue

2022-04-23 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Correct way for using TThread.ForceQueue?

2022-04-25 Thread Thomas Kurz via fpc-pascal
hod = 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 Thomas Kurz v

Re: [fpc-pascal] Correct way for using TThread.ForceQueue?

2022-04-25 Thread Thomas Kurz via fpc-pascal
:= ...; 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.ForceQueue

Re: [fpc-pascal] Correct way for using TThread.ForceQueue?

2022-04-25 Thread Thomas Kurz via fpc-pascal
rocedure 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: Thomas Kurz

[fpc-pascal] Correct way for using TThread.ForceQueue?

2022-04-25 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Feature announcement: implicit generic function specializations

2022-04-23 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Feature Announcement: Function References and Anonymous Functions

2022-05-26 Thread Thomas Kurz via fpc-pascal
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

[fpc-pascal] Strange "division by zero" error using variants

2022-05-24 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Feature Announcement: Function References and Anonymous Functions

2022-05-28 Thread Thomas Kurz via fpc-pascal
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

[fpc-pascal] Operator not overloaded

2022-06-23 Thread Thomas Kurz via fpc-pascal
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;

Re: [fpc-pascal] Operator not overloaded

2022-06-24 Thread Thomas Kurz via fpc-pascal
there? - 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

[fpc-pascal] Functions for dealing with floating-point precision

2022-06-19 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Teaching Kids Using Free Pascal

2022-08-27 Thread Thomas Kurz via 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

[fpc-pascal] How to assign overloaded event handler?

2022-09-14 Thread Thomas Kurz via fpc-pascal
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:

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Get highest element of a StringList

2022-09-10 Thread Thomas Kurz via fpc-pascal
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:37:34 Subject: [fpc-p

Re: [fpc-pascal] Strange floating-point result

2022-11-11 Thread Thomas Kurz via fpc-pascal
Understood, ok. Thanks for your explanation. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Strange floating-point result

2022-11-11 Thread Thomas Kurz via 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; //

[fpc-pascal] Working with anonymous functions

2023-03-10 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] How to use StrToDateTime() to convert a string with no delimiters?

2023-04-24 Thread Thomas Kurz via fpc-pascal
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

[fpc-pascal] StrIComp

2023-04-29 Thread Thomas Kurz via fpc-pascal
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] DateUtils: (Try)ModifiedJulianDateToDateTime not implemented

2023-04-16 Thread Thomas Kurz via fpc-pascal
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 ___

Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-04-04 Thread Thomas Kurz via 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

Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-21 Thread Thomas Kurz via fpc-pascal
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

[fpc-pascal] msdos: unresolved external

2023-07-12 Thread Thomas Kurz via fpc-pascal
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.

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-26 Thread Thomas Kurz via fpc-pascal
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

[fpc-pascal] LoadLibrary, FreeLibrary & Threads (win32)

2023-06-22 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Legitimate use of for and break

2023-06-16 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Parse JSON

2023-06-25 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Record Constructors which differ in parameter lists

2023-05-10 Thread Thomas Kurz via fpc-pascal
Vec3f 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 parameter li

Re: [fpc-pascal] Multiple enumerators per class

2023-05-12 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Record Constructors which differ in parameter lists

2023-05-12 Thread Thomas Kurz via fpc-pascal
> 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

[fpc-pascal] Record Constructors which differ in parameter lists

2023-05-09 Thread Thomas Kurz via fpc-pascal
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

[fpc-pascal] "Unexpected end of file" when having an open comment after the final "end."

2024-02-08 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] "Unexpected end of file" when having an open comment after the final "end."

2024-02-08 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Floating point question

2024-02-06 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Floating point question

2024-02-06 Thread Thomas Kurz via fpc-pascal
ing. 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-pascal Sent: Tuesday, February 6, 2024 6:59 AM To: 'FPC-Pascal users d

Re: [fpc-pascal] Floating point question

2024-02-06 Thread Thomas Kurz via fpc-pascal
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 -

Re: [fpc-pascal] Floating point question

2024-02-13 Thread Thomas Kurz via fpc-pascal
> 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:

Re: [fpc-pascal] Floating point question

2024-02-12 Thread Thomas Kurz via fpc-pascal
>> 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

Re: [fpc-pascal] Floating point question

2024-02-06 Thread Thomas Kurz via fpc-pascal
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 ;

Re: [fpc-pascal] Floating point question

2024-02-12 Thread Thomas Kurz via fpc-pascal
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"

[fpc-pascal] Daily snapshots?

2023-12-27 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Procedures that work like WRITELN()

2023-12-27 Thread Thomas Kurz via fpc-pascal
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]); -

Re: [fpc-pascal] Daily snapshots?

2023-12-29 Thread Thomas Kurz via fpc-pascal
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 via fpc-pascal

[fpc-pascal] Does the varargs specifier behave differently on 32 and 64 bit platforms?

2024-01-05 Thread Thomas Kurz via fpc-pascal
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

Re: [fpc-pascal] Floating point question

2024-01-27 Thread Thomas Kurz via fpc-pascal
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." when (cross-

[fpc-pascal] Floating point question

2024-01-27 Thread Thomas Kurz via fpc-pascal
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,

Re: [fpc-pascal] Floating point question

2024-02-02 Thread Thomas Kurz via fpc-pascal
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 >> milliseconds in a TDateTime. I have a discrepa

Re: [fpc-pascal] Floating point question

2024-02-22 Thread Thomas Kurz via fpc-pascal
> 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

Re: [fpc-pascal] Floating point question

2024-02-22 Thread Thomas Kurz via fpc-pascal
> 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?

Re: [fpc-pascal] Floating point question

2024-02-22 Thread Thomas Kurz via fpc-pascal
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's an

Re: [fpc-pascal] Floating point question

2024-02-22 Thread Thomas Kurz via fpc-pascal
> 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