Posted on Wednesday, November 28, 2007 at 6:25 AM
So I wanted to do:
private TTo Identity<TFrom,TTo>(TFrom I)
{
return (TTo)I;
}
Well, actually I didn't. I wanted C# to be smart enough to realize that if S is a subtype of T then List<S> can safely be assumed to be a subtype of List<T>. But anyway, that's not the case, and you have to call ConvertAll on the List to get it to be a List<T> rather than a List<S>. Joy. Anyway, turns out the above fails to compile. Thankfully, this works:
private TTo Identity<TFrom,TTo>(TFrom I)
{
return (TTo)(object)I;
}
But, argh.
Comments:
0
Tags:
C#,
types
Posted on Wednesday, November 21, 2007 at 6:01 AM
I answered a question on the Perl forum today about splitting CSV. CSV is a comma separated format; for example:
blah,blah,blah
You can put values in quotes:
blah,"blah blah",blah
And those quotes make commas within them meaningless too:
blah,"blah,blah,blah",blah
If we do the naive thing and implement it using split on a comma:
my @fields = split(/,/, $string);
Then we will obviously get the Wrong Answer. The question was, is there a regex we can use with split that will do the Right Thing? And the answer was yes, though it took me a few minutes to come up with it. The thing is that we don't want to match anything more than the commas we are splitting on, but we do need to do some analysis on the string that is up ahead (or behind us) to detect if the comma we are seeing is in quotes...
Posted on Monday, November 19, 2007 at 10:40 AM
I've spent the last few days at the French Perl Workshop. As well as my brand new talk, I gave two re-runs of two that I had given before. One was entirely new to the French audience, and the other one was from quite a while back and given a face lift so it seemed new (in fact, it was the first talk I ever gave to the Perl community; it was on the topic of web security, and from the web code I encounter it is no less relevant today than it was then). That was 100 minutes worth of talks, which was a pleasure thanks to a great audience...
Comments:
0
Tags:
Perl,
conferences
Posted on Monday, November 12, 2007 at 5:04 AM
I'm now working as lead developer at Programmer's Heaven. Every so often, I'll be bringing you a little look inside, sharing some of the tools and techniques that we use to build and run the site.
Last week I completed migrating the Programmer's Heaven source tree to the
Subversion version control system. Before I arrived, we were using a commercial offering, which I won't name here. I tried to give it plenty of chances to work well, and was patient when I heard a new version was coming out. However, the new version introduced new problems more than resolving the old ones, and I could never track down a pattern to the most serious issue, which led to broken builds a couple of times. It was frustrating knowing there were better tools out there; I had worked with Subversion on numerous projects before and knew that it was simple and Just Worked most of the time. It has its quirks, but nothing as close to annoying as what we were using...