Object Oriented Programming in Script/Objects: Difference between revisions
m 2 revisions imported |
No edit summary |
||
| Line 1: | Line 1: | ||
[[Category:SCI Pages]] | |||
[[Official SCI Documentation]]<br /> | [[Official SCI Documentation]]<br /> | ||
[[Object Oriented Programming in Script|Table of Contents]] | |||
| |||
<div align="center"> | <div align="center"> | ||
Chapter: | Chapter: | ||
| Line 10: | Line 12: | ||
[[Object Oriented Programming in Script/An Extended Example|6]] | | [[Object Oriented Programming in Script/An Extended Example|6]] | | ||
[[Object Oriented Programming in Script/Index|Index]] | [[Object Oriented Programming in Script/Index|Index]] | ||
</div><br /> | </div> | ||
<div align="center"><span style="font-size: 22pt">Objects</span><br />''Author: [[Jeff Stephenson]]''<br />''1988-04-04''</div></div> | |||
<br /> | |||
==<br /> Introduction == | |||
<blockquote> | |||
Objects are specific instances of a class, and are defined using the instance statement: | Objects are specific instances of a class, and are defined using the instance statement: | ||
| Line 79: | Line 80: | ||
Any unknown symbol encountered in a compilation is assumed to be the ID of some object which is to be defined later in the source file. If no object with the symbol as its name is encountered by the end of the file, an error will be raised. | Any unknown symbol encountered in a compilation is assumed to be the ID of some object which is to be defined later in the source file. If no object with the symbol as its name is encountered by the end of the file, an error will be raised. | ||
<blockquote> | |||
==<br /> References == | |||
<references /><!-- Do not edit this section. It is autopopulated by <ref></ref> tags --> | |||
==<br /> Also See == | |||
< | |||
* [[:Category:SCI Documentation|SCI Documentation]] | |||
* [[:Category:Official SCI Documentation|Official SCI Documentation]] | |||
* [[:Category:SCI Scripting]] | |||
* [[:Category:Objects|Objects]] | |||
| | ||
[[Object Oriented Programming in Script | Table of Contents]] | [[Official SCI Documentation]]<br /> | ||
[[Object Oriented Programming in Script|Table of Contents]] | |||
<span style="float: left">[[Object Oriented Programming in Script/Classes|< Previous: Classes]]</span> | <span style="float: left">[[Object Oriented Programming in Script/Classes|< Previous: Classes]]</span> | ||
<span style="float: right">[[Object Oriented Programming in Script/Sending Messages|Next: Sending Messages >]]</span> | <span style="float: right">[[Object Oriented Programming in Script/Sending Messages|Next: Sending Messages >]]</span> | ||
| | ||
[[Category:References]] | |||
[[Category:SCI References]] | |||
[[Category:Historical Pages]] | |||
[[Category:SCI Historical Pages]] | |||
[[Category:Development]] | |||
[[Category:SCI Development]] | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SCI Documentation]] | [[Category:SCI Documentation]] | ||
[[Category:Official Documentation]] | |||
[[Category:Official SCI Documentation]] | |||
[[Category:Scripting]] | [[Category:Scripting]] | ||
[[Category:SCI Scripting]] | [[Category:SCI Scripting]] | ||
[[Category:SCI Objects]] | [[Category:SCI Objects]] | ||
Revision as of 14:16, 2 January 2026
Official SCI Documentation
Table of Contents
Introduction
Objects are specific instances of a class, and are defined using the instance statement:
Code:(instance anObject of aClass (properties aProperty: value ... ) (method (aMethod [p1 p2 ...] [&tmp t1 t2 ...]) code ) ... [(procedure ...)] )This defines an Object as an instance of class aClass. The properties and method statements are optional and are used to over-ride the default values and methods inherited from aClass.
The ID of an object or a class is what tells the sci kernel where to send messages. The object ID is obtained by simply writing the object's name wherever an expression is valid -- it can be assigned to a variable or passed as a parameter to a procedure. Thus, if we define egoObj as an instance of class Ego,
Code:(instance egoObj of Ego)we can assign the ID of egoObj to the global variable ego:
Code:(global ego 0) (= ego egoObj)Once this has been done, the following two expressions are equivalent:
Code:(ego x?) (egoObj x?)To find the distance from the object ego to the object wolf, we can pass the wolf's ID as an argument to ego's distanceTo: method:
Code:(ego distanceTo: wolf)Any unknown symbol encountered in a compilation is assumed to be the ID of some object which is to be defined later in the source file. If no object with the symbol as its name is encountered by the end of the file, an error will be raised.
References
Also See