Forum > Free Pascal

Feature announcement: Implicit generic function specializations

<< < (3/3)

Warfley:
Some thing I've found, which I did not report as a bug yet, because I don't know if it is desired (as this might very well introduce a load of unwanted side effects), is that implicit specialization is not recognizing possible implicit casts:

--- 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 advancedrecords}{$ModeSwitch implicitfunctionspecialization} type  generic TTest<T> = record    class operator :=(const rhs: T): specialize TTest<T>;  end; generic procedure Foo<T>(arg: specialize TTest<T>);beginend; begin  specialize foo<Integer>(42); // Works  foo(42); // Errorend.But it could be useful with for example the TNullable type

PascalDragon:

--- Quote from: Warfley on April 22, 2022, 09:54:32 pm ---Some thing I've found, which I did not report as a bug yet, because I don't know if it is desired (as this might very well introduce a load of unwanted side effects), is that implicit specialization is not recognizing possible implicit casts:
--- End quote ---

Currently this is indeed by design as at least Delphi does not allow it either. And I personally prefer that we don't open that pandora's box... (especially es it might become problematic to determine what is a suitable specialization if there are multiple valid implicit assignments to do this in more complex scenarios)

Navigation

[0] Message Index

[*] Previous page

Go to full version