[Haskell-beginners] GLfloat cast... have I got it right?
Arlen Cuss
celtic at sairyx.org
Fri Jul 8 00:37:56 CEST 2011
> The !a is, IIUIC, a strictness instruction that ensures that whatever
> expression I put here is evaluated immediately i.e. no thunk is
> generated and presumably no space leaks either: something rendering at
> 60 fps with 'interesting' calculations for RGB values for example could
> cripple the application!
Correct. (I believe it forces the expression to WHNF, which basically
means 'forces the value' in the case of things like numbers and floats,
AFAIK, but I've only just learned about that syntax myself)
> But back to the syntax: I am guessing (and hoping I've got it right for
> the *right* reasons) that it works because the definition says "a" for
> all three and that explicitly typing the first one automatically tells
> (infers!) the type inference system that the other two are to be treated
> as GLfloat types too.
Exactly. As you've specified one of them to be a given type (note that I
think it would be slightly off the mark to call it a "cast" here [as per
the subject], unless that terminology is the norm for numbers in Haskell
-- it reads more [to me] like you're actually informing the typing
engine that it *is* a GLfloat, not to make it into one!), the rest must
follow by virtue of them sharing that type.
Cheers,
A
More information about the Beginners
mailing list