Re: OO Theory misconceptions (was Re: can I make a list of
Re: OO Theory misconceptions (was Re: can I make a list of
- Subject: Re: OO Theory misconceptions (was Re: can I make a list of
- From: has <email@hidden>
- Date: Sat, 2 Feb 2002 02:11:49 +0000
Timothy Bates wrote:
>
That is a very cool example, but I think what is missing is the ability to
>
have an initialisation handler called on load script
>
>
Set bill to load script file.lib
>
>
bill's birthday()
>
--> "I was born on 1/2/02"
>
>
Where on load script, a handler called initialise() is called, which does
>
some setup and creation-time stuff (in this case, setting a birthday
>
property).
No problem. Here's one approach.
======================================================================
--the library file
property theDate : missing value
on init()
set theDate to current date
return me
end init
on birthday()
return "I was born on " & theDate's date string
end birthday
-------------------------------------
--the loader
set bill to init() of (load script "[path to lib file here]")
bill's birthday()
--> "I was born on Friday, February 1, 2002"
======================================================================
Another is to make the init() handler a constructor function, returning not
the entire library but just the stuff you want. HTH.
has