Re: [fpc-pascal] Feature announcement: implicit generic function specializations
On 22/04/2022 17:13, Rainer Stratmann via fpc-pascal wrote: Am Freitag, 22. April 2022, 17:27:33 CEST schrieb Hairy Pixels via fpc-pascal: On Apr 22, 2022, at 8:48 PM, Rainer Stratmann via fpc-pascal From assembly to high-level language there is a huge step. From high-level language to implicit generic function specializations it is a little step regarding the benefits. In my opinion it makes everything more complicated. My mind refuses to read the description of the new feature. But mostly I am worried because of the statement "has the potential to break existing code". Rainer, We assume this is a language feature you will not use in your code, which is fine. However, it is a cause for celebration among those who do welcome such syntax sugar, and will be using the feature to improve the size and readability of their code. kind regards, Howard ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On 29/12/2021 11:22, wkitty42--- via fpc-pascal wrote: On 12/29/21 4:54 AM, Michael Van Canneyt via fpc-pascal wrote: Translated to RPC: if you want speed, don't use HTTP or JSON. WST offers a binary protocol and plain TCP channel, it's bound to be much faster. i'm sorry... what is WST? googling for "wst binary protocol tcp ip channel" doesn't turn up anything informative for me and acronym searching is equally uninformative... getting old sucks :? WST stands for Web Services Toolkit, a package that offers both provision (authoring) of web services, and facilitates programming web service consumption. A package for the framework is available in Lazarus' online package manager. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TypeInfo on generic templates
On 29/10/2020 18:27, Ryan Joseph via fpc-pascal wrote: Is it possible that the TypeInfo intrinsic could work with generic template types or is this a bug? I get "Illegal qualifier" in the procedure below. generic procedure DoThis(a: array of T); begin writeln(TypeInfo(T)^.name); end; Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal What could .name return in this context? "placeholder for an as-yet-unspecialised and unknown type"? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Enum range check error
On 21/10/2020 21:34, Ryan Joseph via fpc-pascal wrote: I thought default would just return the first value in the enum but I guess it's just zeros. Maybe we need a better default for objfpc mode. The first element is returned by Low(TEnum), and the first value by Ord(Low(TEnum)). ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Dynamic Arrays in Procedures
On 04/10/2020 20:58, James Richters via fpc-pascal wrote: I’m wondering if there is a way to pass an array of values to a Procedure without defining an array variable…. For example, if I have a Procedure: Procedure DoSomething(X :Byte); Then I can call it with a specific a variable like this: Var ThingA :Byte; … DoSomething(ThingA); And I can also call it without a variable but instead just hard code a specific value like this: DoSomething($1A); So if I have a procedure like this: Procedure DoSomethingElse(Y :Array of Byte); I can call it like this: Var ThingB :Array Of Byte; SetLength(ThingB,3); ThingB[0] :=$12; ThingB[1] :=$1A; ThingB[2] :=$2B; DoSomethingElse(ThingB); But can I also just call it with specific values somehow? DoSomethingElse([$12,$1A,$2B]);for example… of course this doesn’t work, but is there a syntax that would work? There is array of const syntax. == code== program project1; {$mode objfpc} procedure ShowArray(anArray: array of const); var i: Integer; begin for i := Low(anArray) to High(anArray) do case anArray[i].VType of vtInteger: WriteLn(anArray[i].VInteger,' '); vtChar: WriteLn(anArray[i].VChar,' '); end; end; begin ShowArray([99, -1, 'p', 'G']); ReadLn; end. == code end== ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Range check error warning.
On 25/03/2020 17:46, wkitt...@windstream.net wrote: On 3/24/20 6:58 PM, Sven Barth via fpc-pascal wrote: wkitt...@windstream.net schrieb am Di., 24. März 2020, 18:37: you should figure out why typed constants are not being allowed/used in your setup... Typed constants can not be used to initialize constants. hummm... ok, so how to you get a constant to be a byte and storing 7 for the decimal value? or are you saying that you cannot use a typed constant in the init of another (typed) constant Try const seven = Byte(7); ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pass open array to static array?
On 15/03/2020 12:06, Ryan Joseph via fpc-pascal wrote: program test; var data: array[0..2] of integer; begin // Incompatible types: got "{Array Of Const/Constant Open} Array of ShortInt" expected "Array[0..2] Of LongInt" data := [1,2,3]; end. With recent FPCs you can however do this: program test; var data: array[0..2] of Integer; tmp: array of Integer = Nil; begin tmp := [1,2,3]; Move(tmp[0], data[0], SizeOf(data)); end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Compiler treatment of dotted reference in class property
On 03/02/2020 13:17, Sven Barth via fpc-pascal wrote: Howard Page-Clark via fpc-pascal <mailto:fpc-pascal@lists.freepascal.org>> schrieb am Mo., 3. Feb. 2020, 11:22: FPC 3.0.4 compiles this code excerpt without a murmur: == code == {$mode objfpc}{$H+} type TSheetInfo = record name: String; tab: String; title: String; kind: TSheetKind; // an enumeration color: TColor; end; TBaseSheet = class(TTabSheet) protected FSheetInfo: TSheetInfo; ... public constructor Create(aComponent: TComponent; aSheetInfo: TSheetInfo); virtual; reintroduce; ... property SheetKind: TSheetKind read FSheetInfo.kind; // << end; TEntryGrid = class(TCustomStringGrid) private FParentSheet: TBaseSheet; ... public constructor Create(AOwner: TComponent; aParentSheet: TBaseSheet); reintroduce; ... property SheetKind: TSheetKind read FParentSheet.FSheetInfo.kind; // << end; == code end == However, more recent FPCs (and trunk) reject this at the properties (marked above <<) with the error "Record or object type expected". Is there a modeswitch or other wheeze that will get recent FPCs to accept dotted notation when specifying property read and write fields? This is simply not allowed for class fields. That it was, was essentially a bug ( https://wiki.freepascal.org/User_Changes_Trunk#Property_field_access_lists_no_longer_allows_classes ). Either use records or (TP style) objects or use a getter. If you declare it as "inline" you can essentially get the same code (with the added bonus that you can raise an exception should the field be Nil). Regards, Sven Thanks for the reference and clarification. Howard ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Compiler treatment of dotted reference in class property
FPC 3.0.4 compiles this code excerpt without a murmur: == code == {$mode objfpc}{$H+} type TSheetInfo = record name: String; tab: String; title: String; kind: TSheetKind; // an enumeration color: TColor; end; TBaseSheet = class(TTabSheet) protected FSheetInfo: TSheetInfo; ... public constructor Create(aComponent: TComponent; aSheetInfo: TSheetInfo); virtual; reintroduce; ... property SheetKind: TSheetKind read FSheetInfo.kind; // << end; TEntryGrid = class(TCustomStringGrid) private FParentSheet: TBaseSheet; ... public constructor Create(AOwner: TComponent; aParentSheet: TBaseSheet); reintroduce; ... property SheetKind: TSheetKind read FParentSheet.FSheetInfo.kind; // << end; == code end == However, more recent FPCs (and trunk) reject this at the properties (marked above <<) with the error "Record or object type expected". Is there a modeswitch or other wheeze that will get recent FPCs to accept dotted notation when specifying property read and write fields? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Const attributes
On 30/07/17 19:55, Marcos Douglas B. Santos wrote: I would like to instantiate my attribute only once inside constructor and then it will be "const" or "final", I mean, immutable. Today it is not possible, right? Any thoughts to the future? It is not what you are asking for, but you can do this: ===code begin=== {$J-} const INT: Integer = 9; type TFoo = class strict private function GetINT: Integer; public property INT: Integer read GetINT; end; function TFoo.GetINT: Integer; begin Exit(INT); end; ===code end=== The INT property is 'immutable' because it is read-only, and you cannot assign to its typed integer referent because of the {$J-}. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Array clearing
On 04/04/17 05:25, Ryan Joseph wrote: Is it possible use FillChar on a multidimensional arrays? arr: array of array of array of integer. SetLength(arr, 3, 3, 3); FillChar(arr[0], (3*3*3)*sizeof(integer), false); I’m just getting crashes. You can always use FillChar and its kin on specific 'nested' arrays like this type TIntArray = array of Integer; TIntIntArray = array of TIntArray; TIntIntIntArray = array of TIntIntArray; procedure FillArray(const anArray: TIntIntIntArray; aValue: DWord); var x, y: integer; begin for x:=0 to High(anArray) do for y:=0 to High(anArray[x]) do FillDWord(anArray[x][y][0], Length(anArray[x][y]), aValue); end; ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal