[gtkada] simple.adb (again)

Emmanuel Briot briot at gnat.com
Wed Jan 3 12:30:26 CET 2001


 > I read this on the documentation. However, in another example
 > (SCRIBBLE.ADB) the callback packages are not instantiated on separate
 > packages.

As Joel explained, it might work in the simple case where your generics are
instantiated in your main program, since their lifetime is the same as the
program itself (elaboration code not withstanding).
This is why we took the shortcut in the example.

However, in the general case, this simply means that you must instantiate the
generics in a package, rather than in a local subprogram.

 > As a beginner studying this example, I became conscious that it is very
 > difficult to realize to what packages the GTK procedures belongs. I
 > would like to suggest avoiding the USE clause, at least in the small
 > examples like this.

True. Although it also tends to make the examples harder to read, and might
frighten some people just having a quick look.
I would recommend using tools like Emacs and the ada-mode, or the "gnatfind"
tool that is packaged up with GNAT.
Then it is easy to find where an entity was defined.

 > Considering this example, it seems that some instructions should be
 > removed. Are the instructions marked with # necessary?

No, you can remove them since you don't use these variables afterwards.
Probably an incorrect copy-paste, I will remove them from the example.
In fact, if you look at the line that contains the call to Draw_Example,
it seems that we have decided to inline everything rather than use local
variables, so these are now unnecessary.

thanks for reporting it.

regards,
Emmanuel




More information about the gtkada mailing list