>If your file is opened, then comparing it to an empty string is what will 
>cause an invalid data type error.


>WHY!!!

>If the datatypes don't match, then the result of the comparison is 
>FALSE, not INVALID.

>It is logically correct to do such a comparison. The result I am looking 
>for is the logically correct response. It SHOULD NOT crash the program!

>And it worked fine on INFORMATION, why not UV?

It is a bad idea to allow it, it encourages bad programming practices and it 
can hide a bug in your program for example if you do:

READ CAR FROM CARS ELSE CAR = ''
IF CARS #  ''  THEN

Here what was intended was to compare CAR to ''  not CARS but having the S 
there is a typo.
If we don't allow datatypes of different types being compared this bug has a 
greater chance of getting caught during development because the program will 
fail on comparing the file to a null string.

If you use FILEINFO it shows that you know that the variable you are testing is 
a file.

I've seen a similar case where a subroutine was expecting:

SUBROUTINE  ABC (MAT A, MAT B, MAT C)

A programmer only needed the contents of the matrix B and C to call it and did:

CALL ABC("",MAT B, MAT C)

Only thing Matrix ABC puts something in MAT A and since the programmer passed 
an empty string what happens is that the content of Matrix B is over-written 
causing data corruption.

It would probably have been a good idea to detect that since a Matrix was 
expected, it shouldn't be legal to pass a dynamic array to the subroutine.  

Most modern OOP programming languages don't allow for types of different kinds 
to be compared to one another without some way of casting them.  


      
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to