Delphi Pipe

 blog, Delphi, Delphi Pipe  Comments Off on Delphi Pipe
Mar 282015

Since Delphi Feeds doesn’t list my blog any more and generally isn’t very fast in responding to requests for adding or removing feeds, I have created my own aggregated feed: RSS-02Delphi Pipe. It’s done with Yahoo Pipes and currently contains the following feeds in no particular order (*1):

[wp-rss-aggregator limit=”100″]

Many of these are also on Delphi Feeds and there are probably many interesting feeds that are still missing. If you want to add a feed, please contact me via my Gooogle+ profile or post a comment to the announcement on Google+. I promise to do my best to maintain the pipe, but that doesn’t mean that I will respond immediately.

You can see the current content of the pipe to the right.

I have also created a static page and subdomain for it:

(*1: Meaning that I have yet to be able to create a meaningful sort order for the rss feed listing the sources.)

 Posted by on 2015-03-28 at 12:59

When const doesn’t mean const

 Delphi  Comments Off on When const doesn’t mean const
Mar 202015

Consider this code:

procedure SplitAt(const _Input: string; _Position: integer; out _Head, _Tail: string);
  _Head := Copy(_Input, 1, _Position-1);
  _Tail := Copy(_Input, _Position);

It’s meant to split a given string into two parts at the given position.

Nothing fancy, really, isn’t it?

Now, consider this call to the procedure above:

  s1: string;
  s2: string;
  s1 := 'hello world';
  SplitAt(s1, 5, s1, s2);
  WriteLn('s1: "', s1, '"');
  WriteLn('s2: "', s2, '"');

Which output do you expect?

The output I got certainly wasn’t what I expected:

s1: ""
s2: ""

I took me a while to understand what happened:

It has been brought to my attention, that the following explanation is wrong:

The compiler passes the parameters right to left, so the first parameter it passes is s2, then s1, then 5 and last s1 again as the input. Since the two rightmost parameters are *out* parameters it clears them before passing them, so s1 is already an empty string when it gets passed as input.

What actually happens is that regardless of the order in which the parameters are passed clearing of the out parameters happens. This clears s1 and it doesn’t matter whether it was already passed as Input or not since strings in Delphi are always passed as pointers.

Not quite what I would have expected. It doesn’t help to remove the const modifier either.

 Posted by on 2015-03-20 at 15:55