[comp.windows.news] NeWS Beginner Questions

tjcm@stl.stc.co.uk (Crawford Macnab) (05/13/88)

    o   Are class variables really different from instance variables ?

	Looking at litewin.ps it appears that every time a window is mapped for
the first time the class variables /FrameMenu and /IconMenu are redefined. 
Surely if a class object contains information to be inherited by all sub-classes
then this information should be initialised at class creation time.

    o   Has anyone created a window based interface to the debug.ps package ?

don@BRILLIG.UMD.EDU (Don Hopkins) (05/15/88)

   Date: 13 May 88 13:20:24 GMT
   From: mcvax!ukc!stl!tjcm@uunet.uu.net  (Crawford Macnab)




       o   Are class variables really different from instance variables ?

	   Looking at litewin.ps it appears that every time a window
   is mapped for the first time the class variables /FrameMenu and
   /IconMenu are redefined.  Surely if a class object contains
   information to be inherited by all sub-classes then this
   information should be initialised at class creation time.

       o   Has anyone created a window based interface to the debug.ps
           package ? 

The difference between instance variables and class variables are that
class variables are shared by all instances of a class and its
subclasses, while each instance has its own local instance variables.
The template for a class definition is:

/NewClass SuperClass
dictbegin
% Instance variables
dictend
classbegin
% Class variables and methods
classend def

(dictbegin/dictend can be replaced by an array of names that will be
initialized to null.) The instance variables are defined between
dictbegin/dictend, and every new instance will be initialized with the
values defined there. The class variables and methods (there's
physically no difference, methods are just variables with executable
arrays as values) are defined in the class dictionary between the
classbegin/classend pair. You can override a class variable, making it
into an instance variable, by def'ing its new value in the instance
dictionary.

I tried making FrameMenu and IconMenu class variables, and it worked,
except that the "Spin!" demo obnoxiously adds keys to the shared
FrameMenu! 

A window based debugger sure would be nice! Has anybody created Items
to display and edit various NeWS data types? (i.e. canvas editor,
process editor, dictionary editor, etc...)

	-Don

singer@Apple.COM (Dave Singer) (05/16/88)

In article <8805150638.AA14535@brillig.umd.edu> don@BRILLIG.UMD.EDU (Don Hopkins) writes:
>I tried making FrameMenu and IconMenu class variables, and it worked,
>except that the "Spin!" demo obnoxiously adds keys to the shared
>FrameMenu! 
>
>A window based debugger sure would be nice! Has anybody created Items
>to display and edit various NeWS data types? (i.e. canvas editor,
>process editor, dictionary editor, etc...)
>
>	-Don
The hack I used was to ensure that there was a framemenu/iconmenu class
variable in the same dictionary as the createframemenu/createiconmenu
procedures.  For obvious reasons this hack is easily fooled;  however
these problems didn't come up for me.  Creating those menus adds nearly
a second (half the time) to creating a window (the other big consumer is
in allocating the canvas itself).

I also have a version of class.ps which you should be able to get from
SUN, which allows multiple inheritance, class re-definition, adding new
methods and class variables after class definition, and type/inheritance
checking.

Finally there is also an inspector I wrote for NeWS structured objects
(dictionaries, arrays, processes etc.) which shows all the key/value pairs
in these things and allows you to update them.  There was a bug in updating
executable arrays last time I looked.

*I no longer work at Schlumberger, where I wrote these.  SUN has
re-distribution rights for them;  ask there or at Schlumberger.*