Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-12-01 Thread Sven Barth
Am 02.12.2015 07:44 schrieb "leledumbo" : > > Sven, I try the generic method inside one of my libraries and it generates > internal error 200204175, but I can't reproduce it with smaller programs. > How do you think I can help you to see it? It's currently a private project > in bitbucket (just bec

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-12-01 Thread leledumbo
Sven, I try the generic method inside one of my libraries and it generates internal error 200204175, but I can't reproduce it with smaller programs. How do you think I can help you to see it? It's currently a private project in bitbucket (just because I don't want people to use it before it's API s

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-29 Thread leledumbo
> With regards to constraints, I tried them previously, but went back to test them again realized that with class methods the constraint must be in the method declaration of the class only. This needs to be documented, I did the same mistake as you. -- View this message in context: http://fre

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-24 Thread DougC
But first fix the code so the test is correct. (The Min function is exactly the same as the Max function. Min should have A < B, not A > B.) On Tue, 24 Nov 2015 08:31:08 -0500 Sven Barth wrote Am 24.11.2015 14:26 schrieb "Anthony Walter"

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-24 Thread Anthony Walter
Mantis entry: http://bugs.freepascal.org/view.php?id=29080 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-24 Thread Sven Barth
Am 24.11.2015 13:53 schrieb "che fou" : > > cool news , this is absolutely a great feature . thanks > but seems generic function can't be inline ! *thinks about this* Oh yeah... I also see why. :/ Would you please report this as a bug with a simple example so it won't be forgotten? :) Regards, Sv

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-24 Thread Sven Barth
Am 24.11.2015 14:26 schrieb "Anthony Walter" : > > Sven, it would seem you cannot currently cannot pass a generic T to resolve the type of another generic subroutine. > > In this example, Test cannot reuse T in its call to Min. I believe this line should be legal "Value := Min(A, B);" (see the code

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-24 Thread Anthony Walter
Sven, it would seem you cannot currently cannot pass a generic T to resolve the type of another generic subroutine. In this example, Test cannot reuse T in its call to Min. I believe this line should be legal "Value := Min(A, B);" (see the code below for context) Currently when you try to compile

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-24 Thread che fou
cool news , this is absolutely a great feature . thanks but seems generic function can't be inline ! keep up the good work ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-23 Thread Anthony Walter
Here is another test, a bit more complex. It fails when trying to pass a procedure reference to the Execute. This is a bit different than trying to get a reference to a generic routine. Routines like ControlMove and ShapeColor and not generic. {$mode delphi} type TForEach = procedure(Item: T; A

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-22 Thread Anthony Walter
More ... // This works function TestIsAs2(Item: TObject): T; begin if Item is T then begin Exit(Item as T); end; Result := nil; end; Now before you say "of course" :) I find it interesting because is and as are operators, just like > greater than and < less than are operators. In pre

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-22 Thread Anthony Walter
Sven, in the with regards to "of course", I think you have it reversed. Is and as were being used as a class in my test, not an object. All examples in {$mode delphi} if Form1.Components[I] is T then // does not compile in my test while if Form1.Components[I].Inheritsfrom(T) // did compile In

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-22 Thread Sven Barth
On 22.11.2015 21:29, Anthony Walter wrote: Test 2 works but with notes: function Find: T; var I: Integer; begin for I := 0 to Form1.ComponentCount - 1 do if Form1.Components[I].InheritsFrom(T) then Exit(T(Form1.Components[I])); Result := nil; end; Example 2 usage: Find.Brush.Color :=

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-22 Thread Anthony Walter
Here are a few tests ... Test 1 works: function Swap(var A, B: T): T; var C: T; begin C := A; A := B; B := C; end; Example 1 usage: Swap(I, J); // J now holds I value, I value holds J Test 2 works but with notes: function Find: T; var I: Integer; begin for I := 0 to Form1.Componen

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-22 Thread leledumbo
> So basically just use it as a single factor (or statement) and you'll be fine until I've improved that. Roger that. -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Feature-announcement-Generic-functions-procedures-and-methods-tp5723106p5723115.html Sent fr

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-21 Thread Sven Barth
On 21.11.2015 19:09, leledumbo wrote: Congratulations! Nice work, Sven. It's a bit weird to see the specialize in the middle of an expression but that's not a problem for me. The one that needs explanation is "complex expressions", what's the minimum requirement for an expression to be called com

Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-21 Thread leledumbo
Congratulations! Nice work, Sven. It's a bit weird to see the specialize in the middle of an expression but that's not a problem for me. The one that needs explanation is "complex expressions", what's the minimum requirement for an expression to be called complex for this case? Sven Barth-2 wrote

[fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-21 Thread Sven Barth
Hello together! I'm pleased to finally announce the addition of generic functions, procedures and methods (collectively called "routines") to Free Pascal which allows writing type safe methods that can be used for multiple types. Syntax: The syntax for declaring a generic routine is similar