Prev | Current Page 281 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

jpg???);
// removing the import statement, the above line should be
// var c = style.FillKind.Texture(???filename.jpg???);
switch(c)
{
// with or without the import statement, the constructor
// name can be used without indicating the complete name
// as long as the ???c??? type is known
case Solid(color):
// ...
case Gradient(startColor, endColor):
// ...
case Texture(file):
// ...
}
}
}
The Color type can be an enum , a typedef , or a class and its implementation has been omitted
because it is not important to understand the import logic.
144
Part I: The Core Language
Type Lookup Sequence
When the compiler parses a file and encounters a variable type, an argument type, or a return type, it
will perform the search for its definition in the following order of priority:
Type parameters like class parameters or enum parameters. It ??™ s not really a good practice to
define a type parameter with the same name as an existing type, but it can happen incidentally
when an external library is imported.


Pages:
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293