Re: Homogeneous sequence
- Posted by Pete Lomax <petelomax at ?luey?nder.co.uk> Aug 14, 2007
- 671 views
Jason Gade wrote: > > Reading this thread with interest and yet with reservations also. > > According to the proposal would I be able to do something like this: > }}} <eucode> > sequence of integer x > sequence y > object z > > -- some code assigning values to x, y, and z > > x = y -- typecheck y to make sure it complies with the definition > x = z -- ditto > </eucode> {{{ > > Or would it fail right away because the type definitions do not match? I am sure you fears are unfounded. First, the typecheck both times is on x to ensure the new value fits. (error: type check failure, x is -1) Type checking is always done after the effect, for such messages. It is no different to y=z, failing (only) when z is not a sequence. The objective is to perform less type checks, not more. y=x would perform no typecheck whatsoever, because the compiler has enough type info to know it will succeed, ditto z=y and z=x. More detailed type info === even less checks. Actually this point is debateable: currently more detailed checks are so expensive no-one does them; if we slash the cost then argubly more people will use them, which is also an objective. Type-wise, you should note that the compiler can seem thick as pigshit:
integer i i=3.5 i="fred"
compiles/binds/translates without hitch. It only goes wrong at run-time; it is only the backend that knows much about type errors. Obviously the front-end is actually pretty smart about emitting the right code for the right types, just not about predicting type errors. Reasonable, I guess. HTH, Pete