<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Proposal for Automated Variables</title>
	<atom:link href="http://www.deltics.co.nz/blog/Index.php?feed=rss2&#038;p=412" rel="self" type="application/rss+xml" />
	<link>http://www.deltics.co.nz/blog/?p=412</link>
	<description>Keeping Delphi afloat in Aotearoa</description>
	<lastBuildDate>Fri, 03 Sep 2010 13:44:08 +1200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jolyon Smith</title>
		<link>http://www.deltics.co.nz/blog/?p=412&#038;cpage=1#comment-395</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Tue, 07 Oct 2008 18:55:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=412#comment-395</guid>
		<description>Hi Daniel.

Manual resource management is not a &quot;broken&quot; system.  It&#039;s just a different one.  One that can be more efficient than automatic garbage collection.

But I don&#039;t see how it would make any transition to a fully auto GC&#039;d Delphi more difficult.  Far from it.

With the &quot;automated&quot; keyword, an auto-GC&#039;d Delphi compiler would simply ignore the keyword.

WITHOUT the &quot;automated&quot; keyword the compiler would still be required to compile the explicit manual resource management code (indistinguishable to the compiler from any other compilable code), so the RTL would need to create facade support for certain operations that would be NO-OPs at runtime.

This was one of the *mistakes* (imho) that was made with Delphi.NET.


So if anything, an &quot;automated&quot; keyword would be a useful step toward GC.

Not-with-standing the fact that I believe that a GC in (native code) Delphi would be a mistake.

