<p dir="ltr">Hi all,</p>
<p dir="ltr">If type inference is not planned, then do you have an alternative to support linq like expression methods ? If type inference is not used then the syntax is very verbose if not ugly.</p>
<p dir="ltr">Also I though that type inference is kind of important for proper lambda support but I might be wrong.</p>
<p dir="ltr">Anyways congratulations, very nice feature.</p>
<p dir="ltr">Thank you<br></p>
<p dir="ltr">Chriss Kalogeropoulos</p>
<div class="gmail_quote">On Nov 22, 2015 11:32 AM, "Sven Barth" <<a href="mailto:pascaldragon@googlemail.com">pascaldragon@googlemail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 22.11.2015 00:04, Anthony Walter wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sven, first off, congratulations and we thank you for so much good work.<br>
in the future do you see a time when type inference could be used?<br>
<br>
S := Add('hello ', 'world');<br>
I := Add(1, 2);<br>
</blockquote>
<br>
I honestly don't think that type inference should become part of Pascal, it's simply not part of the language philosophy and it would also not play well with the need for "specialize" in ObjFPC mode and as long as Delphi doesn't introduce it I won't add it only for mode Delphi either.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Which then brings to mind, will it be possible to get use references to<br>
generic routines?<br>
</blockquote>
<br>
If you have read the limitations part of my mail then you should know that this is a known limitation and to be addressed in the future.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
type<br>
TTransform<T> = function<T>(const A, B: T): T;<br>
</blockquote>
<br>
FPC already supports this, though the syntax is<br>
<br>
=== code begin ===<br>
<br>
type<br>
TTransform<T> = function(const A, B: T): T;<br>
<br>
=== code end ===<br>
<br>
Or with added "generic" keyword in case of non-Delphi modes.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
var<br>
Transform: TTransform<T>;<br>
</blockquote>
<br>
This is not a valid type declaration and never will be, because "T" is not defined. The correct one is<br>
<br>
=== code begin ===<br>
<br>
var<br>
Transform: TTransform<String>;<br>
<br>
=== code end ===<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
begin<br>
Transform := Add<String>;<br>
WriteLn(Transform('hello', 'world'));<br>
Transform := Min<String>;<br>
WriteLn(Transform('hello', 'world'));<br>
Transform := Max<String>;<br>
WriteLn(Transform('hello', 'world'));<br>
end;<br>
</blockquote>
<br>
This would work once assignments of routines work. In non-Delphi modes the syntax will be<br>
<br>
=== code begin ===<br>
<br>
Transform := @specialize Add<String>;<br>
Writeln(Transform('hello', 'world'));<br>
<br>
=== code end ===<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
function Print<T>(const A, B: T; Transform: TTransform<T>);<br>
begin<br>
WriteLn(Transform(A, B));<br>
end;<br>
<br>
begin<br>
Print('hello', 'world', Add); // type inference<br>
Print('hello', 'world', Min);<br>
Print('hello', 'world', Max);<br>
end;<br>
</blockquote>
<br>
No type inference.<br>
<br>
Regards,<br>
Sven<br>
<br>
_______________________________________________<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org" target="_blank">fpc-devel@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel" rel="noreferrer" target="_blank">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a><br>
</blockquote></div>