<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DelphiTools.info</title>
	<atom:link href="http://delphitools.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://delphitools.info</link>
	<description>SamplingProfiler and other Delphi tools</description>
	<lastBuildDate>Thu, 02 Sep 2010 15:12:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>SamplingProfiler v1.7.5</title>
		<link>http://delphitools.info/2010/09/02/samplingprofiler-v1-7-5/</link>
		<comments>http://delphitools.info/2010/09/02/samplingprofiler-v1-7-5/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 15:12:49 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Delphi XE]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=527</guid>
		<description><![CDATA[A new version has been released which adds support for the new Delphi XE paths, you can download it here. Note that there is still a pseudo-random issue of unknown origin under Windows 7, where the utility may or may not be able to gather profiling information. If that happens, close the application and launch [...]]]></description>
			<content:encoded><![CDATA[<p>A new version has been released which adds support for the new Delphi XE paths, you can download it <a href="http://delphitools.info/downloads/samplingprofiler-changelog/">here</a>.</p>
<p>Note that there is still a pseudo-random issue of unknown origin under Windows 7, where the utility may or may not be able to gather profiling information. If that happens, close the application and launch it again. The issue doesn&#8217;t happen with Windows OSes before 7.</p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/09/02/samplingprofiler-v1-7-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Things on the radar for DWS</title>
		<link>http://delphitools.info/2010/08/30/things-on-the-radar-for-dws/</link>
		<comments>http://delphitools.info/2010/08/30/things-on-the-radar-for-dws/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 06:22:01 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[DWS]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=515</guid>
		<description><![CDATA[Or a roadmap of sorts. The basic idea is to maintain forward compatibility for the &#8220;external&#8221; aspects: the language and the components. At the same time, the internals of DWS will be subject to evolution, incremental Darwinian evolution, rather than a straight break into some next-gen architecture. The main goals: Strong typing: this is a [...]]]></description>
			<content:encoded><![CDATA[<p>Or a roadmap of sorts. The basic idea is to maintain forward compatibility for the &#8220;external&#8221; aspects: the language and the components. At the same time, the internals of DWS will be subject to evolution, incremental <em><a href="http://en.wikipedia.org/wiki/Charles_Darwin">Darwinian</a></em> evolution, rather than a straight break into some next-gen architecture.</p>
<p><span style="text-decoration: underline;"><strong>The main goals:</strong></span></p>
<ul>
<li><strong>Strong typing</strong>: this is a long term goal of dropping &#8220;<em>Eval : Variant</em>&#8221; methods, and ultimately, the reliance on Variant. Variants will stay in the scripting language though, but may become optional (see below). Changes will be incremental, with new methods and classes popping into existence, some as temporary glue, and other bits of code will fade away. What this means is that you shouldn&#8217;t rely on the internals classes, their methods, or even their still being there down the road.</li>
<li><strong>Expression tree:</strong> this is an architectural goal of keeping the expression tree &#8220;understandable&#8221; and maintainable. Even though specialized classes may come to abound, higher level classes will be maintained to keep the expression tree easy to understand and maintain. This is to allow using the expression tree as a specialized DOM, facilitate debugging, refactoring, static analysis, etc.</li>
<li><strong>Custom primitive types</strong>: allow optional primitive types to be plugged into the compiler, I&#8217;m thinking primarily of Variant, date-time, vectors and matrices at this time. From a language point of view, this could also mean optionally allowing operator overloading.</li>
<li><strong>Generics/Templates:</strong> provide some mechanisms for genericity, at least on the Delphi side, so that you can f.i. have a &#8220;TList&lt;T&gt;&#8221; in the scripts, even if you may not be able to design a generic containers in script.</li>
<li><strong>Local JITter:</strong> introduce a framework to simplify JITting portions of a script. The initial aim would be for math computations involving floats, vectors &amp; matrices into SSE instructions. Complete JITting isn&#8217;t on the radar at this point, and probably shouldn&#8217;t be. This is unlikely to happen until a 64bit Delphi compiler is out.</li>
</ul>
<p>If you want to help on the DWS compiler &amp; runtime side, at this point the most needed things are unit tests. Can&#8217;t have too much of them <img src='http://delphitools.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p><strong><span style="text-decoration: underline;">Library, tools and utilities front:</span></strong></p>
<p>DWS2 came with a rather vast set of companion libraries, tools and utilities, covering many things from HTML web page generation to auto-completion support functions. At this point I will not focus on those, but on the core aspects mentioned above.</p>
<p>There are however a few RTL-like sets of libraries still to be released, TStringList, TStringBuilder, TXxxxList, file access, etc. all these providing extra optional functionality for the scripts.</p>
<p>If some of you want to help on that front, or need some of the treasures from the old DWS2 chest, they can go ahead and bring the old code up to Unicode Delphi, things should be compatible for the most part on the DWS side apart from a few name changes.</p>
<p><strong><span style="text-decoration: underline;">Documentation:</span></strong></p>
<p>A natural choice would be the google code wiki facility, but it&#8217;s very primitive to say the least. Another possibility is wikia, but I&#8217;ve no idea how easy it would be to export/backup a wikia wiki at this point, should wikia go the way of the Dodo. Another option would be a no-database, xcopy-installable, portable wiki like PmWiki. I&#8217;m still looking around, if you&#8217;ve suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/08/30/things-on-the-radar-for-dws/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>DWScript first bits now available</title>
		<link>http://delphitools.info/2010/08/24/dwscript-first-bits-now-available/</link>
		<comments>http://delphitools.info/2010/08/24/dwscript-first-bits-now-available/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 11:44:18 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[DWS]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=511</guid>
		<description><![CDATA[They are released in the SVN source repository on google code, at http://code.google.com/p/dwscript/ The core compiler and some internal libraries are there, along with a few unit tests, but no demos just yet. It&#8217;s compatible with Delphi 2009 (and 2010?) only at this point. Hopefully some demos will be added, ad interim, you&#8217;ll have to [...]]]></description>
			<content:encoded><![CDATA[<p>They are released in the SVN source repository on google code, at</p>
<p><a href="http://code.google.com/p/dwscript/">http://code.google.com/p/dwscript/</a></p>
<p>The core compiler and some internal libraries are there, along with a few unit tests, but no demos just yet. It&#8217;s compatible with Delphi 2009 (and 2010?) only at this point.</p>
<p>Hopefully some demos will be added, ad interim, you&#8217;ll have to look at the unit test source to see how to compile your own scripts. More modules should also come in the next weeks/months as their dependencies get cleaned up, and the dust of many years shaken away.</p>
<p>Here is a quick summary of the most significant changes since DWS2:</p>
<p><strong>What changed in the script language?</strong></p>
<ul>
<li>DateTime type was deprecated, in favor of plain old Float for timestamps.</li>
<li>Integer is now an Int64. For language simplicity, there is only one integer type, 64bit it is.</li>
<li>Strong typing is more strictly enforced throughout, this can cause issues in previous scripts that abused compiler bugs.</li>
<li>Support for &#8220;deprecated&#8221; warnings was added.</li>
<li>for loop variables can no longer be altered within the loop.</li>
</ul>
<p><strong>What changed internally?</strong></p>
<ul>
<li>Move to strong typing away from Variants, this is still a work in progress (and source of much speedups).</li>
<li>Handling of break/continue/exit no longer relies on exceptions (it&#8217;s now orders of magnitude faster).</li>
<li>Expression tree memory usage reduced significantly, this is also still a work in progress.</li>
<li>Tokenizer was re-architectured for higher parsing speed.</li>
<li>Naming prefix was simplified from &#8220;dws2&#8243; to just &#8220;dws&#8221;, though the code is based on DWS2.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/08/24/dwscript-first-bits-now-available/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Informal DelphiWebScript performance tests</title>
		<link>http://delphitools.info/2010/08/20/informal-delphiwebscript-performance-tests/</link>
		<comments>http://delphitools.info/2010/08/20/informal-delphiwebscript-performance-tests/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 07:50:52 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[DWS]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=508</guid>
		<description><![CDATA[I&#8217;ve made some informal performance tests on DWS vs PascalScript vs Delphi. The PascalScript version was downloaded yesterday, though when compiling, I got many warnings hinting its code hasn&#8217;t been fully upgraded to Unicode and D2009, so maybe it wasn&#8217;t the latest version? I&#8217;m not a user of PascalScript, so if anyone want to chime [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve made some informal performance tests on DWS vs PascalScript vs Delphi.</p>
<p>The PascalScript version was downloaded yesterday, though when compiling, I got many warnings hinting its code hasn&#8217;t been fully upgraded to Unicode and D2009, so maybe it wasn&#8217;t the latest version? I&#8217;m not a user of PascalScript, so if anyone want to chime in, feel free!</p>
<p>The script I used for testing was something like</p>
<pre>var s, i: Integer;
for i:=1 to 1000000 do s:=s+i;
</pre>
<p>with only minimal syntax adaptations to get it running and compiling in the various environments. For PascalScript, I tweaked the &#8220;sample1&#8243; project to run the script, so maybe there were some optimization options not active? If so, let me know!<br />
The result timings on my machine were (including compilation and execution, except for Delphi):</p>
<p>Delphi: &lt;1 msec (using 32bit integers), 1.5 msec (using 64bit integers)<br />
DWS2 revival: <span style="text-decoration: line-through;">150</span> 60 msec in D2009 (using 64bit integers)<br />
DWS2 vanilla: 420 msec in D7 (using 32bit integers)<br />
PascalScript: 1860 msec in D2009, 1490 msec in D7 (using 32bit integers)</p>
<p>Note that in DWS2 revival, integers are 64bit integers (more on that and other changes later).</p>
<p>I then redid the test using a double precision float for the &#8220;s&#8221; variable: Delphi goes up to 15 msec, DWS2 revival increases to <span style="text-decoration: line-through;">180</span> 95 ms (vs 670 ms for vanilla), PascalScript results were unchanged.</p>
<p>Last test consisted in moving the &#8220;s:=s+i&#8221; to a function, to measure the call overhead. Delphi laughed at me and stayed with roughly the same figures, PascalScript went up to 3000 msec, and DWS2 revival took a hit to 1000 msec. Function calls are indeed a DWS area with still some simplifications and optimizations potential <img src='http://delphitools.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>As for the re-release time-frame, I&#8217;m waiting to hear from the original maintainers, as well as removing a few dependencies to make it into a standalone library (currently the compiler itself is standalone, but the DWS library equivalents of system &amp; sysutils units aren&#8217;t).</p>
<p><em><strong>edit 2010-09-01:</strong> following a round of cleanup and optimizations, figures for DWS revival are now 60 and 95 msec for 64bit integers and floats respectively.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/08/20/informal-delphiwebscript-performance-tests/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>DelphiWebScript Revival</title>
		<link>http://delphitools.info/2010/08/19/delphiwebscript-revival/</link>
		<comments>http://delphitools.info/2010/08/19/delphiwebscript-revival/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 16:13:02 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[DWS]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=506</guid>
		<description><![CDATA[I&#8217;m planning a mini resurrection of former DelphiWebScript (by Matthias Ackermann) which has been dormant for a few years already. DWS is a 100% Delphi-based Delphi-language script engines, that supports a fairly large subset of the Delphi language (including objects), with a performance high enough for use in real-time scenarios (simulators, game engine scripting&#8230;). We&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m planning a mini resurrection of former <a href="https://sourceforge.net/projects/dws/">DelphiWebScript</a> (by Matthias Ackermann) which has been dormant for a few years already.</p>
<p>DWS is a 100% Delphi-based Delphi-language script engines, that  supports a fairly large subset of the Delphi language (including  objects), with a performance high enough for use in real-time scenarios  (simulators, game engine scripting&#8230;).</p>
<p>We&#8217;ve been making use of the library at work for years now, with it receiving updates covering a variety of things from Delphi compatibility, to language enhancements to speed or memory usage optimizations. On the other hand, the parts we didn&#8217;t use fell significantly behind (to the point of deprecation), and wouldn&#8217;t be part of the revival (unless some extra hands join in for the update).</p>
<p>However, most emails and websites from back then have gone the way of the <a href="http://en.wikipedia.org/wiki/Dodo">Dodo</a>, so this post is mostly a call to former DWS2 maintainers, contributors and users to make themselves known if they are interested&#8230; if they are still using DWS2 in some form or another, or if they are merely just still around to share memories of a bygone era <img src='http://delphitools.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/08/19/delphiwebscript-revival/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Website mobile update</title>
		<link>http://delphitools.info/2010/07/31/website-mobile-update/</link>
		<comments>http://delphitools.info/2010/07/31/website-mobile-update/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 12:18:13 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Site]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=503</guid>
		<description><![CDATA[DelphiTools.info has been mobile-enabled thanks to WPtouch, it should now serve a version more friendly to Android-based devices, iPhone &#38; others. The two Android apps hosted here have been updated with QR code links to the Android Market.]]></description>
			<content:encoded><![CDATA[<p>DelphiTools.info has been mobile-enabled thanks to <a href="http://bravenewcode.com/products/wptouch">WPtouch</a>, it should now serve a version more friendly to Android-based devices, iPhone &amp; others. The two <a href="http://delphitools.info/android/">Android apps</a> hosted here have been updated with <a href="http://en.wikipedia.org/wiki/QR_Code">QR code</a> links to the Android Market.</p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/07/31/website-mobile-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>All hail the &#8220;const&#8221; parameters!</title>
		<link>http://delphitools.info/2010/07/28/all-hail-the-const-parameters/</link>
		<comments>http://delphitools.info/2010/07/28/all-hail-the-const-parameters/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 06:16:44 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[const]]></category>
		<category><![CDATA[CPU]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Delphi Optimization]]></category>
		<category><![CDATA[Profiler]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=483</guid>
		<description><![CDATA[Passing parameters as &#8220;const&#8221; is a classic Delphi optimization trick, but the mechanisms behind that &#8220;trick&#8221; go beyond cargo-cult recipes, and may actually stumble into the &#8220;good practice&#8221; territory. Why does it work? The most well known case is &#8220;const String&#8220;, for which the compiler than takes advantage of the &#8220;const&#8221; to pass the String [...]]]></description>
			<content:encoded><![CDATA[<p>Passing parameters as &#8220;<em>const</em>&#8221; is a classic Delphi optimization trick, but the mechanisms behind that &#8220;trick&#8221; go beyond <a href="http://en.wikipedia.org/wiki/Cargo_cult_programming">cargo-cult</a> recipes, and may actually stumble into the &#8220;good practice&#8221; territory.</p>
<p><strong>Why does it work?</strong></p>
<p>The most well known case is &#8220;<em>const String</em>&#8220;, for which the compiler than takes advantage of the &#8220;<em>const</em>&#8221; to pass the <em>String</em> reference directly (as a pointer)&#8230; and without increasing the reference counter.</p>
<p>To illustrate what the reference counting implies, here are two screen-shots from the CPU disassembly view, taken in Delphi 6, but the recent compilers up to Delphi 2010 at least behave in a similar fashion (just with the Unicode version of the functions).<br />
I&#8217;ve made a pseudo-function, with only one <em>String </em>parameter that calls a single function (here <em>Length()</em>, which isn&#8217;t inlined in Delphi 6, and corresponds to <em>LStrLen</em>), guess which CPU disassembly corresponds to &#8220;<em>Test(const a : String)</em>&#8221; and which to &#8220;<em>Test(a : String)</em>&#8221;</p>
<table style="width: 100%;">
<tbody>
<tr>
<td width="50%" align="center"><a href="http://delphitools.info/wp-content/uploads/2010/07/refcount1.png"><a href="http://delphitools.info/wp-content/uploads/2010/07/refcount1.png"><img class="alignnone size-medium wp-image-484" title="refcount1" src="http://delphitools.info/wp-content/uploads/2010/07/refcount1-247x300.png" alt="" width="247" height="300" /></a></a></td>
<td width="50%" align="center" valign="top"><a href="http://delphitools.info/wp-content/uploads/2010/07/refcount2.png"><img class="alignnone size-full wp-image-485" title="refcount2" src="http://delphitools.info/wp-content/uploads/2010/07/refcount2.png" alt="" width="323" height="45" /></a></td>
</tr>
</tbody>
</table>
<p>What you&#8217;re seeing on the left is an implicit <em>try&#8230;finally</em> construct which is used to protect the reference counting (<em>LStrAddRef/LStrClr</em>) on the implicit local variable used to store the <em>String </em>parameter. If you have such calls nested a few levels deep (not uncommon in object-oriented code), you could accumulate quite some overhead.<br />
Also not see here but hidden within the <em>AddRef </em>and <em>Clr </em>calls are bus locks, which may hit you disproportionately in multi-threading scenarios.</p>
<p>And what if you&#8217;re modifying the passed <em>String</em>? Can you forego the &#8220;<em>const</em>&#8220;? Well no, the extra overhead is still there, and using a &#8220;<em>const</em>&#8221; still beneficial.</p>
<p><em>String </em>isn&#8217;t the only type affected, there are similar gains for all reference counted types (interfaces, dynamic arrays, records holding reference-counted types). And when passing a record as &#8220;<em>const</em>&#8220;, there is an additional gain in the lack of defensive copying of the record (the larger the record, the greater the gain).</p>
<p>For ordinal and numeric types, there is no compiler optimization (yet), but it can be good practice to mark them as &#8220;<em>const</em>&#8220;, not in the optimistic hope that someday the compiler will optimize it, but to ease up debugging and code writing. Copies of those parameters (when you want to modify them in the function body) are typically handled adequately by the compiler (and often enough comes for free), so don&#8217;t let performance considerations hold you.</p>
<p>There is one case in which using &#8220;<em>const</em>&#8221; could have adverse effects, but it involves global variables which you would modify or release during the call&#8230; so you don&#8217;t really need to know more about it, do you? <img src='http://delphitools.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>How does it manifests itself in Profiling?</strong></p>
<p>A missing &#8220;<em>const</em>&#8221; can manifests itself in different ways during profiling, for <em>String</em>, <em>Interface </em>and dynamic array types, you&#8217;ll usually see it via the relevant <em>xxxAddRef </em>or <em>xxxClr </em>functions (the obvious case) and via time spent in <em>begin/end</em> (the less obvious case). Depending on how many functions calls with the reference counting are involved in your inner loop, none of the above may come ahead, even if calls and reference counting are an issue: the time spent will be spread over the above functions and your various <em>begin/end</em> sections.<br />
For record parameters, the lack of &#8220;<em>const</em>&#8221; could materialize itself in &#8220;<em>Move</em>&#8220;, or other data copying costs (large records will be moved, smaller ones can be copied via ad-hoc in-place code by the compiler).</p>
<p>In multi-threading, things can be a little less obvious, as rather than the reference counting and exception frame, it could be the bus locks hitting you, or sometimes worse, inter-CPU traffic to pass around the values of the reference counter.</p>
<p>Multi-threading&#8217;s worst case would be referring to the same string field from multiple threads, and passing that string around in functions without &#8220;<em>const</em>&#8221; parameters, thus repeatedly hitting the reference counter of that string from multiple threads at the same time, resulting in extra inter-CPUs traffic to share the value of that reference counter.</p>
<p>In such cases, &#8220;<em>const</em>&#8221; can help, but it will often not be enough, you&#8217;ll also have to look for functions/methods that return strings with an unnecessary reference counting, like when getting your strings from a <em>TStringList</em>.</p>
<p><strong>Good Practice</strong><br class="spacer_" /></p>
<p>Usually I tend to &#8220;<em>const</em>&#8221; just about every parameter that isn&#8217;t &#8220;<em>var</em>&#8221; or an object, this isn&#8217;t just  to pre-emptively alleviate possible performance issues, but also to gain something valuable when debugging and writing a function&#8217;s body: untouched input parameters, wherever you are in the function&#8217;s body. This means not just in the function&#8217;s body, but also when in the functions called by the function.</p>
<p>And that&#8217;s the key point to remember about &#8220;<em>const</em>&#8221; parameter: it&#8217;s here to state that a parameter will be left unchanged inside the body, something which allows the compiler to optimize it&#8217;s output, and the developer to optimize his thought process too. Qualifying all your parameters as either &#8220;<em>const</em>&#8221; or &#8220;<em>var</em>&#8221; makes your intentions obvious.</p>
<p>So IME, it&#8217;s not worth it to hoard your keystrokes, best spend them on &#8220;<em>const</em>&#8221; and explicit local variables when you really need to alter those input parameters.<br />
Whoever has to maintain your code will be thankful.</p>
<p><strong>Object parameters</strong></p>
<p>There is one case I&#8217;ve not mentioned in all the above, the case of object parameters (and class references). It&#8217;s a special case because when you pass an object as &#8220;<em>const</em>&#8220;, you&#8217;re not making any promises of not keeping the object constant, but just keeping the underlying variable (pointer) constant. This is unlike other languages. There is also a risk of confusion when your code will be read by developers not really familiar with the underlying pointer-based mechanics of objects (and they are more common than you may think, even, and maybe more so in highly OO languages).</p>
<p>So for objects, unless you want to spend a lot of time educating, my rule of thumb is to avoid &#8220;<em>const</em>&#8221; or &#8220;<em>var</em>&#8221; for object parameters.</p>
<p><strong>Beyond &#8220;const&#8221; parameters</strong></p>
<p>Const&#8217;ing your parameters will eliminate some defensive copying, implicit <em>try&#8230;finally</em>, and reference counting overhead, but it leaves open another field of similar inefficiencies: that of return values.</p>
<p>Alas there is no &#8220;<em>const Result</em>&#8221; syntax, which would allow to state that your result can&#8217;t be altered in any way (a sort of strict immutability if you will). Thus whenever you have a function returning a <em>String </em>f.i., you&#8217;ll end up triggering the implicit reference counting and exception machinery if you&#8217;re not careful (like in <a href="http://delphitools.info/2009/05/06/code-optimization-go-for-the-jugular/">this case</a>)&#8230;</p>
<p>There are strategies to tackle this issue, but none of them are as simple as adding a &#8220;<em>const</em>&#8220;, and most of them come with sacrifices&#8230; so, let them be food for other articles.</p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/07/28/all-hail-the-const-parameters/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Aim foot, shoot!</title>
		<link>http://delphitools.info/2010/07/24/aim-foot-shoot/</link>
		<comments>http://delphitools.info/2010/07/24/aim-foot-shoot/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 15:54:45 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=467</guid>
		<description><![CDATA[Hot on the heels of Nick Hodges being suddenly &#8220;let go&#8220;, Borcodero guys engaged in a bout of pathetic self-deprecating PR disaster. Apparently along with Nick, more than a Spirit of Delphi award winner may have left Embarcadero.]]></description>
			<content:encoded><![CDATA[<p>Hot on the heels of <a href="http://www.nickhodges.com/">Nick Hodges</a> being suddenly &#8220;<a href="http://www.deltics.co.nz/blog/?p=636">let go</a>&#8220;, Borcodero guys engaged in a bout of <a href="http://delphihaven.wordpress.com/2010/07/21/pathetic/">pathetic</a> self-deprecating <a href="http://www.deltics.co.nz/blog/?p=640">PR disaster</a>.</p>
<p>Apparently along with Nick, more than a <a href="http://blogs.embarcadero.com/abauer/2004/09/14/1334">Spirit of Delphi</a> award winner may have left Embarcadero.</p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/07/24/aim-foot-shoot/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>glInfo for Android</title>
		<link>http://delphitools.info/2010/06/10/glinfo-for-android/</link>
		<comments>http://delphitools.info/2010/06/10/glinfo-for-android/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 12:17:09 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[glInfo]]></category>
		<category><![CDATA[GLScene]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=443</guid>
		<description><![CDATA[Just published glInfo in the Android Market, this is a simple utility that provides information on the OpenGL ES driver of the device it&#8217;s running on (version, supported extensions, limits&#8230;) and allows to copy or mail the whole report. Its purpose is to facilitate gathering device OpenGL ES support information, when the device you&#8217;re targeting [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://delphitools.info/wp-content/uploads/2010/06/screen.png"><img class="alignright size-thumbnail wp-image-445" style="margin-left: 10px; margin-right: 10px; border: 0pt none;" title="glInfo screenshot" src="http://delphitools.info/wp-content/uploads/2010/06/screen-100x150.png" alt="" width="100" height="150" /></a>Just published <em><strong>glInfo</strong></em> in the Android Market, this is a simple utility that provides information on the OpenGL ES driver of the device it&#8217;s running on (version, supported extensions, limits&#8230;) and allows to copy or mail the whole report.</p>
<p>Its purpose is to facilitate gathering device OpenGL ES support information, when the device you&#8217;re targeting or have issues with is in the hands of a non-developer&#8230; or in the hands of a lazy developer <img src='http://delphitools.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>It is named after from the glInfo utility that used to be hosted at Tom Nuydens&#8217;s Delphi3d site.</p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/06/10/glinfo-for-android/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>GLScene status</title>
		<link>http://delphitools.info/2010/06/07/glscene-status/</link>
		<comments>http://delphitools.info/2010/06/07/glscene-status/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 12:53:35 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[GLScene]]></category>
		<category><![CDATA[Site]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=441</guid>
		<description><![CDATA[I&#8217;ve updated the GLScene.org main page with information on where you can find support newsgroups and forums, since the nntp newsgroup went down and are unlikely to come back up (thanks Paul Van Dinther, now from PlanetInAction, for the help in accessing the wiki). The old site has been resurrected there too, as the wiki [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated the <a href="http://glscene.org/">GLScene.org</a> main page with information on where you can find support newsgroups and forums, since the nntp newsgroup went down and are unlikely to come back up (thanks Paul Van Dinther, now from <a href="http://www.planetinaction.com/index.htm">PlanetInAction</a>, for the help in accessing the wiki).</p>
<p>The old site has been resurrected there too, as the wiki engine lost most of the images added during the last years&#8230; I&#8217;ll be looking into setting up something to replace both with a more functional content manager.</p>
<p>The reason behind this dust being shaken is that I&#8217;ll likely be initiating a GLScene for Android project (for Java / Dalvik).</p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/06/07/glscene-status/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
