-------- Message original --------
Sujet: Re: variable type cast
Date : Mon, 13 May 2013 09:11:11 +0200
De : Maurice Lombardi <Maurice.Lombardi(a)ujf-grenoble.fr>
Pour : Jay Michael <jmichael_ll(a)yahoo.com>
Le 13/05/2013 01:12, Jay Michael a écrit :
> gpc version 20070904, based on gcc-3.4.5 (mingw special)
> Given
> type INT16 = INTEGER attribute( size=16 ) ;
> type WORD16 = Cardinal attribute( size=16 ) ;
> var i16 : INT16 ;
> var w16 : WORD16 ;
> why does
> WORD16(I16) := W16 ;
> produce "error: invalid lvalue in assignment"?
First notice tht the other way around
I16 := INT16(W16) ;
works.
Typecasts are C style unportable "extensions" which garble the
"write once, compile everywhere" philosophy behind the strong typing
principles of Pascal.
There is certainly nothing about it in the standards, and I do not know
at which point this "lvalue error" crept in first into C, and then into
Pascal.
Maurice
--
Maurice Lombardi
Laboratoire Interdisciplinaire de Physique,
(ex Spectrometrie Physique)
Universite Joseph Fourier de Grenoble, BP87
38402 Saint Martin d'Heres Cedex FRANCE
Tel: 33 (0)4 76 51 47 51
Fax: 33 (0)4 76 63 54 95
mailto:Maurice.Lombardi@ujf-grenoble.fr