Project Updates

Sunday, January 9, 2011

New OOP Syntax Details

From the Syntax2.f file:

Module
   removes all modules from the search order
   creates the structure, creates a wordlist, and sets the pointer to the size counter for field words
   it doesn't add itself to the search order automatically

::
   Compile a verb or method
   If the word that follows is NOT a method ,
      creates an internal word that can be accessed externally with a > prefix
      both words it creates are private; to use them you have to add the module to the search order with Using
   If the word that follows IS a method ,
      it sets the following code to be the implementation for that method with this module.
      and it creates a version using the Module:Method convention (called the direct version)
         unlike methods, direct versions they are always internal.
      Methods are still always public, including the direct versions.

Fields are always private now.  They still have the internal and external versions, but you have to add the class to the search order with Using or :: to get to them.

Procedural
   Remove all classes from the search order.

Var
   now a shorthand for Variable but also supporting being a cell-size field
   in a Module , fields are private.
   in a Structure , fields are public.

Field and Make can also be used inside or outside a class.

Embedded
   automatically called by Module (and Structure) , puts Var and friends
   in "OOP" mode, i.e. they will be private or public depending on if
   we're defining a module or a structure.

Make: and New
   Automatic initialization; note this doesn't preclude the Class: convention
   Make: ;  is used to either embed a module into a class or
      compile a module into the dictionary using *STATIC* parameters.
      When a Module is instantiated, even if it's embedded
      will be passed to that module's Init method.
   'New' is the runtime version of the same principle. It passes whatever
      parameters to the given Module's implementation of Init .

No comments:

Post a Comment