Posts filed under 'software development'

What is a muxy?

I though it was about time that I posted a blog entry, but what was I going to blog about? Instead of blogging I should be working on muxy so I though that would be a good thing to describe.

Basicly muxy is a transport stream demultiplexor. That means you can use it for recording digital TV programs. You can actuall read more about it at MUXY the Muxer

Muxy forms part of the Digital ORB which will be a TV watching program like MythTV but without feature creep and targeted at Australian DTV.

Add comment October 5th, 2007

Automatic type conversion

I just added my 2c about Inner Classes to the WIKI but it got me thinking again about a feature I think is lacking in modern languages. Having slipped out of the top 10 blogs, I felt it was time to share my idea.

The feature is automatic type conversion. When you have some pseudo code like this:

class TMyChildClass inherits from TMyParentClass;
 
function DoSomeProcess(bar : TMyChildClass);
 
var
 foo : TMyParentClass;
begin
 foo := TMyChildClass.Create;
 DoSomeProcess(foo)

It does not work. The problem is that although foo is compatible, the compiler wants me to explicitly say so. The solution is to add an explicit type conversion like this

DoSomeProcess(TMyChildClass(foo));

But this becomes a problem if the conversion is not type checked until run time. If for example I had:

var
 p : Pointer;
begin
 DoSomeProcess(TMyChildClass(p));

I have valid code but I get a run time error because of the invalid type cast. So, the explicit type cast is for shutting up the compiler, not for making my code correct.

The compiler complains because it knows what type to expect, and given that it knows, I think it should be able to implicitly cast my parameter like this:

DoSomeProcess(foo);

and I get the same result. If the type is correct, it works and if not I get a run time error.

What about preventing programming bugs? Well I guess some kind of syntax is required to allow the automatic conversion. Each language would have to pick it’s own syntax but in delphi, it might be something like this:

DoSomeProcess(auto foo);

4 comments May 15th, 2006


Calendar

August 2008
S M T W T F S
« Nov    
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Posts by Month

Posts by Category