Article View: comp.lang.logo
Article #156Re: Object Logo (was Re: Logo is based on 1960s...)
From: Brian Harvey
Date: Mon, 17 Aug 1992 05:29
Date: Mon, 17 Aug 1992 05:29
57 lines
2492 bytes
2492 bytes
A quick summary of the object mechanism in Object Logo: There is a hierarchy of classes. (We'll see later that the class/instance distinction is not enforced, but for now let's think of it that way.) To create a new class, you say KINDOF <oldclass>, e.g., MAKE "BACKWARDS.TURTLE KINDOF TURTLE To make a particular turtle (an instance) you say MAKE "TORTUGA ONEOF TURTLE or MAKE "TERRAPIN ONEOF :BACKWARDS.TURTLE [Why the colon or not? TURTLE is a primitive *procedure* that outputs a class; BACKWARDS.TURTLE is a *variable* whose value is a class. If you don't like it you can say TO BACKWARDS.TURTLE OUTPUT :BACKWARDS.TURTLE END but there's nothing new about that.] Every instruction is carried out by some object. (There is an object called Logo at the root of the tree that's the default object if you don't specify one.) To direct an instruction to an object you say ASK :TORTUGA [FD 100] More complicated instructions may involve more than one object: ASK :TORTUGA [SETHEADING TOWARDS ASK :TERRAPIN [POSITION]] You can specialize methods by using TO in a class: ? ASK :BACKWARDS.TURTLE [TO FORWARD :DIST] > USUAL.FORWARD (- :DIST) > END That's basically it, except for the details: 1. There is no real difference between a class and an instance; both are just objects. The difference between KINDOF and ONEOF is that the latter, after creating the new object, does ASK <new-object> [EXIST] The EXIST method generally creates instance variables, but it can do anything you want. So an instance is just a subclass with its own instance variables. 2. There's multiple inheritance. 3. There are a number of predefined classes, not just turtles but windows, text windows, graphics windows, menu bars, and so on. But the classes you create don't have to be about physical screen or system-like things; you can specialize LOGO and get a bare-bones class.
Technical Details
Message-ID:
<16ndfbINNic9@agate.berkeley.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!sun-barr!ames!agate!anarres.CS.Berkeley.EDU!bhReferences:
<gthomas.712971296@unixg.ubc.ca> <1992Aug5.143104.16220@newshost.lanl.gov> <1992Aug16.173417.3526@usenet.ins.cwru.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!sun-barr!ames!agate!anarres.CS.Berkeley.EDU!bh From: bh@anarres.CS.Berkeley.EDU (Brian Harvey) Newsgroups: comp.lang.logo Subject: Re: Object Logo (was Re: Logo is based on 1960s...) Date: 17 Aug 1992 05:29:15 GMT Organization: University of California at Berkeley Lines: 57 Message-ID: <16ndfbINNic9@agate.berkeley.edu> References: <gthomas.712971296@unixg.ubc.ca> <1992Aug5.143104.16220@newshost.lanl.gov> <1992Aug16.173417.3526@usenet.ins.cwru.edu> NNTP-Posting-Host: anarres.cs.berkeley.edu