[fpc-devel] type discussion
chrivers at iversen-net.dk
Thu Jun 2 17:27:15 CEST 2005
> >>>Sorry, the only language that does what ?
> >>var strlist : TStringlist;
> >>strlist := Tstringlist.create;
> >>I know strlist is a Tstringlist, the compiler knows it too as I have
> >>declared it so why do I have to spell it out in the creation process?
> > In C++:
> > TStringList strlist;
> > strlist = new TStringList;
> > How is that shorter ?
> okay but its still redundant. Why does the compiler need to have it
> spelt out twice? Why cant the compiler deduce that as the pointer is
> declared as TStringlist therefore it creates a TStringList?
Because the pointer might not be. Polymorphism, you know? :-)
More information about the fpc-devel