[progress Communities] [progress Openedge Abl] Forum Post: Re: Cast Vs Dynamic-cast

Status
Not open for further replies.
M

Mike Fechner

Guest
But once it's referenced by a PLO you can CAST anything to anything - at least the compiler will let you. When the types are incompatible at runtime an runtime error will be thrown. And that is expected. This behavior is needed, for instance when referencing objects in a temp-table field of type PLO. The compiler will allow any CAST from a PLO reference and it's our responsibility that the types match. Which is absolutely o.k. So the question is really if the compiler check for CAST is too strict and a warning like suggested by Marian would be enough. I must admit in the majority of cases, when the compiler creates an error, he is right. So I can live with the fact that when I know better I do the CAST(CAST( )) thing. It's typically when the reference I hold to the original object is an Interface type, not a real class, that I need this.

Continue reading...
 
Status
Not open for further replies.
Top