﻿<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
<title>yoy.be Why-O-Why</title>
<link>http://yoy.be/werk.html</link>
<description>yoy.be &quot;Why-O-Why&quot; - werk</description><item>
<link>http://yoy.be/d64lvi.html</link>
<title>Delphi 64-bits: set your local variables!</title>
<description>
&lt;p&gt;I'm relatively new to programming for the 64-bits platform, and I ran into the same thing twice now, so I feel I need to write about this. This last time, it even first showed up as an exception that occurred with the release build only, not the debug build! But it showed up consistently, so it was something I could investigate. I found out the specific exception only occurred&amp;nbsp;with the 'Optimization' compiler switch enabled. Apparently 'modern' Delphi has the 'Optimization' switch set to off in default 'Debug' configurations, and on in default 'Release&quot; configurations.&lt;/p&gt;<br />
&lt;p&gt;'Modern' Delphi apparently also has 'Use debug DCUs' on for both 'Debug' &lt;em&gt;and&lt;/em&gt; 'Release', which I very much regret. Most especially because when I introduce newlings to the Delphi debugger, we invariably drop into a core .pas-file,&amp;nbsp;either causing confusion, or the need for an explanation of what that is and why you'd better never make changes there. Or also what's the relation to the program you're building on one side, and the resulting compiled&amp;nbsp;binary code on the other side. Any way breaking away from working with the debugger for the remainder of the lesson.&lt;/p&gt;<br />
&lt;p&gt;What I want to warn about is that apparently the 64-bit compiler no longer provides the internal scaffolding to clear the memory of the local variables in procedures and functions. It also doesn't warn that you're using an unintialized value &lt;em&gt;(1)&lt;/em&gt;. In my case I've seen bugs appear just by switching from 32-bits to 64-bits, so be careful to always have an assignment to local variables before using them. Even if it's integers to zero and booleans to false. (Strings on the other hand, because of them being a pointer-type by nature, are zeroed for you.)&lt;/p&gt;<br />
&lt;p style=&quot;padding-left: 30px;&quot;&gt;&lt;em&gt;(1)&amp;nbsp;&lt;/em&gt;The compiler&amp;nbsp;does warn about you &lt;em&gt;not&lt;/em&gt; using a value set to a local variable. And there's also a difference there between 32-bits and 64-bits compiling there. If you have a superfluous assignment to set a default value at the beginning, and the following code also sets a value in all branches of &lt;em&gt;if&lt;/em&gt;s and &lt;em&gt;case&lt;/em&gt;s, I've found that the 32-bits compiler warns less about the unused assignment than the 64-bits compiler does. Perhaps because it's silently de-duplicating the assignments it's doing behind the scenes anyway? It's a minor inconvenience, but one I can live with, and one that reminds me to check if all local values get an initial value by my code.&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/coding.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_coding.gif&quot; class=&quot;c&quot; alt=&quot;coding&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/computers.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_computers.gif&quot; class=&quot;c&quot; alt=&quot;computers&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/dagboek.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_dagboek.gif&quot; class=&quot;c&quot; alt=&quot;dagboek&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/delphi.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_delphi.gif&quot; class=&quot;c&quot; alt=&quot;delphi&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/werk.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_werk.gif&quot; class=&quot;c&quot; alt=&quot;werk&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
<guid isPermaLink="true">http://yoy.be/d64lvi.html</guid>
<pubDate>Sat, 14 Feb 2026 09:43:29 GMT</pubDate>
</item><item>
<link>http://yoy.be/randomdelphi.html</link>
<title>205B random strings and no 'Delphi'</title>
<description>
&lt;p&gt;&amp;rarr;&amp;nbsp;&lt;a href=&quot;https://en.delphipraxis.net/topic/4573-can-delphi-randomize-string-delphi/&quot;&gt;Delphi-PRAXiS: Can Delphi randomize string 'Delphi'?&lt;/a&gt;&lt;/p&gt;<br />
&lt;p&gt;Ah, that takes me back. A&amp;nbsp;while ago at work I got someone baffled by this statement: It is said that a &lt;a href=&quot;https://en.wikipedia.org/wiki/Infinite_monkey_theorem&quot;&gt;thousand monkeys&lt;/a&gt; banging away on keyboards could at some moment&amp;nbsp;&lt;em&gt;in infinite time&lt;/em&gt; produce the complete work of Shakespeare (and that the combined internet forums are a living counter-proof). Now if you search online you can find an XML download of the combined works of Shakespeare, so it's not hard to find the relative occurance of each letter of the alphabet. One can guess this will have rougly the same values per letter as the total of the English language. So, then, if you take &lt;em&gt;'random'&lt;/em&gt; by its definition, and the monkey's produce text at 1/26 probability for each letter in the alphabet,&amp;nbsp;&lt;em&gt;therefore&lt;/em&gt; they'll &lt;em&gt;never&lt;/em&gt; reach a point in time where they (re)produce the works Shakespeare.&lt;/p&gt;<br />
&lt;p&gt;Now, I'm not a real philosopher, or a statistician, so my thesis could be complete fiction and based on nothing, but sometimes you really got to take a lesson from practice. In theory,&amp;nbsp;&lt;em&gt;in infinite time,&amp;nbsp;&lt;/em&gt;it's ofcourse&amp;nbsp;&lt;em&gt;possible&lt;/em&gt; that something really really inherently possible could emerge out of a random system, but there are characteristigs to anything random, and there are exponential things at play that soon but experimantal set-ups like with the link above, that they&amp;nbsp;&lt;em&gt;probably&lt;/em&gt; would produce the expected outcome in a time-span that exceeds the number of years we've got left before the sun sheds its outer layers and devours the earth, complete with a set of silicon-based machines churning away at putting a series of random characters in sequence and comparing them of some neat stories of a long gone English playwright.&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/coding.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_coding.gif&quot; class=&quot;c&quot; alt=&quot;coding&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/computers.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_computers.gif&quot; class=&quot;c&quot; alt=&quot;computers&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/delphi.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_delphi.gif&quot; class=&quot;c&quot; alt=&quot;delphi&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/werk.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_werk.gif&quot; class=&quot;c&quot; alt=&quot;werk&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
<guid isPermaLink="true">http://yoy.be/randomdelphi.html</guid>
<pubDate>Sun, 28 Feb 2021 17:48:19 GMT</pubDate>
</item><item>
<link>http://yoy.be/dontraisee.html</link>
<title>Good to know: don't do except on e:Exception do ... raise e;</title>
<description>
&lt;p&gt;Good to know. At work, I inherited a smaller project. It started firing access violation errors reading from 00000000 (that tells you there's a &lt;em&gt;nil&lt;/em&gt; pointer involved somewhere)&amp;nbsp;at some address that didn't put me somewhere in the source code when I did Search &amp;gt; Find address in the IDE...&lt;/p&gt;<br />
&lt;p&gt;I was lucky I got the program running in a debugger when this happens, and the root cause was something&amp;nbsp;completely different. (An SQL unique index constraint&amp;nbsp;violation if you're really interested.) I got that fixed soon enough, but that didn't explain where the access violation comes from.&lt;/p&gt;<br />
&lt;p&gt;I followed the exception with the debugger, and before the exception was handled by anything&amp;nbsp;that outputs like a logger or an error display, sure enough an access violation happend, but the debugger didn't show me anywhere else in the source code than it was already debugging, strange.&lt;/p&gt;<br />
&lt;p&gt;It took me a long hard look at the code before I spotted it, but with some luck you'll be able to spot what's wrong faster. The original author had the strange habit of writing exception handlers like this:&lt;/p&gt;<br />
&lt;pre&gt;try&lt;br /&gt;  //important stuff here&lt;br /&gt;except&lt;br /&gt;  on e:Exception do&lt;br /&gt;    begin&lt;br /&gt;      //stuff to do in case of an exception here, (e.g. transaction rollback)&lt;br /&gt;      raise e;&lt;br /&gt;    end;&lt;br /&gt;end;&lt;/pre&gt;<br />
&lt;p&gt;And they were all over the place. Nothing bad about that per s&amp;eacute;, with raising the exception again, you can centralise the actual exception handling on the 'highest level' where all the calls are made. But&amp;nbsp;while you're able to raise a specific exception&amp;nbsp;&lt;em&gt;if you create a new one*,&amp;nbsp;&lt;/em&gt;apparently there's a difference between &lt;code&gt;raise e;&lt;/code&gt; and &lt;code&gt;raise;&lt;/code&gt; at least in this Delphi version I was on. Delphi handles the destruction of exception objects for you, and apparently that throws something off and causes the nil access violation somewhere deep inside...&lt;/p&gt;<br />
&lt;p&gt;*: Fun fact: Did you know that the Delphi&amp;nbsp;runtime system creates an EOutOfMemory exception instance at the start of your programs, just to have it ready when it actually runs out of memory anytime later? Forgot where I read about that though...&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/delphi.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_delphi.gif&quot; class=&quot;c&quot; alt=&quot;delphi&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/werk.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_werk.gif&quot; class=&quot;c&quot; alt=&quot;werk&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
<guid isPermaLink="true">http://yoy.be/dontraisee.html</guid>
<pubDate>Mon, 28 Dec 2020 12:29:47 GMT</pubDate>
</item><item>
<link>http://yoy.be/invoicetemplates.html</link>
<title>QuickReports: R.I.P. Lut</title>
<description>
&lt;p&gt;&amp;rarr;&amp;nbsp;&lt;a href=&quot;https://stackoverflow.com/questions/65348138/quickreport-on-delphi-sydney-10-4-1&quot;&gt;https://stackoverflow.com/questions/65348138/quickreport-on-delphi-sydney-10-4-1&lt;/a&gt;&lt;/p&gt;<br />
&lt;p&gt;Oh my, I didn't know. I guess we'll see this more and more with one-person open-source projects, that people stop with the project for all kinds of reasons.&lt;/p&gt;<br />
&lt;p&gt;But about reports, I've made this really elegant thing at work to script the design of a report with just a few basic commands (line, text, image, matrix, block, repeat...) that allows you to&amp;nbsp;&lt;em&gt;write&lt;/em&gt; what the report should look like, and make lots of small alterations later. If you really need your reports just right, I've always found a graphical designer to introduce minor artefacts that&amp;nbsp;you sometimes need to work around...&lt;/p&gt;<br />
&lt;p&gt;I know there are tons of similar things out there, like TeX and PostScript, and even HTML or MetaFiles, but it was grown out of neccessity and suffered&amp;nbsp;&lt;em&gt;&quot;dogfooding&quot;&lt;/em&gt; from the very start, which shows in its design and execution. And thanks to &lt;a href=&quot;https://github.com/synopse/SynPDF&quot;&gt;SynPDF&lt;/a&gt;, (or &quot;&lt;a href=&quot;https://answers.microsoft.com/en-us/windows/forum/windows_10-hardware/how-to-add-or-reinstall-the-microsoft-pdf-printer/70377c34-e50a-42be-b9f3-92345d6e25df&quot;&gt;Print to PDF&lt;/a&gt;&quot; for that matter) you can just exports PDF's with it as well. So I really should take some time and re-do it on my own time and open source it... If I can make it even better and cleaner, I might introduce the open-source version as a replacement at work! (... &lt;a href=&quot;https://en.wikipedia.org/wiki/Second-system_effect&quot;&gt;Oh-oh!&lt;/a&gt;) (... or was it &lt;a href=&quot;https://en.wikipedia.org/wiki/Second_product_syndrome&quot;&gt;this one&lt;/a&gt;?)&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/coding.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_coding.gif&quot; class=&quot;c&quot; alt=&quot;coding&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/delphi.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_delphi.gif&quot; class=&quot;c&quot; alt=&quot;delphi&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/werk.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_werk.gif&quot; class=&quot;c&quot; alt=&quot;werk&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/freeware.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_freeware.gif&quot; class=&quot;c&quot; alt=&quot;freeware&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
<guid isPermaLink="true">http://yoy.be/invoicetemplates.html</guid>
<pubDate>Fri, 18 Dec 2020 15:26:56 GMT</pubDate>
</item><item>
<link>http://yoy.be/ggggrgviz.html</link>
<title>Carefull with Gogole Sheet CSV export</title>
<description>
&lt;p&gt;Ready for another story from the trenches? So image a Google Sheet made by someone else, with all kinds of dat in about 30 columns, of about a few thousand rows. Yes, it's a stretch to keep using Sheets for that, but this data will serve for&amp;nbsp;the analysis for a decent application to manage this with... That probably won't be my team handling that project, but I had to do a quick cross reference of this data with the data in the database of one our current projects. The best way to do cross-checks is get the sheet into a table in the database to run queries. I guess you should be able to import a CSV pretty easily, right? I searched around and found this:&lt;/p&gt;<br />
&lt;p&gt;&lt;code&gt;https://docs.google.com/spreadsheets/d/{key}/gviz/tq?tqx=out:csv&amp;amp;sheet={sheet_name}&lt;/code&gt;&lt;/p&gt;<br />
&lt;p&gt;Which I thought would provide the data in just the way ready for me to import. Wrong. The second column just happened to have codes for all of the items that are numeric for the first few hundreds of items, and then alphanumeric codes. At first I thought the CSV importer was fouling up, but I hadn't looked at the CSV data itself. Turns out this CSV exporter checks the first few lines (or perhaps even only the first one!), guesses the column is numeric, and then just exports an empty value for all non-numeric values in that column!&lt;/p&gt;<br />
&lt;p&gt;The code in that column was only in a number of cases needed to uniquely identify the items, so I first was looking for a reason why my cross-match was throwing duplicates in all of the wrong places. Ofcourse. Weep one tear for the time lost, then move on. Take&amp;nbsp;solace in the wisdom&amp;nbsp;gained.&lt;/p&gt;<br />
&lt;p&gt;I solved it by using the CSV from the Export menu. I only needed it once so I didn't get a URL for that.&amp;nbsp;&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/coding.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_coding.gif&quot; class=&quot;c&quot; alt=&quot;coding&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/computers.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_computers.gif&quot; class=&quot;c&quot; alt=&quot;computers&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/dagboek.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_dagboek.gif&quot; class=&quot;c&quot; alt=&quot;dagboek&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/internet.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_internet.gif&quot; class=&quot;c&quot; alt=&quot;internet&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/werk.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_werk.gif&quot; class=&quot;c&quot; alt=&quot;werk&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
<guid isPermaLink="true">http://yoy.be/ggggrgviz.html</guid>
<pubDate>Fri, 26 Jun 2020 13:18:29 GMT</pubDate>
</item><item>
<link>http://yoy.be/nottx.html</link>
<title>Microsoft Teams was down?</title>
<description>
&lt;p&gt;&amp;rarr;&amp;nbsp;&lt;a href=&quot;https://www.theverge.com/2020/3/16/21181300/microsoft-teams-down-outage-europe-remote-working-coronavirus&quot;&gt;Microsoft Teams goes down just as Europe logs on to work remotely &amp;mdash; Verge&lt;/a&gt;&lt;/p&gt;<br />
&lt;p&gt;&lt;a href=&quot;https://github.com/stijnsanders/tx#tx&quot;&gt;Tx&lt;/a&gt; wasn't down, especially the instance you host yourself.&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/actueel.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_actueel.gif&quot; class=&quot;c&quot; alt=&quot;actueel&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/coding.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_coding.gif&quot; class=&quot;c&quot; alt=&quot;coding&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/computers.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_computers.gif&quot; class=&quot;c&quot; alt=&quot;computers&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/dagboek.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_dagboek.gif&quot; class=&quot;c&quot; alt=&quot;dagboek&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/delphi.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_delphi.gif&quot; class=&quot;c&quot; alt=&quot;delphi&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/werk.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_werk.gif&quot; class=&quot;c&quot; alt=&quot;werk&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/freeware.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_freeware.gif&quot; class=&quot;c&quot; alt=&quot;freeware&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
<guid isPermaLink="true">http://yoy.be/nottx.html</guid>
<pubDate>Mon, 16 Mar 2020 19:29:20 GMT</pubDate>
</item><item>
<link>http://yoy.be/delphiday2019.html</link>
<title>I'll be there: Delphi Day 2019 - Brussels 9 May</title>
<description>
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://www.eventbrite.nl/e/delphi-day-2019-tickets-58441488064&quot;&gt;May 9: Delphi Day 2019&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;<br />
&lt;p&gt;I'll be there.&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/actueel.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_actueel.gif&quot; class=&quot;c&quot; alt=&quot;actueel&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/delphi.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_delphi.gif&quot; class=&quot;c&quot; alt=&quot;delphi&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/werk.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_werk.gif&quot; class=&quot;c&quot; alt=&quot;werk&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
<guid isPermaLink="true">http://yoy.be/delphiday2019.html</guid>
<pubDate>Tue, 23 Apr 2019 10:39:30 GMT</pubDate>
</item><item>
<link>http://yoy.be/nocostvar.html</link>
<title>Local variables don't cost nothing!</title>
<description>
&lt;p&gt;O my god. I can't believe I have to keep explaining this. To a years-long colleague with some more years on the counter than me, the other day. He repeated a function call with the same arguments a few times in a few adjacent lines of code, with a guarantee in place that this will result the same value every time.&lt;/p&gt;<br />
&lt;p&gt;I asked him why. It couldn't be to have less typing: the extra &lt;code&gt;var a:integer;&lt;/code&gt; would replace far much more code it took for the repeated function calls. It couldn't be performance: even if the function would just be getting a value from a memory location, the call and return, building a stack frame and tearing it down it again, would end up in a multiple of the instructions the processor needs to work through.&lt;/p&gt;<br />
&lt;p&gt;I don't know who launched the idea the compiler &lt;em&gt;should&lt;/em&gt; be smart enough to pick things like this out &amp;mdash; what I read about Rust and other modern languages, I know research is actively looking at things like that &amp;mdash; but as we currently have it, our good old trusted compiler doesn't. What is &lt;em&gt;does&lt;/em&gt; do, and typically really well if we work a little with it, is mapping local variables onto the available registers of the CPU. In the best case no memory whatsoever is allocated for local variables.&lt;/p&gt;<br />
&lt;p&gt;Even if in theory some local variables get a temporary address on the stack, modern CPU's have multiple levels of cache so that the values don't even reach your DRAM silicon before you're function call completes. We're supposed to keep all functions and methods as short as possible, but even if we don't, the compiler knows if a local variable is only used for a short section of the code. So in some cases it's even better to have an extra local variable instead of re-using a local variable somewhere up front and then later near the end of a larger block, and still not pay with any performance of memory consumption...&lt;/p&gt;<br />
&lt;p&gt;So when in doubt, take an extra local var. It's what they're there for. It helps the compiler do better analysis. It helps you, now and later. All I need to do now is name them a little better. I know I have the nasty habit of things like &lt;code&gt;var a,b,c,d,e,f,g:integer;&lt;/code&gt; but I think I'm improving... Slowly...&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/coding.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_coding.gif&quot; class=&quot;c&quot; alt=&quot;coding&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/computers.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_computers.gif&quot; class=&quot;c&quot; alt=&quot;computers&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/delphi.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_delphi.gif&quot; class=&quot;c&quot; alt=&quot;delphi&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/werk.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_werk.gif&quot; class=&quot;c&quot; alt=&quot;werk&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
<guid isPermaLink="true">http://yoy.be/nocostvar.html</guid>
<pubDate>Fri, 8 Mar 2019 21:45:59 GMT</pubDate>
</item><item>
<link>http://yoy.be/updatefrom.html</link>
<title>PostgreSQL: update set from (join)*</title>
<description>
&lt;p&gt;In &lt;a href=&quot;https://www.microsoft.com/en-us/sql-server/&quot;&gt;SQLServer&lt;/a&gt; schreef ik wel eens een query van de vorm:&lt;/p&gt;<br />
&lt;pre&gt;&lt;strong&gt;update&lt;/strong&gt; MyTable &lt;strong&gt;set&lt;/strong&gt; Field1='Value1',Field2=3&lt;br /&gt;&lt;strong&gt;from&lt;/strong&gt; MyTable T1&lt;br /&gt;&lt;strong&gt;inner&lt;/strong&gt; &lt;strong&gt;join&lt;/strong&gt; SomeOtherTable T2 &lt;strong&gt;on&lt;/strong&gt; T2.Field3=T1.Field3&lt;br /&gt;--eventueel nog joins&lt;br /&gt;&lt;strong&gt;where&lt;/strong&gt; T1.Field1='Value0'&lt;/pre&gt;<br />
&lt;p&gt;Maar dan probeer je hetzelfde te doen in &lt;a href=&quot;https://stackoverflow.com/questions/19270259/update-with-join-in-sqlite&quot;&gt;SQLite: noppes&lt;/a&gt;&lt;/p&gt;<br />
&lt;p&gt;Of in &lt;a href=&quot;https://www.postgresql.org/&quot;&gt;PostgreSQL&lt;/a&gt;, daar blijkt het wel te bestaan &lt;strong&gt;maar&lt;/strong&gt;&amp;nbsp;hij plakt de referentie naar de tabel van de update niet aan het gebruik van de tabel in je from of join. Omdat je zo dan eigenlijk geen velden van de tabel in de where hebt staan, doet hij de update op&amp;nbsp;&lt;strong&gt;alle records, ongeacht je selectie.&lt;/strong&gt; Maar dat is gemakkelijk op te lossen natuurlijk:&lt;/p&gt;<br />
&lt;pre&gt;&lt;strong&gt;update&lt;/strong&gt; MyTable &lt;strong&gt;set&lt;/strong&gt; Field1='Value1',Field2=3&lt;br /&gt;&lt;strong&gt;from&lt;/strong&gt; MyTable T1&lt;br /&gt;&lt;strong&gt;inner&lt;/strong&gt; &lt;strong&gt;join&lt;/strong&gt; SomeOtherTable T2 &lt;strong&gt;on&lt;/strong&gt; T2.Field3=T1.Field3&lt;br /&gt;&lt;span style=&quot;background-color: gold;&quot;&gt;&lt;strong&gt;where&lt;/strong&gt; MyTable.MyPrimaryKeyField=T1.MyPrimaryKeyField&lt;/span&gt; --in de veronderstelling dat dit je primary key veld is natuurlijk&lt;br /&gt;&lt;strong&gt;and&lt;/strong&gt; T1.Field1='Value0'&lt;/pre&gt;<br />
&lt;p&gt;Maar daar moet je dus wel zelf aan denken, lastig als je het anders gewoon was...&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/coding.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_coding.gif&quot; class=&quot;c&quot; alt=&quot;coding&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/werk.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_werk.gif&quot; class=&quot;c&quot; alt=&quot;werk&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
<guid isPermaLink="true">http://yoy.be/updatefrom.html</guid>
<pubDate>Tue, 5 Mar 2019 14:56:04 GMT</pubDate>
</item><item>
<link>http://yoy.be/rasphone.html</link>
<title>VPN problemen? rasphone</title>
<description>
&lt;p&gt;Dit is er eentje om te onthouden. Ik had problemen met de VPN connectie naar het werk. Het is te zeggen, het werkte vlot en naar behoren op mijn vorige laptop. Ik koop me na &lt;em&gt;x&lt;/em&gt; jaren eens een nieuwe laptop, neem de instellingen over, noppes. Waarom precies is me niet duidelijk aan de error. In de event log vind ik &lt;em&gt;RasSstp&lt;/em&gt; die zegt dat het &lt;em&gt;of&lt;/em&gt; een timeout &lt;em&gt;of&lt;/em&gt; een certificaat-probleem is. Dus was ik al de certificate (stores! wist ik veel of het de computer of service of persoonlijke store is)&amp;nbsp; aan het uitpluizen voor een eventueel verschil. Ik had zelfs al &lt;code&gt;netsh ras set tracing * enabled&lt;/code&gt; gevonden maar daar vond ik helemaal niets in terug... En dan kom ik plots toevallig langs deze (lap, vergeten de URL van waar ik het zag bij te houden):&lt;/p&gt;<br />
&lt;pre&gt;C:\Users\&lt;em&gt;%USERNAME%&lt;/em&gt;\AppData\Roaming\Microsoft\Network\Connections\Pbk\rasphone.pbk&lt;/pre&gt;<br />
&lt;p&gt;Blijkt daar niet alleen precies inderdaad een cruciaal verschilletje te zitten in &amp;eacute;&amp;eacute;n van de honderden parametertjes daar, blijkt ook dat je gewoon extra files in die folder kan zetten en ze verschijnen auto-magisch in het netwerk-menu onder het icoon op de taakbalk. En voila, probleem geflikskts.&lt;br clear=&quot;all&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/computers.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_computers.gif&quot; class=&quot;c&quot; alt=&quot;computers&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/dagboek.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_dagboek.gif&quot; class=&quot;c&quot; alt=&quot;dagboek&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/internet.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_internet.gif&quot; class=&quot;c&quot; alt=&quot;internet&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://yoy.be/werk.html&quot;&gt;&lt;img src=&quot;http://yoy.be/cat/cat_werk.gif&quot; class=&quot;c&quot; alt=&quot;werk&quot; width=&quot;50&quot; height=&quot;13&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
<guid isPermaLink="true">http://yoy.be/rasphone.html</guid>
<pubDate>Sun, 3 Feb 2019 20:51:05 GMT</pubDate>
</item></channel></rss>