<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Tiburon - Anonymous Methods</title>
	<atom:link href="http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/</link>
	<description>Product Line Sales Manager and Technical Leader Evangelist for Latin America</description>
	<pubDate>Fri, 05 Dec 2008 14:50:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: El Cy</title>
		<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3492</link>
		<dc:creator>El Cy</dc:creator>
		<pubDate>Mon, 04 Aug 2008 20:18:51 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3492</guid>
		<description>It is just me (don't want to offend anybody !!!) ... but also CodeGear guys (maybe excepting Barry) ... are also puzzled  by the new Delphi addition: closures.... 

Until a very good usage scenario (maybe inspired from C#, JavaScript, Ruby, Groovy...etc)  of closures will not be provided (adapted to Delphi) ... we will just continue to be biased against the creepy syntax :) ...

I just assume that anon-methods (closures) were added to Delphi (currently just in Win32/ no .NET mention) to align to the current modern language features (.NET family + dynamic ones) and also to support future devel as native Delphi Linq-like syntax sugar [maybe using sets ?] and future C++0x lambdas... Just a guess...

Barry just promised us some real-word examples for Delphi closures ... so lets press Barry for releasing these gems :)</description>
		<content:encoded><![CDATA[<p>It is just me (don&#8217;t want to offend anybody !!!) &#8230; but also CodeGear guys (maybe excepting Barry) &#8230; are also puzzled  by the new Delphi addition: closures&#8230;. </p>
<p>Until a very good usage scenario (maybe inspired from C#, JavaScript, Ruby, Groovy&#8230;etc)  of closures will not be provided (adapted to Delphi) &#8230; we will just continue to be biased against the creepy syntax <img src='http://blogs.codegear.com/andreanolanusse/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &#8230;</p>
<p>I just assume that anon-methods (closures) were added to Delphi (currently just in Win32/ no .NET mention) to align to the current modern language features (.NET family + dynamic ones) and also to support future devel as native Delphi Linq-like syntax sugar [maybe using sets ?] and future C++0x lambdas&#8230; Just a guess&#8230;</p>
<p>Barry just promised us some real-word examples for Delphi closures &#8230; so lets press Barry for releasing these gems <img src='http://blogs.codegear.com/andreanolanusse/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bart roozendaal</title>
		<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3491</link>
		<dc:creator>bart roozendaal</dc:creator>
		<pubDate>Mon, 04 Aug 2008 18:45:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3491</guid>
		<description>I'm afraid I'm with the sceptical people out there. I don't see the value in this all. Looking at the examples out there, and even this one, it simply makes the code more complex (to read) and the things shown with the examples are very doable using the OO techniques that we currently have.

Others may like this; I'm glad I don't need to use them if I don't want to.</description>
		<content:encoded><![CDATA[<p>I&#8217;m afraid I&#8217;m with the sceptical people out there. I don&#8217;t see the value in this all. Looking at the examples out there, and even this one, it simply makes the code more complex (to read) and the things shown with the examples are very doable using the OO techniques that we currently have.</p>
<p>Others may like this; I&#8217;m glad I don&#8217;t need to use them if I don&#8217;t want to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz&#8217;s Weblog : Understanding Anonymous Methods</title>
		<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3489</link>
		<dc:creator>Craig Stuntz&#8217;s Weblog : Understanding Anonymous Methods</dc:creator>
		<pubDate>Mon, 04 Aug 2008 14:37:42 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3489</guid>
		<description>[...] to the Delphi roadmap, anonymous methods will be assignable to procedure references.  You can see an example of this on Andreano Lanusse&#8217;s [...]</description>
		<content:encoded><![CDATA[<p>[...] to the Delphi roadmap, anonymous methods will be assignable to procedure references.  You can see an example of this on Andreano Lanusse&#8217;s [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wim van Nifterick</title>
		<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3487</link>
		<dc:creator>Wim van Nifterick</dc:creator>
		<pubDate>Sun, 03 Aug 2008 08:46:22 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3487</guid>
		<description>In addition to what Joe H wrote: can anyone explain to me what the real advantage of anonymus methods over named ones? I would code the "adder" example as below (with a subroutine), which imho does the same job and is much clearer. I'm probably missing the point.

function VeryComplicateFunction(const x,y:integer):integer;
begin
  // hundreds LOC, but for simplicity like in the example:
  Result := x + y;
end;      // VeryComplicateFunction

//**************************************************************

procedure TFOO.DoTheTest;
var
  MyNumber : integer;

//--------------------------------------------------------------

{sub}function SimpleFunction(const Number:integer):integer
begin
  Result:=VeryComplicateFunction(MyNumber,Number);
end;      // SimpleFunction in DoTheTest

//--------------------------------------------------------------

begin
  MyNumber:=20;
  Writeln(SimpleFunction(22));  // writes 42
end;      // DoTheTest

//**************************************************************</description>
		<content:encoded><![CDATA[<p>In addition to what Joe H wrote: can anyone explain to me what the real advantage of anonymus methods over named ones? I would code the "adder" example as below (with a subroutine), which imho does the same job and is much clearer. I&#8217;m probably missing the point.</p>
<p>function VeryComplicateFunction(const x,y:integer):integer;<br />
begin<br />
  // hundreds LOC, but for simplicity like in the example:<br />
  Result := x + y;<br />
end;      // VeryComplicateFunction</p>
<p>//**************************************************************</p>
<p>procedure TFOO.DoTheTest;<br />
var<br />
  MyNumber : integer;</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>{sub}function SimpleFunction(const Number:integer):integer<br />
begin<br />
  Result:=VeryComplicateFunction(MyNumber,Number);<br />
end;      // SimpleFunction in DoTheTest</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>begin<br />
  MyNumber:=20;<br />
  Writeln(SimpleFunction(22));  // writes 42<br />
end;      // DoTheTest</p>
<p>//**************************************************************</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe White</title>
		<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3481</link>
		<dc:creator>Joe White</dc:creator>
		<pubDate>Thu, 31 Jul 2008 13:02:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3481</guid>
		<description>Wait. Does this mean we'll be able to make a variable of type "reference to TFoo" and have the compiler automatically refcount it and clean it up, without needing to declare an interface?

Or better yet, define "TFoo = reference to class..." and get the same automatic refcounting, with no need to FreeAndNil explicitly?

Our modus operandi is to declare an interface for every new class we create, just so we don't have to sweat the memory management. But I'd love to be able to do the same thing with less typing.</description>
		<content:encoded><![CDATA[<p>Wait. Does this mean we&#8217;ll be able to make a variable of type "reference to TFoo" and have the compiler automatically refcount it and clean it up, without needing to declare an interface?</p>
<p>Or better yet, define "TFoo = reference to class&#8230;" and get the same automatic refcounting, with no need to FreeAndNil explicitly?</p>
<p>Our modus operandi is to declare an interface for every new class we create, just so we don&#8217;t have to sweat the memory management. But I&#8217;d love to be able to do the same thing with less typing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreano Lanusse</title>
		<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3438</link>
		<dc:creator>Andreano Lanusse</dc:creator>
		<pubDate>Thu, 24 Jul 2008 02:40:48 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3438</guid>
		<description>Yes, won't be possible direct assignment to event handler</description>
		<content:encoded><![CDATA[<p>Yes, won&#8217;t be possible direct assignment to event handler</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Caleb</title>
		<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3435</link>
		<dc:creator>Caleb</dc:creator>
		<pubDate>Wed, 23 Jul 2008 07:48:48 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3435</guid>
		<description>"is to ensure that the event a method reference type."

I'm not sure what this means, but I get that direct assignment to event handler slots will not be possible.  A pity.</description>
		<content:encoded><![CDATA[<p>"is to ensure that the event a method reference type."</p>
<p>I&#8217;m not sure what this means, but I get that direct assignment to event handler slots will not be possible.  A pity.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreano Lanusse</title>
		<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3433</link>
		<dc:creator>Andreano Lanusse</dc:creator>
		<pubDate>Wed, 23 Jul 2008 01:43:10 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3433</guid>
		<description>Caleb, this is a very good question. Days ago we had some discussion about that with Barry Kelly our compiler guy, here his answer.

Method references are managed types, while events are method pointer-valued properties, and method pointers are unmanaged types. Thus, for type-safety reasons, assigning method references to method pointers is not supported.

The primary motivation behind using method references is to have a type that can contain a closure value. Since closures close over their defining environment, including any local variables reference at the point of definition, they have state that must be freed. Method references, being managed types (they are reference counted), can keep track of this state and free it when necessary.

If a method reference or closure could be freely assigned to a method pointer, such as an event, then ill-typed programs with dangling pointers or memory leaks would be very easy to create.

The easiest and best, but possibly not most convenient, way to assign a method reference or closure value to an event is to ensure that the event a method reference type.</description>
		<content:encoded><![CDATA[<p>Caleb, this is a very good question. Days ago we had some discussion about that with Barry Kelly our compiler guy, here his answer.</p>
<p>Method references are managed types, while events are method pointer-valued properties, and method pointers are unmanaged types. Thus, for type-safety reasons, assigning method references to method pointers is not supported.</p>
<p>The primary motivation behind using method references is to have a type that can contain a closure value. Since closures close over their defining environment, including any local variables reference at the point of definition, they have state that must be freed. Method references, being managed types (they are reference counted), can keep track of this state and free it when necessary.</p>
<p>If a method reference or closure could be freely assigned to a method pointer, such as an event, then ill-typed programs with dangling pointers or memory leaks would be very easy to create.</p>
<p>The easiest and best, but possibly not most convenient, way to assign a method reference or closure value to an event is to ensure that the event a method reference type.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Caleb</title>
		<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3432</link>
		<dc:creator>Caleb</dc:creator>
		<pubDate>Tue, 22 Jul 2008 22:15:09 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3432</guid>
		<description>If this works as described, then it means Delphi gets closures.  "Anonymous methods" is a really silly name for this feature, because that is an artifact of the implementation, not the underlying feature itself.   The real feature is the binding of local data inside method declarations.   This is big in functional programming:

http://en.wikipedia.org/wiki/Closure_(computer_science)

There is a good deal of discussion about it on the net, but it is mostly with languages such as lisp, python, ruby, javascript, C# and so on.  

It is a technique for solving some kinds of problems efficiently, just like OOP is a technique for solving some other kinds of problems efficiently.   

Andreano, in Tiburon can we assign closures to delphi events if the calling signature matches?  I expect this would be one of the more common uses.</description>
		<content:encoded><![CDATA[<p>If this works as described, then it means Delphi gets closures.  "Anonymous methods" is a really silly name for this feature, because that is an artifact of the implementation, not the underlying feature itself.   The real feature is the binding of local data inside method declarations.   This is big in functional programming:</p>
<p><a href="http://en.wikipedia.org/wiki/Closure_" rel="nofollow">http://en.wikipedia.org/wiki/Closure_</a>(computer_science)</p>
<p>There is a good deal of discussion about it on the net, but it is mostly with languages such as lisp, python, ruby, javascript, C# and so on.  </p>
<p>It is a technique for solving some kinds of problems efficiently, just like OOP is a technique for solving some other kinds of problems efficiently.   </p>
<p>Andreano, in Tiburon can we assign closures to delphi events if the calling signature matches?  I expect this would be one of the more common uses.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jolyon Smith</title>
		<link>http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3421</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Mon, 21 Jul 2008 02:49:01 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.codegear.com/andreanolanusse/2008/07/17/tiburon-anonymous-methods/#comment-3421</guid>
		<description>Echoing previous comments - what gives with the new "reference to" preamble?

Utterly unnecessary as far as I can see, and a potential source of confusion.  After all, why not:

var
   o: reference to TObject;

Just as redundant but at least consistent (with the new incantation).  Or does the use of "reference to" confer some special properties on these types that is not present in "regular" function/procedure pointer types?

It's the only explanation I can think of.


I also share similar concerns to those expressed w.r.t on-going maintenance of code that uses this stuff.

Really, apart from the binding to local variables, what does this really offer that existing function pointers do not already provide in an arguably much clearer (certainly more easily understood) fashion?

In C# (the aping of which is what ultimately lies behind this stuff) the need was clear, to avoid delegates and so streamline things.  Here, the "solution" is less streamlined than what we already had (and still have?)

As I understand things though, this was also needed in C# for the LINQ implementation (initially a huge piece of "WOW" functionality that is rapidly losing it's appeal - and traction - as pointy sticks get prodded at it).  Heck, even within Microsoft the great standard bearer for LINQ (LINQ for SQL) is looking a bit pathetic now that ADO Entities are here.

If I recall, the local variable binding stuff is (partly at least) the LINQ connection in this area.  And sure, it has real "cool - wow look at that value" when you look at trivial little demos.  Put this sort of stuff into even slightly more than non-trivial production code however, and the price will be paid in spades when some poor sap has to come speluncking through the code in months/years time and try to figure out how to fix some bug or other.


This is a BAD direction for Delphi to be going in, leading, as it does, right up to the door step of C#.


If Delphi is to become just a Pascal imitator of C#, I think most people are just going to say "to hell with it - let's just use C#.  It's Microsoft, and it's on the front edge of the language curve, as opposed to this CodeGear C# wannabe, which is way behind the curve and, well, isn't Microsoft.  So what if C# is potentially slower, it's so gosh-darn sexy.  Phwoarr!"


The great advantage that Delphi used to have was that it was just as powerful as C++ but a darn sight more pleasurable and productive to work with (on an on-going basis, rather than a "sexy toys to spew out code, and we'll worry about the maintenance issues when they arise" basis).


Ugly, inscrutable code is the order of the day in the C# camp, so new functionality that is also ugly and inscrutable at least fits comfortably in (especially when it cuts down on SOME of the existing ugliness and inscrutability).</description>
		<content:encoded><![CDATA[<p>Echoing previous comments - what gives with the new "reference to" preamble?</p>
<p>Utterly unnecessary as far as I can see, and a potential source of confusion.  After all, why not:</p>
<p>var<br />
   o: reference to TObject;</p>
<p>Just as redundant but at least consistent (with the new incantation).  Or does the use of "reference to" confer some special properties on these types that is not present in "regular" function/procedure pointer types?</p>
<p>It&#8217;s the only explanation I can think of.</p>
<p>I also share similar concerns to those expressed w.r.t on-going maintenance of code that uses this stuff.</p>
<p>Really, apart from the binding to local variables, what does this really offer that existing function pointers do not already provide in an arguably much clearer (certainly more easily understood) fashion?</p>
<p>In C# (the aping of which is what ultimately lies behind this stuff) the need was clear, to avoid delegates and so streamline things.  Here, the "solution" is less streamlined than what we already had (and still have?)</p>
<p>As I understand things though, this was also needed in C# for the LINQ implementation (initially a huge piece of "WOW" functionality that is rapidly losing it&#8217;s appeal - and traction - as pointy sticks get prodded at it).  Heck, even within Microsoft the great standard bearer for LINQ (LINQ for SQL) is looking a bit pathetic now that ADO Entities are here.</p>
<p>If I recall, the local variable binding stuff is (partly at least) the LINQ connection in this area.  And sure, it has real "cool - wow look at that value" when you look at trivial little demos.  Put this sort of stuff into even slightly more than non-trivial production code however, and the price will be paid in spades when some poor sap has to come speluncking through the code in months/years time and try to figure out how to fix some bug or other.</p>
<p>This is a BAD direction for Delphi to be going in, leading, as it does, right up to the door step of C#.</p>
<p>If Delphi is to become just a Pascal imitator of C#, I think most people are just going to say "to hell with it - let&#8217;s just use C#.  It&#8217;s Microsoft, and it&#8217;s on the front edge of the language curve, as opposed to this CodeGear C# wannabe, which is way behind the curve and, well, isn&#8217;t Microsoft.  So what if C# is potentially slower, it&#8217;s so gosh-darn sexy.  Phwoarr!"</p>
<p>The great advantage that Delphi used to have was that it was just as powerful as C++ but a darn sight more pleasurable and productive to work with (on an on-going basis, rather than a "sexy toys to spew out code, and we&#8217;ll worry about the maintenance issues when they arise" basis).</p>
<p>Ugly, inscrutable code is the order of the day in the C# camp, so new functionality that is also ugly and inscrutable at least fits comfortably in (especially when it cuts down on SOME of the existing ugliness and inscrutability).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
