⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swarm.defobj.sgml.reference.html

📁 set for Swarm2.1是圣菲研究院的开发人员对Swarm的特性及其使用描述的最为完备的指南性文档。从这里可以获得最细致的平台说明。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD><TITLE>Defobj Library</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.53"><LINKREL="HOME"TITLE="Documentation Set for Swarm 2.1.1"HREF="set.html"><LINKREL="UP"TITLE="Reference Guide for Swarm 2.1.1"HREF="book930.html"><LINKREL="PREVIOUS"TITLE="Beta to 1.0.0"HREF="x1840.html"><LINKREL="NEXT"TITLE="Archiver"HREF="swarm.defobj.archiver.protocol.html"></HEAD><BODYCLASS="REFERENCE"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Documentation Set for Swarm 2.1.1</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="x1840.html">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="swarm.defobj.archiver.protocol.html">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="REFERENCE"><ANAME="SWARM.DEFOBJ.SGML.REFERENCE"></A><DIVCLASS="TITLEPAGE"><H1CLASS="TITLE">I. Defobj Library</H1><DIVCLASS="PARTINTRO"><ANAME="AEN2268"></A><TABLECLASS="SIDEBAR"BORDER="1"CELLPADDING="5"><TR><TD><DIVCLASS="SIDEBAR"><P><B>Overview</B></P><P>The defobj library supports the style of object-oriented      programming that is used throughout Swarm. It defines a specific style      for using the Objective C language that includes its own standard      conventions for creating objects and for storage allocation, error      handling, and debugging support.</P></DIV></TD></TR></TABLE><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SWARM.DEFOBJ.SGML.SECT1.DEPEND">1. Dependencies</A></H1><P>The defobj library is defined and documented using the <AHREF="swarm.library.sgml.appendix.html">library interface conventions</A>      established by the defobj library. It imports the Object      superclass and other standard type definitions of the GNU      Objective C runtime system.</P><P>The collections library must always be linked along with the defobj      library. Even though the interface definitions of defobj do not depend      directly on collections, the implementations of these libraries both      require the presence of the other. Only the collections library should      be initialized directly; initialization of the collections library      automatically initializes the defobj library as well.</P></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SWARM.DEFOBJ.SGML.SECT1.COMPAT">2. Compatibility</A></H1><P>No explicit compatibility issues for particular versions      of Swarm</P></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SWARM.DEFOBJ.SGML.SECT1.USAGE">3. Usage Guide</A></H1><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN2282">3.1. Why Swarm uses Objective C</A></H2><P>Swarm uses object-oriented programming not only because this is a good        way to build general-purpose software libraries, but because the very        concept of an object is at the base of how you build a model in        Swarm. To build a simulation in Swarm, the first step to define the        various kinds of objects that can inhabit some real or artificial        world, and the second step is to define the kinds of events that can        occur to these objects, including all the different ways that the        objects can interact with each other.</P><P>The basic concept of an object is that it responds to external events,        and that the only thing that really matters about an object are the        ways it can be observed responding to these events. In an        object-oriented programming system, an object is represented by some        uniquely identified chunk of data, and the events are the dynamic        operations that can be made to occur on these objects.</P><P>Different object-oriented programming systems define the operations        that occur on objects in different ways. For example, in C++ the        operations are called "member functions" and look much like an        ordinary function call in the C language. In Objective C, an operation        on an object is called a "message" and has a special syntax by which        you call it, but a message also has arguments and behaves in many        respects like a call to a function.</P><P>The key requirement for Swarm is to be able to make all these        operations happen to any object at any time, whenever they're supposed        to occur within some simulated world. It stores these operations        inside its own data structures, and when you run a simulation in        Swarm, the Swarm system itself traverses these data structures to make        the necessary operations happen at the proper time.</P><P>Swarm needs to be able to make any kind of action happen to any kind        of object at any time, and to do this it needs very general-purpose        structures that hold some kind of representation of the actions        themselves. That's a special requirement that not every object        language provides. You already have enough work to define the kinds of        objects that can exist inside your model, and Swarm doesn't want you        to have to define an even larger number of objects for every kind of        event that might occur to your objects. Instead, it wants the object        language to provide it with a representation of the operations on        objects that you've already defined. Swarm can then store these        representations in its own data structures, and make the operations        happen whenever it needs to.</P><P>In Swarm, the representation of events that happen on objects        are just as fundamental to the model as the objects themselves. That's        why Swarm is a "discrete-event" simulation system. But if the object        system doesn't provide a general-purpose enough representation of        events as well as objects, there would be a lot more work to do. The        Objective C system, through its special data type called a "message        selector," provides a representation of operations that is flexible        enough to do this, but the C++ language does not. (In C++, the        compiler requires more information about an operation than the event        structures in Swarm would be able to provide.)</P><P>There's a host of additional reasons why Objective C has also        been a good match for the requirements of the Swarm system. Like C++,        the operations on objects can be compiled to a very efficient form        (though Objective C does require a little more overhead than C++ to        get the operation started). This efficiency can be very important for        a simulation, since simulations can run for very long periods of time        to explore all the behavior that might occur within their simulated        worlds. Other languages, such as Lisp, Smalltalk, and Java, also have        the "dynamic message dispatch" feature that would make general-purpose        event structures possible, but they still carry significant added        overhead compared to C.</P><P>Objective C is also a very simple extension to the C        language. Basic knowledge of C is already widespread, and a few days        are typically all that is needed to learn the few additions of        Objective C. (Really learning the concepts of objects, however, can        take much longer, no matter what object language you try to use.)</P><P>Objective C was also a good choice for Swarm because it has a        high quality, freely distributable implementation in the GNU C        compiler. One of the main concerns about Objective C is that it isn't        nearly as widely known or used as other languages like C++, but at        least the GNU C compiler assures it will be available on machines        where Swarm needs to run. The OpenStep system now part of the Apple        Rhapsody project (formerly NeXTStep of the NeXT corporation), and the        parallel GNUStep project, also help assure that Objective C is a        living language.</P><P>There are even more powerful aspects of Objective C that        Swarm takes advantage of. Some of these are described in the        <AHREF="swarm.defobj.sgml.reference.html#SWARM.DEFOBJ.SGML.SECT1.ADVUSAGE">Advanced Usage        Guide</A> of the defobj library. But many others are at the        heart of how Swarm uses Objective C, and so are dealt with in        the rest of this Usage Guide. The entire purpose of the defobj        library is to define a standard style for the use of Objective        C in Swarm. This style is backed up by a library of foundation        classes that Swarm provides to support this        style.</P><P></P><P>Swarm provides its own foundation classes even for such basic        operations as creating an object, and other support that user classes        ordinarily receive from a builtin Object superclass. A good        understanding of the defobj library is essential for Objective C        programming in Swarm. Like any programming language, Objective C        requires learning not only the rules of the language itself, but also        a standard library of initial capabilities that you build        from. Objective C doesn't really have a single official standard        library (or language definition either, for that matter), but the        OpenStep foundation libraries (and the OpenStep language definition)        come very close to this status.</P><P>For a variety of reasons explained here and in the <AHREF="swarm.defobj.sgml.reference.html#SWARM.DEFOBJ.SGML.SECT1.ADVUSAGE">Advanced Usage        Guide</A>, Swarm doesn't use a standard library based on        the NextStep foundation interface. You can still learn the        Objective C language from other available sources, but you        have to be careful to sort out the language level from the        standard object and library support they also discuss.</P><P>The index page of the Swarm documentation provides a variety of        links to other Objective C resources.  In particular, it provides a        link to a complete on-line reference for the Objective C language as        defined by OpenStep (formerly NextStep) and implemented by the GNU C        compiler. None of the Swarm documentation attempts to duplicate this        coverage of the basic language; Swarm assumes that you learn Objective        C from other available sources. The Objective C reference (<AHREF="http://devworld.apple.com/techpubs/rhapsody/ObjectiveC/index.html"TARGET="_top"><ICLASS="CITETITLE">Object-Oriented          Programming and the Objective C Language</I></A>) is the single best        available source, and it can also be ordered as a hardcopy book from        the <AHREF="http://devworld.apple.com/techpubs/rhapsody/rhapsody.html"TARGET="_top">Rhapsody          Developer Documentation site</A> . Don't try to program in        Objective C without it.</P><P></P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN2304">3.2. Swarm style of Objective C Programming</A></H2><P>No matter where you've learned to program in Objective C, don't        try to use Objective C in Swarm without understanding the special ways        in which Swarm adapts its use of the language and the language runtime        system. Your place to find this information is right here in the        defobj library. Defobj not only provides the most basic layer of        foundation class libraries for Swarm, but also serves as the place        where all the rules and guidelines for the use of Objective C in Swarm        are gathered together.</P><P>Some of these rules and guidelines don't even require any        specific software to implement them, but are just conventions and        recommended style that anyone programming in Objective C can follow        when their goals are similar to those of Swarm, and to a large extent

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -