[Oberon] ANY type cast
Thomas Frey
thomas.frey at alumni.ethz.ch
Tue Apr 12 11:13:13 CEST 2005
> I didn't found any documentation about ANY type, but it's easy to
> understand it is another PTR. The only difference I've seen is that only
> PACO compiler recognize it.
> The question is: if it cast any POINTER and OBJECT why didn't cast
> PONITER TO ARRAY OF CHAR? Or better, why only one direction? If we have:
> VAR data: ANY; str: Utilities.String;
> the assignment
> data := str;
> is ok for the compiler, but the condition:
> data IS Utilities.String , or the cast data(Utilities.String)
> , or WITH data: Utilities.String DO
> are not.
> How can I recuperate the value pointed by data, witch in this case is
> a string?
ANY is an alias for PTR. It only works for OBJECT instances. A better
keyword would be OBJECT but it is already taken by the OBJECT keyword
for OBJECT-CLASS. To allow casting data(Utilities.String) the type guard
code generated by the compiler would need to be changed.
--Thomas
More information about the Oberon
mailing list