..
var p2 : Point3D = new Point3D(1,2,3);
// ...
var c : Circle = new Circle(p1, 10);
// ...
}
}
The Point3D implementation is not shown in the example but it is a class that extends Point and that
resides in the same hx file. It is not the main type of the file and, thus, must be imported explicitly or
indirectly as described previously.
??‘
??‘
??‘
??‘
??‘
145
Chapter 6: Organizing Your Code
This technique seems to load the output file with an extra burden for the newly introduced typedefs ; in
practice the compiled result will be exactly the same as using direct imports. This happens because
typedef s are declarations used only to check the types at compile time and they are not actually
translated into bytecode in the generated output.
In some cases, it is useful to create instances of classes using their names and the reflection API. It
sounds obvious that no type check is done over the generated instances because they can only be
identified at run time. If those classes are used only with reflection, the compiler cannot know that they
are actually needed and will not include them in the output file.
Pages:
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295