<?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: Absolute (for) Beginners</title>
	<atom:link href="http://www.deltics.co.nz/blog/Index.php?feed=rss2&#038;p=586" rel="self" type="application/rss+xml" />
	<link>http://www.deltics.co.nz/blog/?p=586</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: The Anti-Case campaign &#171; Wings of Wind Software</title>
		<link>http://www.deltics.co.nz/blog/?p=586&#038;cpage=1#comment-8544</link>
		<dc:creator>The Anti-Case campaign &#171; Wings of Wind Software</dc:creator>
		<pubDate>Fri, 06 Nov 2009 10:48:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=586#comment-8544</guid>
		<description>[...] idea struck when, having my previous experience with Class Signatures, I saw Jolyon&#8217;s post about using of absolute keyword. The first reaction was &#8220;Hey, my solution is better than this [...]</description>
		<content:encoded><![CDATA[<p>[...] idea struck when, having my previous experience with Class Signatures, I saw Jolyon&#8217;s post about using of absolute keyword. The first reaction was &#8220;Hey, my solution is better than this [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kryvich</title>
		<link>http://www.deltics.co.nz/blog/?p=586&#038;cpage=1#comment-8512</link>
		<dc:creator>Kryvich</dc:creator>
		<pubDate>Mon, 19 Oct 2009 15:52:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=586#comment-8512</guid>
		<description>It&#039;s not about parameters, but it&#039;s about the register optimization inside a code block.

Some people think it&#039;s a Greatest Delphi article ever written:
https://forums.codegear.com/thread.jspa?threadID=15794

So I would trust it.</description>
		<content:encoded><![CDATA[<p>It&#8217;s not about parameters, but it&#8217;s about the register optimization inside a code block.</p>
<p>Some people think it&#8217;s a Greatest Delphi article ever written:<br />
<a href="https://forums.codegear.com/thread.jspa?threadID=15794" rel="nofollow">https://forums.codegear.com/thread.jspa?threadID=15794</a></p>
<p>So I would trust it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jolyon Smith</title>
		<link>http://www.deltics.co.nz/blog/?p=586&#038;cpage=1#comment-8505</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Sun, 18 Oct 2009 19:46:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=586#comment-8505</guid>
		<description>@Kryvich: An interesting link and a lot of the info there makes sense.

I&#039;m not so sure about some though - the comments about try/finally adding overhead for example... I thought I&#039;d read somewhere/somewhen else that try/finally or try/except *doesn&#039;t* add any overhead unless an exception is actually thrown.

It&#039;s also not entirely clear whether the author means that &quot;absolute&quot; affects parameters or local variables - he refers to variables but his example shows a parameter.  I don&#039;t think he can mean variables because afaik variables are *always* declared on the stack and if he means parameters then I&#039;d be interested to do some further investigation.  Perhaps my understanding of calling conventions is incomplete, but in respect of event handlers in particular I&#039;m curious as to how one handler can be using a register for a parameter that another handler for the same event expects on the stack.

Generally I&#039;d be careful about taking too much of that article as &quot;gospel&quot; without confirming any relevant observations in your own test harnesses - it was written almost 6 years ago after all.</description>
		<content:encoded><![CDATA[<p>@Kryvich: An interesting link and a lot of the info there makes sense.</p>
<p>I&#8217;m not so sure about some though &#8211; the comments about try/finally adding overhead for example&#8230; I thought I&#8217;d read somewhere/somewhen else that try/finally or try/except *doesn&#8217;t* add any overhead unless an exception is actually thrown.</p>
<p>It&#8217;s also not entirely clear whether the author means that &#8220;absolute&#8221; affects parameters or local variables &#8211; he refers to variables but his example shows a parameter.  I don&#8217;t think he can mean variables because afaik variables are *always* declared on the stack and if he means parameters then I&#8217;d be interested to do some further investigation.  Perhaps my understanding of calling conventions is incomplete, but in respect of event handlers in particular I&#8217;m curious as to how one handler can be using a register for a parameter that another handler for the same event expects on the stack.</p>
<p>Generally I&#8217;d be careful about taking too much of that article as &#8220;gospel&#8221; without confirming any relevant observations in your own test harnesses &#8211; it was written almost 6 years ago after all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kryvich</title>
		<link>http://www.deltics.co.nz/blog/?p=586&#038;cpage=1#comment-8498</link>
		<dc:creator>Kryvich</dc:creator>
		<pubDate>Sun, 18 Oct 2009 11:52:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=586#comment-8498</guid>
		<description>I read about the Absolute keyword that it can break an optimization of your code...

Yes, it is: 

A technique sometimes used to avoid typecasting is to &quot;overlay&quot; a variable with another of a different type by using the absolute keyword. However, this prevents the variable from becoming a &quot;fast&quot; register variable. It is better to type-cast and save the original variable into a new variable. 

http://effovex.com/OptimalCode/general.htm</description>
		<content:encoded><![CDATA[<p>I read about the Absolute keyword that it can break an optimization of your code&#8230;</p>
<p>Yes, it is: </p>
<p>A technique sometimes used to avoid typecasting is to &#8220;overlay&#8221; a variable with another of a different type by using the absolute keyword. However, this prevents the variable from becoming a &#8220;fast&#8221; register variable. It is better to type-cast and save the original variable into a new variable. </p>
<p><a href="http://effovex.com/OptimalCode/general.htm" rel="nofollow">http://effovex.com/OptimalCode/general.htm</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken Knopfli</title>
		<link>http://www.deltics.co.nz/blog/?p=586&#038;cpage=1#comment-8486</link>
		<dc:creator>Ken Knopfli</dc:creator>
		<pubDate>Fri, 16 Oct 2009 08:43:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=586#comment-8486</guid>
		<description>@Xepol: Thanks!
&quot;that is ABSOLUTELY the way many of us did it in the day&quot;

I remember doing it like this:

var StringLength: byte;
StringLength := MyString[0];

I think the compatible type char=byte meant no casting was necessary by the time BP7 arrived. Older Turbo Pascals were much stricter, hence the &quot;absolute&quot; technique, but it was an anachronism in BP7.</description>
		<content:encoded><![CDATA[<p>@Xepol: Thanks!<br />
&#8220;that is ABSOLUTELY the way many of us did it in the day&#8221;</p>
<p>I remember doing it like this:</p>
<p>var StringLength: byte;<br />
StringLength := MyString[0];</p>
<p>I think the compatible type char=byte meant no casting was necessary by the time BP7 arrived. Older Turbo Pascals were much stricter, hence the &#8220;absolute&#8221; technique, but it was an anachronism in BP7.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Turbo Pascal Fan</title>
		<link>http://www.deltics.co.nz/blog/?p=586&#038;cpage=1#comment-8485</link>
		<dc:creator>Turbo Pascal Fan</dc:creator>
		<pubDate>Fri, 16 Oct 2009 05:53:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=586#comment-8485</guid>
		<description>The potential for making complex things simple and clear is much bigger than the potential for making mistakes. It is always the choice of the programmer which technique he will use, so if he is confident that using absolute is the most elegant way to achieve something then this is obviously not the potential for making mistakes.</description>
		<content:encoded><![CDATA[<p>The potential for making complex things simple and clear is much bigger than the potential for making mistakes. It is always the choice of the programmer which technique he will use, so if he is confident that using absolute is the most elegant way to achieve something then this is obviously not the potential for making mistakes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Under the hood of an anonymous method &#171; TURBU Tech</title>
		<link>http://www.deltics.co.nz/blog/?p=586&#038;cpage=1#comment-8484</link>
		<dc:creator>Under the hood of an anonymous method &#171; TURBU Tech</dc:creator>
		<pubDate>Fri, 16 Oct 2009 05:22:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=586#comment-8484</guid>
		<description>[...]  [...]</description>
		<content:encoded><![CDATA[<p>[...]  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gerry</title>
		<link>http://www.deltics.co.nz/blog/?p=586&#038;cpage=1#comment-8479</link>
		<dc:creator>Gerry</dc:creator>
		<pubDate>Fri, 16 Oct 2009 01:19:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=586#comment-8479</guid>
		<description>I also use absolute for many of these cases, mainly in sort compare functions as mentioned by Xepol, and sometimes with for..in.

Unfortunately I work with a programmer who uses the for..in method, but calls the pointer p (and sometimes p1, p2 etc) - it&#039;s amazing how hard a bad naming convention can make code to read!</description>
		<content:encoded><![CDATA[<p>I also use absolute for many of these cases, mainly in sort compare functions as mentioned by Xepol, and sometimes with for..in.</p>
<p>Unfortunately I work with a programmer who uses the for..in method, but calls the pointer p (and sometimes p1, p2 etc) &#8211; it&#8217;s amazing how hard a bad naming convention can make code to read!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xepol</title>
		<link>http://www.deltics.co.nz/blog/?p=586&#038;cpage=1#comment-8477</link>
		<dc:creator>Xepol</dc:creator>
		<pubDate>Thu, 15 Oct 2009 21:28:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=586#comment-8477</guid>
		<description>@Ken -&gt; You are just telling the compiler to use the same address on the stack to represent different variable types.  Since, in the case of TEdit, TMemo etc, all that exists on the stack is a pointer, you are effectively telling the compiler to use the pointer at that location as if it was a pointer to TEdit, TMemo etc.  It&#039;s a type of type cast.

In the case of 
Str: string[32]:
StrLen: byte absolute Str;

that is ABSOLUTELY the way many of us did it in the day.  Short strings were limited to 255 characters because the zero&#039;th position of the string was a byte that contained its length.   It was quicker to just access the 0th element of the string than call the Length function.  IN those days, it mattered, particularilly when you did a LOT of string handling.

Yes, Delphi 2&#039;s ANsiString caused a degree of migration pain for those of us who did this a lot.  It wasn&#039;t the correct way, and we payed for it when things changed.  Fortunately, it was impossible to compile the old code in the new string style so you HAD to fix it (which was a relatively painless and predictable fix) before your code could run - made the outcome very predictable.

Interesting note, this use of the ABSOLUTE keyword is also not the intended use but rather actually allowed you to tell the compiler the absolute location in memory for a variable.

In the old DOS days, this was very VERY handy - the most common use I saw was to overlay a char array onto the video buffer (text and graphics).

Since Windows came along, it has been pretty much restricted to the stack thing.</description>
		<content:encoded><![CDATA[<p>@Ken -&gt; You are just telling the compiler to use the same address on the stack to represent different variable types.  Since, in the case of TEdit, TMemo etc, all that exists on the stack is a pointer, you are effectively telling the compiler to use the pointer at that location as if it was a pointer to TEdit, TMemo etc.  It&#8217;s a type of type cast.</p>
<p>In the case of<br />
Str: string[32]:<br />
StrLen: byte absolute Str;</p>
<p>that is ABSOLUTELY the way many of us did it in the day.  Short strings were limited to 255 characters because the zero&#8217;th position of the string was a byte that contained its length.   It was quicker to just access the 0th element of the string than call the Length function.  IN those days, it mattered, particularilly when you did a LOT of string handling.</p>
<p>Yes, Delphi 2&#8217;s ANsiString caused a degree of migration pain for those of us who did this a lot.  It wasn&#8217;t the correct way, and we payed for it when things changed.  Fortunately, it was impossible to compile the old code in the new string style so you HAD to fix it (which was a relatively painless and predictable fix) before your code could run &#8211; made the outcome very predictable.</p>
<p>Interesting note, this use of the ABSOLUTE keyword is also not the intended use but rather actually allowed you to tell the compiler the absolute location in memory for a variable.</p>
<p>In the old DOS days, this was very VERY handy &#8211; the most common use I saw was to overlay a char array onto the video buffer (text and graphics).</p>
<p>Since Windows came along, it has been pretty much restricted to the stack thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken Knopfli</title>
		<link>http://www.deltics.co.nz/blog/?p=586&#038;cpage=1#comment-8475</link>
		<dc:creator>Ken Knopfli</dc:creator>
		<pubDate>Thu, 15 Oct 2009 16:15:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.deltics.co.nz/blog/?p=586#comment-8475</guid>
		<description>...OK, now I get it. In your Schizo types example, a variant type of HiWord and LoWord overlaid on a Pointer type would be a good example of using both absolute and a variant type. 

In fact, I recall having done something similar to this to do endian conversion (way back when).</description>
		<content:encoded><![CDATA[<p>&#8230;OK, now I get it. In your Schizo types example, a variant type of HiWord and LoWord overlaid on a Pointer type would be a good example of using both absolute and a variant type. </p>
<p>In fact, I recall having done something similar to this to do endian conversion (way back when).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
