AW: [fpc-pascal]how to assign a value to an untyped variable

Michael Van Canneyt michael.vancanneyt at wisa.be
Fri Jul 11 15:27:09 CEST 2003


On Fri, 11 Jul 2003, ZINTEL Gerhard wrote:

> >
> > Hello all,
> >
> > Friday, July 11, 2003, 3:18:58 PM, you wrote:
> >
> > ZG> hello list members,
> > ...
> > ZG> which type to be used for a type cast (that is not
> > allowed for the left
> > ZG> side) or how to use an address operator to manage it?
> > at least in my fpc 1.0.6 typecasts for the left side are allowed,
> > value := r;        // error
> > real(value) := r;  // works ! ;-)
> >
>
> In the (at least my) reference guide in chapter "6.4 Value typecasts"
> (version 1.8) there is written:
>
> "Value typecasts cannot be used on the left side of assignments, as variable
> typecasts."
>
> doesn't it mean that the above is not allowed or do I miss something?

It means you cannot do

 TSomeType(1):=SomethingElse

as opposed to

 TSomeType(AVariable):=SomethingElse

Which means essentially that a typecast of a constant is still a constant,
and cannot be assigned to. (same goes for expressions)

You can of course do
 SomethingElse:=TSomeType(1)

Michael.





More information about the fpc-pascal mailing list