• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OO Theory misconceptions (was Re: can I make a list of
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: [Meta,OT] OOP and Forks
  • Next by Date: Re: How to coerce a real to an integer in X?
  • Previous by thread: Re: OO Theory misconceptions (was Re: can I make a list of
  • Next by thread: Re: OO Theory misconceptions (was Re: can I make a list of
  • Index(es):
    • Date
    • Thread