Re: public, export
- Posted by jeremy (admin) Mar 15, 2009
- 946 views
A simple example right now:
-- button.e export function button_class_id() return "Button" end function public function button_new(sequence name) -- make new button return button end function -- window.e export function window_class_id() return "Window" end function public function window_new(sequence name) -- make new window return window end function -- gui.e public include button.e as but public include window.e as win ? button_class_id() -- Good! ? window_class_id() -- Good! -- myprog.ex include gui.e object w = window_new("Hello World!") -- Good! object b = button_new("Press Me") -- Good! ? window_class_id() -- Unknown Function! ? button_class_id() -- Unknown Function!
See, the *_class_id() methods are used internally for the multi-file GUI library. They are not meant to be used by the user, nor should the user be relying on them. Their implementation/functionality may very well change over time. So, the export keyword allowed those functions to be exposed to those who directly included button.e or window.e, but their availability was not passed on when gui.e did a public include button.e or public include window.e.
Jeremy