If you want to write with a GC, just use .NET.</description>
		<content:encoded><![CDATA[<p>Hi Daniel.</p>
<p>Manual resource management is not a &#8220;broken&#8221; system.  It&#8217;s just a different one.  One that can be more efficient than automatic garbage collection.</p>
<p>But I don&#8217;t see how it would make any transition to a fully auto GC&#8217;d Delphi more difficult.  Far from it.</p>
<p>With the &#8220;automated&#8221; keyword, an auto-GC&#8217;d Delphi compiler would simply ignore the keyword.</p>
<p>WITHOUT the &#8220;automated&#8221; keyword the compiler would still be required to compile the explicit manual resource management code (indistinguishable to the compiler from any other compilable code), so the RTL would need to create facade support for certain operations that would be NO-OPs at runtime.</p>
<p>This was one of the *mistakes* (imho) that was made with Delphi.NET.</p>
<p>So if anything, an &#8220;automated&#8221; keyword would be a useful step toward GC.</p>
<p>Not-with-standing the fact that I believe that a GC in (native code) Delphi would be a mistake.</p>
<p>If you want to write with a GC, just use .NET.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Lehmann</title>
		<link>http://www.deltics.co.nz/blog/?p=412&#038;cpage=1#comment-394</link>
		<dc:creator>Daniel Lehmann</dc:creator>
		<pubDate>Tue, 07 Oct 2008 12:37:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=412#comment-394</guid>
		<description>I don&#039;t like this feature THAT much. In my opinion it hides a broken system (the need for manual destruction) behind a new syntax and will make the transition to a GC&#039;ed native Delphi more difficult (and I hope that we one day get a GC&#039;ed native Delphi).</description>
		<content:encoded><![CDATA[<p>I don&#8217;t like this feature THAT much. In my opinion it hides a broken system (the need for manual destruction) behind a new syntax and will make the transition to a GC&#8217;ed native Delphi more difficult (and I hope that we one day get a GC&#8217;ed native Delphi).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geza</title>
		<link>http://www.deltics.co.nz/blog/?p=412&#038;cpage=1#comment-382</link>
		<dc:creator>Geza</dc:creator>
		<pubDate>Sat, 04 Oct 2008 06:05:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=412#comment-382</guid>
		<description>And an other one: ;-) I finish with this one...

procedure foo;
var
list : TList.Create &amp; finally free;
begin
[...]
end;</description>
		<content:encoded><![CDATA[<p>And an other one: <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  I finish with this one&#8230;</p>
<p>procedure foo;<br />
var<br />
list : TList.Create &amp; finally free;<br />
begin<br />
[...]<br />
end;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geza</title>
		<link>http://www.deltics.co.nz/blog/?p=412&#038;cpage=1#comment-381</link>
		<dc:creator>Geza</dc:creator>
		<pubDate>Sat, 04 Oct 2008 06:03:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=412#comment-381</guid>
		<description>Here is another variant:

procedure foo;
var
list : TList := TList.Create &amp; finally free;
begin
[...]
end;</description>
		<content:encoded><![CDATA[<p>Here is another variant:</p>
<p>procedure foo;<br />
var<br />
list : TList := TList.Create &amp; finally free;<br />
begin<br />
[...]<br />
end;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geza</title>
		<link>http://www.deltics.co.nz/blog/?p=412&#038;cpage=1#comment-378</link>
		<dc:creator>Geza</dc:creator>
		<pubDate>Fri, 03 Oct 2008 06:16:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=412#comment-378</guid>
		<description>And intermediate solution would be an optional finally keyword in blocks and variable assignments for definition:

procedure foo;
var
  list : TList := nil
begin
 [...]
finally
  list.free;
end;

or even better:

procedure foo;
var
  list : TList := TList.Create;
begin
 [...]
finally
  list.free
end;</description>
		<content:encoded><![CDATA[<p>And intermediate solution would be an optional finally keyword in blocks and variable assignments for definition:</p>
<p>procedure foo;<br />
var<br />
  list : TList := nil<br />
begin<br />
 [...]<br />
finally<br />
  list.free;<br />
end;</p>
<p>or even better:</p>
<p>procedure foo;<br />
var<br />
  list : TList := TList.Create;<br />
begin<br />
 [...]<br />
finally<br />
  list.free<br />
end;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jolyon Smith</title>
		<link>http://www.deltics.co.nz/blog/?p=412&#038;cpage=1#comment-377</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Thu, 02 Oct 2008 22:21:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=412#comment-377</guid>
		<description>@Serg: imho demonstrably *less* prone, when used correctly (see previous comments about incorrect use of try..finally, although presumably you don&#039;t use try..finally, since the same [and more] errors can occur with that as are possible with &quot;automated&quot;).

;)

But if you don&#039;t like it you don&#039;t have to vote for it, and even if it&#039;s implemented, you wouldn&#039;t have to use it.

:)</description>
		<content:encoded><![CDATA[<p>@Serg: imho demonstrably *less* prone, when used correctly (see previous comments about incorrect use of try..finally, although presumably you don&#8217;t use try..finally, since the same [and more] errors can occur with that as are possible with &#8220;automated&#8221;).</p>
<p> <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>But if you don&#8217;t like it you don&#8217;t have to vote for it, and even if it&#8217;s implemented, you wouldn&#8217;t have to use it.</p>
<p> <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jolyon Smith</title>
		<link>http://www.deltics.co.nz/blog/?p=412&#038;cpage=1#comment-376</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Thu, 02 Oct 2008 22:12:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=412#comment-376</guid>
		<description>Hi Nigel - well, in the meantime you might want to check out the post on AutoFree() (&quot;Free Yourself&quot;) that led me to this suggestion in the first place.

http://www.deltics.co.nz/blog/?p=391

:)</description>
		<content:encoded><![CDATA[<p>Hi Nigel &#8211; well, in the meantime you might want to check out the post on AutoFree() (&#8221;Free Yourself&#8221;) that led me to this suggestion in the first place.</p>
<p><a href="http://www.deltics.co.nz/blog/?p=391" rel="nofollow">http://www.deltics.co.nz/blog/?p=391</a></p>
<p> <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Serg</title>
		<link>http://www.deltics.co.nz/blog/?p=412&#038;cpage=1#comment-375</link>
		<dc:creator>Serg</dc:creator>
		<pubDate>Thu, 02 Oct 2008 22:09:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=412#comment-375</guid>
		<description>I don&#039;t like the idea at all. The feature proposed just makes your code more prone to errors.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t like the idea at all. The feature proposed just makes your code more prone to errors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nigel X</title>
		<link>http://www.deltics.co.nz/blog/?p=412&#038;cpage=1#comment-374</link>
		<dc:creator>Nigel X</dc:creator>
		<pubDate>Thu, 02 Oct 2008 21:48:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=412#comment-374</guid>
		<description>Like your suggestion, Jolyon,

In the meantime i&#039;d be happy enough for some common objects that automatically clean up after themselves, e.g. TSafeStringList, TSafeList, TSafeBitmap, etc.

TSafeStringList alone would save me about 5000 lines of code each day ;-)</description>
		<content:encoded><![CDATA[<p>Like your suggestion, Jolyon,</p>
<p>In the meantime i&#8217;d be happy enough for some common objects that automatically clean up after themselves, e.g. TSafeStringList, TSafeList, TSafeBitmap, etc.</p>
<p>TSafeStringList alone would save me about 5000 lines of code each day <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jolyon Smith</title>
		<link>http://www.deltics.co.nz/blog/?p=412&#038;cpage=1#comment-373</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Thu, 02 Oct 2008 20:40:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=412#comment-373</guid>
		<description>Hi Stevie - As regards an &quot;automated&quot; block type, rather than a variable decoration, I did consider that, but is creates a problem with the existing (albeit deprecated) use of the keyword as a block type in class declarations.

As regards your other point, there is no guess work.  The &quot;automated&quot; keyword is as explicit about the behaviour of that variable as &quot;absolute&quot; is, or &quot;abstract&quot; is for method declarations (or &quot;empty&quot; in Oxygene, for example).

You could achieve the same things by being more explicit (*) and then seeing the behaviour expressed in the code (or by seeing it NOT expressed, in the case of an empty/abstract method - :) ), but the declaration encapsulates it for you, allowing the code to be free of mundane housekeeping jobs.


(*) e.g. in the case of &quot;absolute&quot;:

procedure TSomeForm.OnControlEnter(Sender: TObject);
var
   listbox: TListbox absolute Sender;
   edit: TEdit absolute Sender;
   ...
begin
   if Sender is TListbox then
     listbox.Color := ...
   else if Sender is TEdit then
     edit.Color := ...
   ...
end;

vs

procedure TSomeForm.OnControlEnter(Sender: TObject);
var
   listbox: TListbox;
   edit: TEdit;
   ...
begin
   if Sender is TListbox then
   begin
     listbox := TListbox(Sender);
     listbox.Color := ...
   end
   else if Sender is TEdit then
   begin
     edit := TEdit(Sender);
     edit.Color := ...
   end
   ...
end;


i.e. with &quot;absolute&quot; you still have to exercise exactly the same cautions that you have to exercise when achieving the same thing &quot;the long way around&quot; - type checking etc - but as long as you are doing that, the actual implementation details you are protecting by exercising that caution are taken care of for you.

This isn&#039;t quite the same, as this &quot;long hand&quot; way is not directly comparable to, and is slightly less efficient than, the language supported capability.  The directly comparable &quot;long hand&quot; implementation would be even more error prone as it would involve using pointers which can easily trip up even the most cautious developer.

&quot;automated&quot; on the other hand is directly comparable to existing &quot;long hand&quot; techniques but it also protects the developer from incorrect use of those techniques.

e.g. I still quite often see try..finally being incorrectly used:

  try
    list := TList.Create;
    // ...
  finally
    list.Free;
  end;

The developer has understood what they need to do, but hasn&#039;t grasped the finer points of the runtime behaviour of exceptions and constructors and learned to apply that (or perhaps carelessly forgot in this one instance, which perhaps involve multipled temp objects, where the try..finally&#039;s can get messy).

Had they applied the same intention by marking &quot;list&quot; as automated, those details would have been take care of.



And all those 2 cents add up to a useful contribution in the end.

;)</description>
		<content:encoded><![CDATA[<p>Hi Stevie &#8211; As regards an &#8220;automated&#8221; block type, rather than a variable decoration, I did consider that, but is creates a problem with the existing (albeit deprecated) use of the keyword as a block type in class declarations.</p>
<p>As regards your other point, there is no guess work.  The &#8220;automated&#8221; keyword is as explicit about the behaviour of that variable as &#8220;absolute&#8221; is, or &#8220;abstract&#8221; is for method declarations (or &#8220;empty&#8221; in Oxygene, for example).</p>
<p>You could achieve the same things by being more explicit (*) and then seeing the behaviour expressed in the code (or by seeing it NOT expressed, in the case of an empty/abstract method &#8211; <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ), but the declaration encapsulates it for you, allowing the code to be free of mundane housekeeping jobs.</p>
<p>(*) e.g. in the case of &#8220;absolute&#8221;:</p>
<p>procedure TSomeForm.OnControlEnter(Sender: TObject);<br />
var<br />
   listbox: TListbox absolute Sender;<br />
   edit: TEdit absolute Sender;<br />
   &#8230;<br />
begin<br />
   if Sender is TListbox then<br />
     listbox.Color := &#8230;<br />
   else if Sender is TEdit then<br />
     edit.Color := &#8230;<br />
   &#8230;<br />
end;</p>
<p>vs</p>
<p>procedure TSomeForm.OnControlEnter(Sender: TObject);<br />
var<br />
   listbox: TListbox;<br />
   edit: TEdit;<br />
   &#8230;<br />
begin<br />
   if Sender is TListbox then<br />
   begin<br />
     listbox := TListbox(Sender);<br />
     listbox.Color := &#8230;<br />
   end<br />
   else if Sender is TEdit then<br />
   begin<br />
     edit := TEdit(Sender);<br />
     edit.Color := &#8230;<br />
   end<br />
   &#8230;<br />
end;</p>
<p>i.e. with &#8220;absolute&#8221; you still have to exercise exactly the same cautions that you have to exercise when achieving the same thing &#8220;the long way around&#8221; &#8211; type checking etc &#8211; but as long as you are doing that, the actual implementation details you are protecting by exercising that caution are taken care of for you.</p>
<p>This isn&#8217;t quite the same, as this &#8220;long hand&#8221; way is not directly comparable to, and is slightly less efficient than, the language supported capability.  The directly comparable &#8220;long hand&#8221; implementation would be even more error prone as it would involve using pointers which can easily trip up even the most cautious developer.</p>
<p>&#8220;automated&#8221; on the other hand is directly comparable to existing &#8220;long hand&#8221; techniques but it also protects the developer from incorrect use of those techniques.</p>
<p>e.g. I still quite often see try..finally being incorrectly used:</p>
<p>  try<br />
    list := TList.Create;<br />
    // &#8230;<br />
  finally<br />
    list.Free;<br />
  end;</p>
<p>The developer has understood what they need to do, but hasn&#8217;t grasped the finer points of the runtime behaviour of exceptions and constructors and learned to apply that (or perhaps carelessly forgot in this one instance, which perhaps involve multipled temp objects, where the try..finally&#8217;s can get messy).</p>
<p>Had they applied the same intention by marking &#8220;list&#8221; as automated, those details would have been take care of.</p>
<p>And all those 2 cents add up to a useful contribution in the end.</p>
<p> <img src='http://www.deltics.co.nz/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
