Forum > Free Pascal

Feature announcement: Implicit generic function specializations

<< < (2/4) > >>

marcov:

--- Quote from: Okoba on April 21, 2022, 09:30:24 am ---If I have two overloaded functions in a unit, FPC detects the the correct one but if I split them in two units, it will raise an error:

--- End quote ---

(possibly related to  https://gitlab.com/freepascal.org/fpc/source/-/issues/39673 that I found last week)


Warfley:
The implicit specialization does not seem to handle inheritance very well:

--- 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";}};} ---program Project1; {$mode objfpc}{$H+}{$ModeSwitch implicitfunctionspecialization} uses  Generics.Collections; generic procedure Foo<T>(lst: specialize TEnumerable<T>);beginend; var  lst: specialize TList<Integer>; // Inherits from TEnumerablebegin                 Foo(lst); // Error  specialize Foo<Integer>(lst); // worksend.

PascalDragon:

--- Quote from: mas steindorff on April 20, 2022, 08:16:46 pm ---this sounds like it's just the ticket for what I'm working with. 
What version /package / ?? do I need to download to access these features?

--- End quote ---

New features are first available only in the development version (aka main) until the next major release (which will be 3.4.0 in some undetermined time in the future). So you'll have to clone the Git repository and compile FPC yourself. Or as is the hype nowadays: use FpcUpDeluxe.


--- Quote from: marcov on April 21, 2022, 10:37:30 am ---
--- Quote from: Okoba on April 21, 2022, 09:30:24 am ---If I have two overloaded functions in a unit, FPC detects the the correct one but if I split them in two units, it will raise an error:

--- End quote ---

(possibly related to  https://gitlab.com/freepascal.org/fpc/source/-/issues/39673 that I found last week)

--- End quote ---

Maybe, yes...

@Okoba: please report it nevertheless with a nice, simple example.


--- Quote from: Warfley on April 21, 2022, 10:39:01 am ---The implicit specialization does not seem to handle inheritance very well:

--- 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";}};} ---program Project1; {$mode objfpc}{$H+}{$ModeSwitch implicitfunctionspecialization} uses  Generics.Collections; generic procedure Foo<T>(lst: specialize TEnumerable<T>);beginend; var  lst: specialize TList<Integer>; // Inherits from TEnumerablebegin                 Foo(lst); // Error  specialize Foo<Integer>(lst); // worksend.
--- End quote ---

Please report.

Okoba:
Reported all at #39677, #39678 and #39680.

PascalDragon:

--- Quote from: Okoba on April 21, 2022, 03:35:35 pm ---Reported all at #39677, #39678 and #39680.

--- End quote ---

Thank you.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version