September 2008 - Posts

I was reading a newsgroup posting of someone reporting a problem with “Tinker” on Vista x64.  They said they got it via Windows Update.  Of course I had no idea what Tinker was, so I checked my Windows Update and there it was under Ultimate Extras. 

Those devils at Microsoft have released a real time snatcher of a game.  Be warned, you may like it !!  ;)

 

tinker

with no comments
Filed under:

So if OSLO and the new language for it named “D” are part of Visual Studio, that means we’d have VB, VC++, VC#, and now VD.  I wonder if Visual D and OSLO will still let you use Strongly Typed Datasets. 

OSLO: for VD with STDs

I can see marketing has been busy ;)

with no comments
Filed under: , ,

As I went to get the mail this morning, one of the kangaroos was laying down in the front paddock with her joey standing standing by her side.  And as I typed away on the keyboard, a little wren kept chasing her reflection in the window. She’s been doing that for weeks, but today she was joined by the brightly coloured male superb blue (yes I need to get the camera out later).  And as I was typing the finishing sentence on an email some five minutes ago, I looked up and through the window I saw a young wedge tail eagle…

I think they’re all telling me to come outside and play :)

with no comments
Filed under:

When Visual Studio 2008 SP1 was released it didn’t have the source code for the framework like the original version of 2008 had. Well now it has !!  Actually it was released almost two weeks ago.

with no comments
Filed under: , , , ,

Via Don Box’s blog, I found the preliminary code for a tuple at CodePlex. The tuple is a simple structure containing in this case two values: a double tuple.  It basically looks like this :

 

Structure Tuple(Of TFirst, TSecond)

 

   Public Property First() As TFirst

   Public Property Second() As TSecond

 

End Structure

 

I’ve omitted the details, such as the constructor or equality overloads and operators etc. 

So Tuple’s can be handy general purpose storage to pass around a couple of values.  Let’s say I write a Parse method such as :

 

   Function Parse(ByVal value As String) As Tuple(Of Int32, Boolean)

      Dim iVal As Int32

      Dim success = Int32.TryParse(value, iVal)

      Return New Tuple(Of Int32, Boolean)(iVal, success)

   End Function

 

That makes it a little easier for calling code to parse a string to an int32, but the problem they then face is the values are First and Second. For example:

 

      Dim tuple = Parse("1")

      Dim i? = If(tuple.Second, tuple.First, Nothing)

 

Wouldn’t it be nicer if that could be written as :

 

      Dim tuple = Parse("1")

      Dim i? = If(tuple.Success, tuple.Value, Nothing)

 

Sure you could write your own structure for this, but then we are back to type bloat.  That level of detail, Success and Value are only needed at design time, so they could be compiler magic based on XML comments.  Perhaps something like this on my Parse method would make the tuple parameters appear as Success and Value instead of First and Second :

 

   ''' <summary>

   ''' A Parse wrapper for string to integer

   ''' </summary>

   ''' <param name="value">a string representation of an integer value</param>

   ''' <returns>

   ''' <tuple>

   '''   <First name="Value">the integer value or 0 if the parse fails</First>

   '''   <Second name="Success">true if the parse succeeds, otherwise false</Second>

   ''' </tuple>

   ''' </returns>

   Function Parse(ByVal value As String) As Tuple(Of Int32, Boolean)

      Dim iVal As Int32

      Dim success = Int32.TryParse(value, iVal)

      Return New Tuple(Of Int32, Boolean)(iVal, success)

   End Function

 

The down side of this is it would only work with the immediate assignment, and one could argue only when it is used with type inference (as I did above).  I doubt the cost justifies the benefit, but imagine the fun you could have if it was a cooking tuple: you could have a double Tuple with Boil and Bubble

(I can’t believe I left that last line in here ;) )

with 4 comment(s)
Filed under: , ,