Using The Apple Dylan Development Environment
Using The Apple Dylan Development Environment
Preliminary
ð
Developer Press
Apple Computer, Inc.
iii
iv
Adding the framework 131
Including C code 132
Compiling your project 133
Launching the runtime 135
Untethering from the runtime 136
Checking code status 136
Compiling a selection 139
Compiling all uncompiled code 140
Compiling code from the Listener 141
Excluding code from compilation 143
Including code in compilation 143
Running an application in Apple Dylan 144
Tethering to a running application 145
Debugging a project 146
Inspecting the stack 148
Inspecting Listener results 151
Inspecting heaps 153
Inspecting modules 154
Metering expressions 156
Monitoring an individual function 159
Creating a user interface 161
Adding the Apple Dylan interface builder 162
Adding the new user interface 163
Sharing your user interface 164
Building your application or library 164
Building your standalone application 164
Building a library 166
Sharing code 167
Sharing projects 168
Sharing code by exporting 168
Retrieving code by importing 171
v
Stack window commands 222
Inspector window commands 223
Glossary 273
Index 279
vi
P R E F A C E
Preface
This book, Using the Apple Dylan Development Environment, gives you a good
look at the user interface and program development environment in Apple
Dylan. You’ll find that the Apple Dylan tools allow flexible programming and
full access to information about your program.
The term Apple Dylan refers to the development environment and associated
tools, extensions and capabilities developed by Apple Computer for
programming in the Dylan language, an object-oriented dynamic language.
For more information on programming in the Apple Dylan language, see the
books Programming in Apple Dylan and Apple Dylan Extensions and Framework
Reference. For more details on creating a user interface for your application, see
the book Creating a User Interface in Apple Dylan. For information on how to
install and configure Apple Dylan on your system, see the booklet Apple Dylan
Quickstart.
What to Read 0
This book has three chapters, a glossary, and an index. You can either read it
sequentially or move around in it from one topic to another.
■ Learning Apple Dylan—introductions to and explorations of the
development environment. This chapter should give you a chance to learn
how to interact with the development environment without a lot of
explanation. This chapter primarily familiarizes you with the browsing and
editing features of the Apple Dylan environment.
■ Using Apple Dylan—deeper understanding and in-depth tasks described.
This chapter opens with a description of the Apple Dylan User Model,
which is the chain of actions and events that takes you from starting to write
code, through compiling, and finally to creating a running standalone
application.
vii
Special Fonts 0
All code listings, reserved words, and the names of data structures, constants,
fields, parameters, and functions are shown in a monospaced font (this is
monospaced).
When new terms are introduced, they are in boldface. These terms are defined
in the glossary.
Types of Notes 0
There are several types of notes used in this book.
viii
P R E F A C E
Note
A note like this contains information that is interesting but
possibly not essential to an understanding of the main text.
Often, these Notes include additional information. See for
instance,“The active project” on page 102.
▲ WARNING
A note like this contains information that is especially
important. As this is an early release of Apple Dylan, not
all interactions are as smooth as we want them to be. For
instance, the warning in “The active project” on
page 102. ▲
ix
P R E F A C E
x
C H A P T E R 1
The source database contains all your source code with all its links and
structure. What you see is a project displaying objects of finer and finer
granularity, right down to the source code. The largest containers in a project
are modules, which contain source folders. The source folders hold source
records, which contain the source code. All of these containers can be dragged,
dropped, and copied as if you were in the Finder.
The development environment displays the project in browsers, windows with
one or more linked panes. The browsers operate as if a set of panes were tiled
next to each other and then bound together so they could interact. Most
browsers are linked together in such a way that the object you select in one
pane has its contents displayed in another pane. This way you can browse
through a list of objects in the first pane, examining the contents of each in turn.
Information displayed in each pane is under your control.
A number of browsers are supplied with Apple Dylan but you can also create
browsers of your own. The main browser for a project is called the project
browser. The browser in the following figure is the default project browser
shipped with Apple Dylan. When you first open or create a project, this
browser configuration is displayed. In this example, the sample project
text-app was opened.
The default project browser has three panes linked to display the text-app
project. The title bar for the browser displays the project’s name, as does the
header of the pane in the upper-left. That pane displays the major components
of the project, mostly modules and subprojects. This is the root pane of the
browser because it is the browser’s upper-left pane. The root pane’s basis (or
source) is the project itself.
The pane in the lower-left displays the contents of whatever object you select in
the upper-left pane. The panes have been linked in the project browser to
display that relationship, although that link could be changed to display other
relationships. Likewise, in the default project browser the contents of any object
selected in the lower-left pane are displayed in the pane on the right.
In the previous figure the module named text-app has been selected in the
upper-left pane. That module holds the code for the project that the project’s
author wrote. Its contents appear in the lower-left pane. Notice that some of the
contents have been expanded within the pane using disclosure triangles, just
as you would in the Finder. The last object in the lower-left pane, a source
folder named text-app, has been selected, so its contents appear in the pane on
the right. In the pane on the right the numerous source records are listed and
some of them have been expanded. There is even a warning that has been
generated during compilation. The warning appears at the end of the source
code for the source record behavior-setup-menus.
The following figure shows the two left-hand panes of the browser in the
previous figure. This figure identifies some of the features on the panes and on
the browser, which surrounds the panes. The browser’s name is on the bar at
the top of the figure. In this example, the name is “Project: text-app”.
Name of project
Status indicator visible in pane
Status indicator
Resource file
Name of module
Close pane box
Icon representing
module
Expanded
source folder
Disclosure triangle
Status indicator
Vertical splitter
Information line
Module
Name of
source folder
Aspect visible
in pane
Close pane box
Zoom box
Icon
representing Horizontal
source folder splitter
Incoming link
Status
indicator
Expanded
source
record with
an error in it
Warning
generated
during
Unexpanded compilation
source record
Expanded
source record
Status
indicator
column
You can enter any Dylan expression into the Listener for immediate execution.
For example, you can call functions in the Listener (including your
application’s startup function), and you can define functions, variables, and
classes in the Listener. The following figure shows the Apple Dylan Listener
window with a simple expression, 3 plus 4, entered at the prompt and the
return value, 7, returned by the Listener. The Listener is ready for the next
expression, as indicated by the waiting prompt, >.
Your application under development can run under the control of the Apple
Dylan development environment. It doesn’t need to be complete and built as a
standalone application to do so. While you are still developing the program,
your code can run loaded into a small, “nub” of an application called the
Application Nub, which is tethered to the development environment. The code
you write is added to the application nub every time you compile the code,
allowing you to slowly build up to your final standalone application.
The following figure shows Apple Dylan tethered to the Application Nub, as it
is while you are developing your application.
AppleDylan
Application nub
Library
Caches
debug info
Project sources
Database Libraries
When your project is complete and you build your standalone application, the
services provided by the application nub and the code in your project are
bundled together. The connection to the development environment is severed.
The following figure shows that when you build your standalone application,
the Application Nub and your application have become one and it has been
severed from the development environment.
AppleDylan
Your application
Library
Caches
debug info
Project sources
Database Libraries
This means that from your point of view as a programmer, the application
under development and the standalone application are equal. Just as you can
interact with an unfinished project connected to the application nub, so too can
you interact with a standalone application that was already been built in Apple
Dylan. You might need to do this for further debugging of the application.
The browsers and the Listener help you write your source code and compile it,
but you need to debug it too. For that the development environment provides
inspector windows. When you have a problem, inspector windows let you
examine runtime objects to help you determine the cause of the problem.
7. Double-click on the Apple Dylan icon from the Finder and then
double-click on the Application Nub.
8. Choose About This Macintosh from the Apple menu.
Verify that at least 50K of unused memory is available.
9. Double-click on Quit Application Nub from the Finder.
When you have the memory adjusted properly, quit the Application Nub
before proceeding with any other tasks in this chapter. The Quit Application
Nub file is in the folder Apple Dylan: Apple Dylan Files: Application Nub.
Ordinarily you launch and quit the Application Nub from within Apple
Dylan. However, in this case and other rare cases, you might need to quit the
Application Nub using this executable file in the Finder.
Dylan is a library that contains the basic definitions of the Dylan language
and the Apple Dylan extensions. This subproject is automatically included in
all projects and cannot be removed or modified.
Mac-toolbox is a library containing the Macintosh toolbox calls that have
been included with this project. It is up to you to add this library and
include any of the Macintosh toolbox calls you want to use in your project.
Dylan-framework is a library containing the Apple Dylan application
framework. You must add the framework to your project if you want to use
it; it is not automatically added to a new project. Since the source code for
the framework is included in Apple Dylan, you could modify it if you want,
however, this is not a common practice, nor is it recommended.
Dylan-user is a module. Every project has its own individual Dylan-user
module. In very simple projects all the code for the project can be in the
Dylan-user module. More commonly, it is standard practice for the
Dylan-user module to contain the module definition and library definition
used to structure the rest of the project. You will have to write your own
module definition and library definition for your project.
The puzzle module is a container for most of the source code for this project.
You will create your own module for your project that will contain your
source code.
The file puzzle.rsrc is the resource file used by the puzzle project. If you
want to use resource files in your project, you must add them to your project
using the Add to Project command.
5. Choose the Preferences command from the Edit menu.
6. Increase the icon size from the Environment sheet.
By changing the Browser Icon Size setting to 16 (or even 32), the differences
between icons are easier to see. If you do that, you might want to increase
the font size to 10 or more as well. For a complete listing of the icons in
Apple Dylan, see the section “Using icons in Apple Dylan” on page 88. You
can set other preferences from the other Preferences sheets. They can be
reached from the Category pull-down list at the top of the Preferences dialog
box.
The following figure shows part of a pane with the icon size at 12, which is the
default.
The following figure shows part of a pane with the icon size increased to 16.
Using browsers 1
Browsers are windows with one or more panes. The panes are tiled so none are
in the background or foreground in relationship to one other and can be linked
to work together. Browsers are where you will do most of your coding and
compiling.
Using browsers 15
C H A P T E R 1
If you have just launched the development environment, you need to open a
project before you can open any browsers. The project browser must remain
open as long as you are working on that project. To close the project browser is
to close the project.
Once you have opened a project or created a new one, you can open other
browsers to get other views of the project. Several built-in browsers are listed in
the third and fourth sections of the Browse menu. To get a complete list of all
browsers available to you, choose List of Browsers from the Browse menu. You
can have several browsers other than the project browser open at once and
closing them does not close the project.
You can change the configuration of the panes in an existing browser, create
new browsers, and save a browser’s configuration. You don’t need to save the
code changes you make in a browser when you close it, but if you have
changed the configuration of the browser, you can choose to save that new
configuration with the Save Browser command.
The code changes are not lost when you close a browser (unless that browser
was the project browser and you specifically chose not to save any changes). To
save code changes, you select the pane containing the changes, and then choose
Save from the File menu. Likewise, you can save all the code in an entire
project by issuing a Save All command or simply choosing to save it when
prompted to do so as you close its project browser.
You can open a project from inside the development environment or from the
Finder. Double-clicking on a project file, which has the suffix “.π”, launches
Apple Dylan (if it’s not already running) and opens that project.
The sample projects provided with Apple Dylan include puzzle, text-app, tiles,
paint-app, hello, Online Insultant, and skeleton, among others. The sample
projects can be found in the folder Sample Code, or the alias in it. Some have a
Read Me file with them, either as a file in their folder or within their project
itself as a text file.
Browsing a project 1
When you open a project, its project browser appears. In the upper-left pane, or
root pane, of that browser the contents of the project are listed.
Every project has a Dylan subproject, which always appears first on the list in
the root pane of the project browser. This is the library containing the Dylan
16 Using browsers
C H A P T E R 1
language itself. The Dylan subproject is created automatically and you cannot
edit it.
Every project also has a Dylan-user module. It is also created automatically
when you create a new project, but it must be edited to specify your project’s
library and module definitions.
If a project uses the framework or the mac-toolbox library, these also appear as
subprojects. You can add these to a project using the Add to Project command
on the File menu.
The default project browser has three panes that are linked so they can work
together to display a project in detail. Whether you click an object’s disclosure
triangle, icon, or name produces different results in a browser. Double-clicking
produces still other results. You can change the aspect visible in a pane, if you
wish, using the Aspect command on the Browse menu.
1. Open the puzzle sample project, if it’s not open already, and make sure it’s
the active project.
Use the Open command and choose the file puzzle.π. The sample projects
can be found in the Sample Code folder or the alias in it. If you had another
project open before opening puzzle, you will need to click in the puzzle
project once you open it, and then use the Activate Project command from
the Project menu. If puzzle were not the active project, the project browser’s
name would read “Project: puzzle (inactive)” and the root pane’s name
would read “puzzle (inactive)”.
2. When puzzle opens, click on the icon or name of the subproject Dylan.
You will see that you can’t open it and a message prints “No applicable
aspect”. This subproject is the library containing the Dylan language, which
you cannot change (or even view) from within the development
environment.
Using browsers 17
C H A P T E R 1
3. Click the icon and then the disclosure triangle for the subproject
mac-toolbox.
You can see the contents of an object by clicking on the disclosure triangle to
its left. When you click its disclosure triangle, the contents of mac-toolbox
are displayed much as they would be in the Finder. The contents are Dylan,
Dylan-user, and mac-toolbox. These are references to the Dylan project, the
Dylan-user module, and the mac-toolbox module.
18 Using browsers
C H A P T E R 1
For now, click the disclosure triangle again to collapse the list of the contents
of mac-toolbox.
4. Click the disclosure triangle left of the subproject dylan-framework to
expand its contents inline.
This is the Apple Dylan framework, which you might want to study later. Its
contents are Dylan, mac-toolbox, Dylan-user, dylan-framework, and
dylan-framework.rsrc. Don’t be concerned about efficiency or memory and
disk space when you see redundant references to such objects as Dylan or
mac-toolbox. These are only references to these objects, which are not being
duplicated with each reference.
As shown in the following figure, since you did not select the name or icon
of dylan-framework, only its disclosure triangle, you have not selected
dylan-framework. The subproject mac-toolbox was your last selection so its
contents are displayed in the other two panes in the project browser.
Using browsers 19
C H A P T E R 1
5. Click the icon or name of the Dylan-user module in the root pane, then
click the disclosure triangles for its library and module source records in
the pane on the right.
As shown in the following figure, the module Dylan-user has been selected
so its contents, the source folder library & module, appear in the lower-left
pane. Then library & module has been selected so its contents appear in the
pane on the right. This is because the three panes are linked in this way.
20 Using browsers
C H A P T E R 1
When you click the name or icon of an object in a pane, such as the root
pane, you see its contents displayed in the pane it’s linked to, the lower-left
pane in this case. The name and icon for the selected object, in this case the
Dylan-user module, also appear in the header of the other pane. As seen in
the preceding figure, the header for the lower-left pane shows the
Dylan-user module’s name and icon, as well as its default aspect, Contents
of.
The lower-left pane is linked to the right-hand pane, so the contents of the
object selected in the lower-left pane appear on the right. In this case, the
contents of the library & module source folder in the lower-left pane appear
in the right-hand pane. The contents of the source folder are the source
records. The header for the pane on the right now has the name and icon for
the library & module source folder in its header. Its default aspect is also
Contents of.
Within library & module are the two source records, the puzzle library
definition and puzzle module definition. As shown in the preceding figure,
they have been expanded in the pane on the right to reveal their source
code. Notice that a dark line surrounds the content area of the right-hand
pane in the following figure, indicating that it is the active pane. When you
click in a pane, you make it the active pane.
Using browsers 21
C H A P T E R 1
7. Expand the contents of the puzzle source folder by clicking its disclosure
triangle in the lower-left pane.
When you expand the puzzle source folder in the lower-left pane, you see its
contents listed inline in the lower-left pane. If you select the puzzle source
folder, its contents are also listed in the right-hand pane because these two
panes have been linked. You could edit this code in either pane and the
other pane would immediately update. For now, just click disclosure
triangles in the right-hand pane to see the code in individual source records.
You can click the pane’s zoom box for more space or drag its resizing box to
make it bigger.
22 Using browsers
C H A P T E R 1
Using browsers 23
C H A P T E R 1
9. Double-click the object puzzle.rsrc in the root pane of the project browser.
You might need to scroll the root pane so you can see the resource file. You
cannot edit a resource file from within Apple Dylan, but must use the
resource editor of your choice from the Finder. You add a resource to a
project using the Add to Project command.
24 Using browsers
C H A P T E R 1
For more information on List of Browsers, see its reference entry in the third
chapter.
Using browsers 25
C H A P T E R 1
1. Open the puzzle sample project, if it’s not already open, and make sure it
is the active project.
The sample projects can be found in the Sample Code folder or an alias in it.
In the following figure you can see that the module puzzle has been selected
in the root pane. Its contents are listed in the lower-left pane. In addition to
the puzzle module being highlighted in the root pane, it is also named at the
bottom of the project browser as the active module. The puzzle source folder
has been selected in the lower-left pane, thus revealing its source records in
the right-hand pane.
2. Select a source record for a class in the right-hand pane, such as the class
<puzzle-view>, and choose Direct Methods from the Browse menu.
The class <puzzle-view> is the third source record from the top in the
right-hand pane of the project browser. The top source record is a comment.
For more information on the icons in Apple Dylan, see the section “Using
icons in Apple Dylan” on page 88.
In the following figure you can see all the direct methods for <puzzle-view>
listed in the Direct Methods browser that opens. You can investigate each of
these source records further, if you wish, expanding them to see their source
code or opening other browsers for them. If you edit their source code here,
the changes are updated in all the browsers immediately. To save the code
changes, click in any pane where the source code is displayed (even if it is
26 Using browsers
C H A P T E R 1
currently out of view due to scrolling) and use the Save command from the
File menu.
Drag the Direct Methods browser off the project browser before continuing.
3. Select the class <puzzle-view> in the project browser and choose Direct
Slots from the Browse menu.
Another browser, Direct Slots, opens with <puzzle-view> as its basis as well.
This browser lists all the direct slots for <puzzle-view>. You are now able to
view two aspects of <puzzle-view> in the new browsers, its direct methods
and its direct slots.
Using browsers 27
C H A P T E R 1
If you drag the Direct Slots browser off the project browser and expand the
<puzzle-view> source record inline, you see its source code inline. As shown
in the following figure, you would be viewing three aspects of
<puzzle-view> simultaneously. In fact, a built-in browser named Info for
Selected Class is very similar to this. For more information on it, see the task
“Using the browser Info for Selected Class” on page 53.
28 Using browsers
C H A P T E R 1
Using browsers 29
C H A P T E R 1
Drag the Call Grapher browser off the project browser before continuing.
5. Select initialize in the project browser and choose Function Family from
the Browse menu.
Notice that another browser, Function Family, opens with initialize as its
basis as well. This browser lists all the other initialize functions in the active
project. You are now able to view two aspects of initialize in the new
browsers.
Drag all the browsers off the project browser before continuing.
30 Using browsers
C H A P T E R 1
6. Expand the class <puzzle-view> in the project browser and type an extra <
into its definition.
Notice that a small square appears in the gray, status indicator column to the
left of the source record. This is a status indicator. If you click the status
indicator, its name appears on the information line at the bottom of the
browser. In this case, it is the Unsaved indicator, meaning that you have
changed this source record but haven’t saved it yet.
There are several other status indicators in Apple Dylan, including the
Uncompiled indicator and Warnings indicator. You can see the list of
indicators using the Status Indicators command on the Browse menu. For
more information on using them, see the chapter “Using Apple Dylan” on
page 95.
7. Scroll down the source records in the right-hand pane and expand some
source records until <puzzle-view> is no longer visible.
Notice that, although you cannot see the unsaved source record anymore,
you can see that the source folder it’s in, puzzle, has an Unsaved indicator in
the lower-left pane marking it as containing something unsaved. The puzzle
module in the root pane has one as well. If you had gone on to editing other
source records and forgotten exactly which source records were still
unsaved, you might have a difficult time finding them. In that case, you
would want a way to list all the unsaved source records in the project.
Using browsers 31
C H A P T E R 1
9. Expand the source record and delete the extra < from the source code.
32 Using browsers
C H A P T E R 1
You will notice that the code is still marked as unsaved with a status
indicator and still listed in the Unsaved Source Records browser.
10. Click in the Unsaved Source Records browser and choose Save from the
File menu.
Notice that <puzzle-view> is no longer listed in the Unsaved Source Records
browser.
Using browsers 33
C H A P T E R 1
Close the empty browser or move it off the project browser before
continuing. Notice that the source code in the project browser has been
updated, as has all the status indicators.
34 Using browsers
C H A P T E R 1
You can open one of the browsers on the Browse menu or you can create a new
browser of your own, either by double-clicking on an object or selecting it and
choosing the New Browser. A new browser has only one pane, so if you want
to have more than one pane in the browser, you split the pane in two. The new
pane is automatically linked to the original pane. You can close an individual
pane within a multi-pane browser by using its close box in the upper left
corner of its header.
1. Open the puzzle project, if it’s not open already, and make it the active
project.
The sample projects can be found in the Sample Code folder, or by using the
alias in that folder.
The following figure shows the project browser for puzzle with the module
Dylan-user selected in its root pane and the source folder library & module
selected in its lower-left pane. The contents of the source folder are
displayed in the pane on the right.
2. Hold down the mouse on the outbox of the root pane without releasing
the mouse.
The outbox displays the outgoing link, which in the following figure is from
the puzzle project’s root pane to the lower-left pane.
Release the mouse when you have seen the link’s name.
Using browsers 35
C H A P T E R 1
36 Using browsers
C H A P T E R 1
4. Hold down the mouse on the outbox of the lower left pane.
The following figure shows the destination of the outbox’s link is the pane to
the right, which has “library & module” as its basis, as noted in its pane’s
header.
Release the mouse when you have seen the link’s name.
5. Select the puzzle module in the root pane and the puzzle source folder in
the lower-left pane.
6. Select a class, such as <puzzle-view> in the right-hand pane and choose
the browser Info for Selected Class from the Browse menu.
Leave the project browser open as you work with the other browser.
The browser shown in the following figure opens with <puzzle-view> as its
basis, as noted in the browser’s name and in its root pane’s header. The class
<puzzle-view> is automatically selected in the grapher pane at the top of the
browser, while its direct slots and direct methods are listed in the two lower
panes, as shown in the following figure.
Using browsers 37
C H A P T E R 1
If this browser were already open, you could have dragged the
<puzzle-view> class from the project browser to the inbox of the root pane
in this browser. This would have made <puzzle-view> the basis of this
browser. Dragging an object from one browser to the inbox of the root pane
on a separate browser is similar to linking them, but it does not create a link.
This is drag and drop behavior that is common to all browsers. The dragged
object is simply the basis for the separate browser; the two browsers are not
linked. The project browser’s outbox and the separate browser’s inbox are
still gray and no link exists.
7. Examine all the links on the inboxes and outboxes for the Info for
Selected Class browser, just as you did for the project browser.
Notice the inboxes and outboxes. The two outgoing links in the lower panes
are not red; they are not linked to anything yet.
8. Drag the outbox for the lower-left pane to the inbox of the lower-right
pane.
In the following figure the inbox for the lower-right pane is red as the
outbox from the other pane is being dragged onto it.
38 Using browsers
C H A P T E R 1
Release the mouse on the inbox and the two panes are linked.
9. Click the puzzle-pict-setter source record in the lower-left pane.
Notice that the selected source record is now the basis for the lower-right
pane. In the following figure the source record puzzle-pict-setter is selected
in the lower-left pane and is named as the basis of the lower-right pane in its
header. Examine all the links.
Notice that the outbox of the lower-left pane names the lower-right pane as
its destination, as shown in the following figure.
Using browsers 39
C H A P T E R 1
Direct methods is not a valid aspect for puzzle-pict- setter, but you can easily
change it to show one that is, such as the variable definitions of it in the
active project. For more information on how to change aspects in Apple
Dylan, see the task “Changing aspects” on page 46.
10. Drag the outbox from the right-hand pane on the project browser to the
inbox of the root pane on the Info for Selected Class browser.
You can link two separate browsers by dragging the outbox from a pane in
one browser onto the inbox of any pane in the other browser. This allows
you to create complex sets of browsers.
Notice that the inbox of the Info for Selected Class browser turns red as you
drag the outbox from the project browser onto it, as shown in the following
figure.
40 Using browsers
C H A P T E R 1
Using browsers 41
C H A P T E R 1
12. Click the class <puzzle-behavior> in the project browser to see it as the
new basis for the Info for Selected Class browser.
In the following figure, <puzzle-behavior> has been selected in the project
browser, which causes it to become the basis for the other browser. Examine
the outgoing link from the project browser.
42 Using browsers
C H A P T E R 1
2. Click in the puzzle project’s root pane, without selecting anything, and
then choose Aspect from the Browse menu.
On the submenu of the Aspect command, the aspects available for a project
are listed. All projects have the same aspects available for them. You could
choose to view an aspect other than Contents of this project, such as Classes
of, but if you do, choose Default (Contents of) again before continuing.
Using browsers 43
C H A P T E R 1
5. Select the puzzle source folder in the lower-left pane and then click in the
right-hand pane without selecting anything.
The right-hand pane now displays the contents of the puzzle source folder.
6. Display the pop-up list of aspects from the header of the right-hand pane.
You can display an object’s list of aspects from the header of the pane its
contents are displayed in. You do this by clicking in the pane without
selecting anything, holding down command-option, and then holding the
mouse down on the object’s name or icon in the header. You will see all the
aspects available just as you would if you had used the Aspect command
from the Browse menu.
In the following example, the aspects available for source folders are
displayed on the pop-up list because the puzzle source folder is the basis for
the pane. For our purposes, don’t select one or, if you do, reselect the default
before continuing.
44 Using browsers
C H A P T E R 1
7. Hold down the Command and Option keys, then click the initialize
source record in the right-hand pane.
The list of aspects for source records is displayed. Notice that its default
aspect is Source Code of +Warnings of.
Using browsers 45
C H A P T E R 1
Changing aspects 1
The easiest way to see a different aspect for an object is to select the object and
choose a built-in browser from the Browse menu. Several browsers have been
built into the development environment for your convenience. They each show
a different aspect, as noted in their names on the Browse menu. When you
choose one, a new browser opens displaying the aspect for the selected object.
However, not all aspects have built-in browsers already made for them. Also,
you might want to change the aspect in a pane you created in a custom
browser or some other existing pane, not open an entirely separate browser. In
that case, you can choose to change the aspect within a pane. Also, if you
change the basis for a pane, the new basis might have a different default aspect,
so that new aspect will consequently be displayed in the pane.
Many aspects are available only for the active project.
If you change the aspects in a browser and want to keep that browser
configuration for use later, you must save it before closing the browser. See the
task “Saving a browser configuration” on page 61 for more information.
1. Open the puzzle sample project and make sure it’s the active project.
The sample projects can be found in the Sample Code folder or using the
alias in it.
46 Using browsers
C H A P T E R 1
3. Click in the pane but don’t select anything, then choose the Aspect
command from the Browse menu.
You will see that the aspects for a source record are listed. Its default, Source
Code of +Warnings of, is the first item on the list. You can choose to see any
of the other aspects on the list and can go back to the default by choosing it
again later.
Using browsers 47
C H A P T E R 1
the pane has changed in the following figure. The pane’s basis, initialize, has
not changed, but its aspect has.
7. Release the mouse with the cursor still over the inbox.
The is-puzzle-solved source record becomes the new basis for the pane in
the Function Family browser. However, the inbox to the Function Family
browser is not red. This is because you have not created a link by dragging
48 Using browsers
C H A P T E R 1
in another source record, you have only changed the basis of the pane. The
icon and name of is-puzzle-solved are shown in the pane’s header in that
browser.
Ordinarily when you expand an object within a pane, you see its default
aspect. For example, if you expand a source record its Source Code of
+Warnings of aspect is displayed inline. You can change that aspect to
another aspect by selecting the object’s name or icon and then using the
Aspect command to select a different one. The new aspect is revealed inline
with the object; no new pane is created, nor is a new browser opened.
Using browsers 49
C H A P T E R 1
1. Open the puzzle sample project and make sure it’s the active project.
The sample projects can be found in the Sample Code folder or by using the
alias in it.
2. Type the name of the class, method or variable in question,
StandardGetFile in this case, into the Listener.
This simply identifies the class or method you want to investigate. You
could type it into a source record in a pane and select it there.
3. Choose the dylan-framework module from the Listener’s Module popup.
You must set the module you want to search in using the Module popup in
the lower-left corner of the Listener window. For more information on using
the Listener, see the section “Running an application in Apple Dylan” on
page 144.
50 Using browsers
C H A P T E R 1
Using browsers 51
C H A P T E R 1
6. Select choose-document and use the Browse menu to select the References
To browser again.
We want to see how choose-document is used. We see there is a
behavior-event and a do-event.
52 Using browsers
C H A P T E R 1
Using browsers 53
C H A P T E R 1
3. Choose the browser Info for Selected Class from the Browse menu.
The browser opens, showing the graph for <stream> along with its direct
slots and direct methods.
The graph displays the five subclasses of <stream>. Notice that the class
<object> has no arrow to its left. That means it is the root of this hierarchy.
4. Click the first subclass on the list, <byte-stream>.
Its direct slots and direct methods are listed in the two lower panes, as
shown in the following figure.
54 Using browsers
C H A P T E R 1
Continue clicking the other subclasses, to see their direct methods and direct
slots, if you want. Resize the browser slightly so you can see the full names
of the five subclasses.
5. Click the arrow to the right of <byte-stream> on the graph.
This further expands the graph. Notice that there are two more subclasses,
but they are not fully visible. Resize the browser more to see the full names
of the two subclasses.
Continue expanding subclasses until there are no more arrows to the right of
any subclass, if you have room on your monitor. You could reveal all the
classes of the hierarchy by continually expanding and resizing the browser,
but you would need a very large monitor.
Using browsers 55
C H A P T E R 1
6. Select an arrow on a bar separating two classes and click the arrow to
collapse that part of the hierarchy.
The following figure shows the arrow to click to collapse the graph at that
point.
56 Using browsers
C H A P T E R 1
Using browsers 57
C H A P T E R 1
Customizing browsers 1
You can customize any browser, either an existing one or a new one you create.
You create a new browser by double-clicking on an object in a pane, which will
open a new, separate browser with that object as its basis. You can also create a
new browser by selecting an object and using the New Browser command on
the Browse menu.
To customize a browser, you can change the links between its panes as
described previously in this section. Furthermore, you can change the aspects
visible in the panes. For more information on aspects, see the tasks “Showing
different aspects of objects” on page 42 and “Changing aspects” on page 46.
You can also add panes or resize existing panes. A new browser has one pane
and its basis is the object selected prior to creating it. The selected object is
specifically the basis for the root pane of the new browser and can, therefore, be
considered the basis of the new browser. The default aspect for the selected
object dictates the type of aspect displayed in the new browser’s pane.
If you want more than one pane in the new browser, you can split the pane in
two. Each of the two new panes can also be split, both horizontally and
vertically. You split a pane with its splitter controls; the horizontal splitter
58 Using browsers
C H A P T E R 1
control is a short, horizontal bar just above the scroll bar on the right of a pane.
The vertical splitter control is a short, vertical bar just to the left of the scroll bar
at the bottom on a pane. To split a pane, hold down the mouse on the splitter
control and then drag the dashed line that appears to wherever you want the
pane split. Another way to split a pane is to drag an outbox onto a splitter; the
pane splits in half and a link is created from the original pane to the new pane.
You can resize existing panes to create different relative sizes. The resize control
in the lower-right corner of each pane and each browser can be dragged to
create new sizes. You can also drag a horizontal line up and down and a
vertical line from side to side between panes.
You can close a pane by clicking its close box in the upper left corner of its
header. If you want to save the configuration of a customized browser, do so
before you close it. For more information on saving browsers, see the task
“Saving a browser configuration” on page 61.
In the following task, the browser Info for Selected Class is customized by
adding a pane.
1. Open the sample project Streams, if it’s not already open, and make sure
it’s the active project.
The sample projects can be found in the Sample Code folder or by using the
alias in it.
2. Select the <stream> class in the stream basics source folder, and choose
Info for Selected Class from the Browse menu.
The Info for Selected Class browser opens with <stream> as its basis.
3. Examine the outbox of the lower-right pane.
Notice that it is not linked to anything, so the outbox in the pane’s header is
gray. In addition, the outbox says “Not Linked”, as shown in the following
figure.
Using browsers 59
C H A P T E R 1
4. Drag the outbox of the pane onto its own vertical splitter control.
You can split a pane in one of two ways, by dragging its outbox to one of its
own splitters or by dragging a splitter control to the desired location for the
split.
n the vertical splitter control is a short, vertical bar just to the left of the
scroll bar at the bottom of a pane.
n the horizontal splitter control is a short, horizontal bar just above the
scroll bar on the right of a pane.
The following figure shows the lower-right corner of the browser with the
outbox of the lower-right pane being dragged onto its vertical splitter. The
splitter control turns red when the outbox is on it.
This splits the pane vertically and creates a link to the new pane. Notice the
outbox is now red on the pane you split, which is half its original width, and
60 Using browsers
C H A P T E R 1
the inbox of the new pane to its right is also red. Nothing has been selected
in the split pane, so the new pane does not display anything yet.
5. Click buffer-end in the middle-lower pane.
You can now click an object in the original pane and it is displayed in the
new pane. The basis for the new pane in this example is buffer-end, as
shown in the following figure. The aspect Source code of is the default
aspect for buffer-end, so that is the aspect displayed in the new pane.
6. Leave this browser open as you start the next task, “Saving a browser
configuration.”
To keep a customized browser configuration for use later, you must save it
before closing the browser. See the task “Saving a browser configuration” on
page 61 for more information.
Using browsers 61
C H A P T E R 1
environment by moving the browser’s file out of the Browsers folder in Apple
Dylan. You do this by leaving Apple Dylan and dragging the file into another
folder or into the Trash. The browser remains on the development
environment’s lists of browsers until the development environment is restarted.
1. Select the customized browser from the previous task.
If you don’t have the customized browser from the previous task still open,
open any built-in browser from the Browse menu. You don’t need to
customize it to save it with another name.
Neither do you have to have any particular project open to accomplish this
task, although in this example the Streams project is open and active. You
could even create a new project by choosing New Project from the File
menu. The browsers you save are available in any project you work on in
Apple Dylan.
2. Look at the Browse menu to see what browsers are currently listed.
The built-in browsers are in the third and fourth sections of the Browse
menu. Any previously saved browsers are in the fourth section.
62 Using browsers
C H A P T E R 1
3. Click in the customized browser you created in the previous task and
choose the Save Browser command on the Browse menu.
Because the active browser is saved, be sure to make active the browser you
want to save before choosing the Save Browser command. You don’t have to
customize a browser to save it with a new name, although that is the
common reason for saving a browser.
4. Locate the Browsers folder using the dialog box, enter a name for the new
browser, and click Save.
A browser should be saved into a file in the Browsers folder of Apple Dylan
or one of its two subfolders. You can save any browser, whether an existing,
new, or changed browser, and give it the name you want. If an existing
browser has the same name, it is overwritten. The objects in the browser are
not saved, just the configuration of panes and all links internal to the
browser.
If you save the browser to a file in the main Browsers folder, the browser
appears in the fourth section of the Browse menu. This type of browser
responds to a selection for its basis, such as a class. If you save the browser
to a file in the subfolder _Ignore Selection Browsers, the browser appears in
the third section of the Browse menu. This type of browser does not respond
to a selection, but instead uses the active project as its basis. If you save the
browser to a file in the subfolder _System Browsers, the new browser does
not appear on the Browse menu, but only on the List of Browsers browser.
You might do this if you wanted to create a new configuration for the default
project browser.
You can now copy the file, mail it to others, and handle it in many ways as
any file on the Macintosh. You can open it by double-clicking it in the Finder.
Using browsers 63
C H A P T E R 1
The new browser is now listed on the Browse menu and probably in List of
Browsers. In addition, the customized browser now shows the new name,
such as Modified Class Info in this example.
64 Using browsers
C H A P T E R 1
Using browsers 65
C H A P T E R 1
8. In the Finder, go to the Browsers folder in Apple Dylan to see the new file.
n Copy, Cut and Paste and related Apple Dylan commands from the Edit
menu
n Clear and Undo and related commands from the Edit menu
n Replace and Find and related commands from the Text menu
n Formatting commands on the Text menu
n Importing and exporting Dylan text files from the File menu
n Macintosh and Emacs-style editing key commands
In combination, these tools allow you to perform complex editing of Dylan
sources while remaining within the structure of your project as displayed by
the development environment.
The best way to learn editing in Apple Dylan is to do it. You can practice using
the sample projects. When you are through practicing, use Revert from the File
menu to bring the sample project back to normal, or simply do not save
changes when you close the sample project.
▲ WARNING
These tools have been assembled from a variety of sources
and may not behave with complete consistency. In
particular, the contents of the Clipboard and the
Emacs-style kill ring are not always synchronized.
Apple Dylan also offers the Copy Special and Insert Special commands, which
are specialized for Dylan programming. These commands are on the Edit menu
and support two different styles of template-based editing.
Copy Special puts a template on the Clipboard and Insert Special puts the
information directly in an editor buffer without affecting the Clipboard.
These commands work only in the active project and require a valid selected
object. This can be either text that names an object, such as a method name, or a
source record icon. Three kinds of information are available, depending on the
nature of the object selected:
n Argument List—provides a prototype argument list for the selected
method
n Class Template—provides a prototype template for a subclass of the class
or classes selected
n Method Template—provides a prototype template for the selected generic
function or method
Copy Special appears on the Edit menu when an object is selected. The action
of the command writes the chosen prototype information to the Clipboard. You
can also use the key shortcut Command-J if you want just the argument list, or
Command-T if you want a template. The available template changes from class
to method depending on what you have selected.
Insert Special does not appear on the Edit menu, but is available by pressing
the option key when you click on Copy Special. Insert Special does not use the
Clipboard, but places the prototype information directly in the current editor
buffer. You can also use the key shortcut Command-Option-J if you want to
insert just the argument list or Command-Option-T if you want a template. The
available template changes from class to method depending on what you have
selected. Insert Special Argument List places the argument list just behind the
insertion point, but deletes no text. Insert Special Template replaces the selected
class or method with the new template.
Use these commands to get the argument list of a method you want to call, or
to create new methods and classes based on existing ones. In general, the Copy
Special commands will be most used, but the Insert Special commands may be
helpful in some situations. Say you wanted to create a method “moo” based on
the existing method “foo”. Type “foo” into the Listener and select it, then press
Command-Option-T and the template for “foo” replaces the name “foo” and
you can proceed with your new method, making sure to change the name of
the method in the first edit.
See the reference documentation for more information on Copy Special and
Insert Special and examples of their use.
left pane of the default project browser. This means that if the source code of
subprojects is available, it will be searched.
Note
Most editing in Apple Dylan operates on one source record
at a time, not the entire project as in this case.
In addition to the conventional Find and Replace commands, the Text menu
also provides Find Selection, which searches the current pane for the selected
text. Find Selection is independent of the other Find/Replace commands; it
performs no replacing and does not change what Find Again searches for.
Formatting commands 1
In addition to the Find/Replace commands, the Text menu permits you to
change the Font, Size, Style, and Color of any text to which you have write
access. Changing any of these items marks the source record for recompilation,
but otherwise has no semantic effect. There are no established guidelines on
text markup, but it is common to use bold for the name of the object being
defined. Use text markup to highlight whatever distinctions are convenient for
you and your project, such as assigning colors to individual code, or particular
type sizes or styles to different functions. Autostyling is not available.
Text markup from Apple Dylan is exported and imported in .dylan text files.
Text markup imported from other editors is ignored.
The Export command performs only limited code checking. Export breaks a
single source record with more than one top-level form or comment into an
individual source record for each top-level form or comment when exported.
You can bring Dylan text files into the Apple Dylan development environment
using the Import command.
You can export a project with partial source records, but you will not be able to
reimport it. If any exported code within a source folder has the incorrect
number of begins or ends, or is any other way seriously malformed, the source
folder cannot be imported.
Importing or exporting has no effect on objects marked for exclusion or
inclusion.
The Macintosh-style scrolling commands (Page Up, Page Down, etc.) do not
move the insertion point. Once you get where you’re going, you must click to
move the insertion point. The Emacs-style cursor-movement commands move
the insertion point.
The following table summarizes the Macintosh-style editing commands. In all
cases, a source record is a buffer and vice versa.
Common Lisp. Fred is included for the convenience of those who already know
Emacs.
Assigning meta to the option key, which you can do using the Preferences
command, may conflict with some of the Macintosh key commands using the
option key. In such cases, use Control-Q followed by the option key to insert a
literal option key.
Meta-X commands are not implemented. The meta key must be pressed and
released for each use, not held down like the Control or Command keys. Where
the meta key is used in combination with other modifying keys, it works best
to press the meta key and release it before pressing the rest of the key
combination.
The Fred kill ring contents may sometimes overwrite the Clipboard. Clipboard
contents are not available from the Fred kill ring.
In addition to the usual use of the mouse to select text by dragging across it,
two clicks selects a word, three clicks selects a line, and four clicks (tricky)
selects the entire buffer, that is, the entire source record.
You may discover other Emacs-style commands in Fred, but their employment
is not supported as they may produce ambiguous or erroneous results.
The table summarizes Emacs-style editing commands. This table is not
intended as documentation of these commands, but as a checklist of those Fred
commands that should work in Apple Dylan.
The meta key is assigned to escape by default. You can choose to use the option
key as the meta key through the Editing Category on the Preferences dialog.
This setting of the meta key conflicts with using the option key for
Macintosh-style editing commands. In this case use Control-Q to quote the
option key as itself.
Emacs-style Keys
cursor motion
• Control-B, ← Move the insertion point back one character.
• Control-F, → Move the insertion point forward one character.
• Meta-B, Meta← Move the insertion point back one word.
• Meta-F, Meta → Move the insertion point forward one word.
• Control-A Move the insertion point to the beginning of the line.
• Control-E Move the insertion point to the end of the line.
• Control-P, ↑ Move the insertion point up one line.
• Control-N, ↓ Move the insertion point down one line.
• Meta-V Scroll upward.
• Control-V Scroll downward.
• Meta-< Move the insertion point to the first line of the source
record.
• Meta-> Moves the insertion point to the last line of the
source record.
• Meta-M Moves the insertion point to the first
non-white-space character in its current line.
Selection
• Shift ← Move insertion point one character to the left and
select.
•Shift → Move insertion point one character to the right and
select.
• Meta-Shift ← Move insertion point one word to the left and select.
• Meta-Shift → Move insertion point one word to the right and select.
•Control-Shift-A Move insertion point to beginning of line and select.
•Control-Shift-E Move insertion point to end of line and select.
•Control-X H Select entire buffer and move to beginning.
•Shift ↑ Select to same point on previous line and move
insertion point.
•Control-Shift-P
Emacs-style Keys
•Shift ↓ Select to same point on next line and move insertion
point.
•Control-Shift-N
•Control-Shift Space Set mark.
Insertion
•Control-O Insert new line but don’t move insertion point.
•Control-Meta-O Split line and indent.
•Control-Y Yank current kill ring. Replace selected text if any.
•Meta-Y Rotating yank.
•Control-Q Insert next keystroke quoted—use if Meta key
assigned to Option and you need Option.
•Meta “ Insert pair of double quotes around insertion point.
•Meta-U Make rest of word uppercase and move insertion
point to end.
•Meta-L Make rest of word lowercase and move insertion
point to end.
•Meta-C Capitalize first letter of rest of current word or
selection and move insertion point.
•Control-T Transpose two characters surrounding insertion
point.
•Meta-T Transpose two words surrounding insertion point.
•Command-click Replace the selected text with the Dylan expression
you command-click on. Especially useful for
replacing one name with another, less useful for
other Dylan expressions; Dylan syntax is not well
understood by the Fred editor.
Deletion
•Delete Delete character to left of insertion point.
•Meta-delete Delete word to left of insertion point.
•Control-D Delete character to right of insertion point.
•Meta-D Delete word to right of insertion point.
•Control-K Delete remainder of line.
Emacs-style Keys
•Control-W Delete current selection and add to kill ring.
•Meta-W Copy current selection and add to kill ring.
•Control-X Delete all spaces and tabs from insertion point to
•Control-Space next character.
•Meta-Space Replace all spaces and tabs surrounding insertion
point with a single space.
•Meta-\ Delete all whitespace characters to left and right of
insertion point.
Undo
•Control-_ Undo previous command.
•Control-Meta-_ Display Undo history.
Numeric arguments
•Control-U Repeat next keystroke 4 times.
•Control-n. Meta-n Repeat next command n times.
Incremental search
•Control-S Initiate forward incremental search.
•Control-R Initiate reverse incremental search.
•Delete Delete last character typed from search string.
•Control-G Clear search string.
Editing code 1
You can edit code and rearrange objects in a browser. You can drag objects
between projects to copy them or copy code from individual source records
between browsers or projects. You can also copy code to and from the Listener
or a text file.
Several sample projects have been included with Apple Dylan. You can use
code from them by copying it into your project. In addition you can use code
from the framework, whose source code has been included in Apple Dylan.
You can edit code in any project, it does not have to be the active project.
However, you cannot compile code in anything but the active project.
1. Open the sample project Streams, if it’s not already open, and make it the
active project.
The sample projects can be found in the Sample Code folder or by using the
alias in it.
2. Create a new project using the New Project command on the File menu.
The following figure shows the default new project browser. Notice that the
Dylan-user module is automatically selected, an untitled source folder
automatically created within it and an empty source record within that. You
could type or copy code into the source record, but for now click in the
Streams project so you can work in it first.
3. Select a location for a new source record in the Streams project and choose
New Source Record from the File menu.
Select an object in the pane you want the new object in. This is how you add
modules, source folders, and source records to an existing project. In the
following example the class <two-buffer-stream> has been selected in the
Streams project browser and New Source Record chosen from the File menu.
You could type or copy code into the new source record. To copy code,
simply highlight the code you want to copy, whether it’s in another source
record, even in another project, or in the Listener and then use the Copy
command.
4. Select the icon of the source record output-buffer-position and drag it
above output-buffer-offset.
This is how you can rearrange objects in Apple Dylan. You can also drag
objects between panes, between browsers, and between projects. Dragging
between projects copies the object, dragging within a project moves it.
Select the module streams-implementor and its source folder stream basics,
if the source record output-buffer-position is not visible. In the following
figure, notice the heavy black marker that indicates where the dragged
source record will be inserted when the mouse is released.
When you release the mouse, the source record appears at the position of the
heavy black line. In the following figure the drag has been completed and
the source record output-buffer-position is above output-buffer-offset.
5. Expand the source record <two-buffer-stream> so you can see its source
code.
You can edit its source code inline using the Edit and Text menu commands.
6. Select text within the expanded source record to delete and choose Clear
from the Edit menu.
The text is deleted with the Clear command.
7. Choose Undo Clear from the Edit menu.
To reinstate the text, use Undo Clear. Notice that the exact wording of the
Clear and Undo Clear commands change appropriately to match the type of
action you can perform. You can undo up to 20 editing commands.
8. Double-click on the source record initialize.
Although you could edit an expanded source record inline in the project
browser, you will probably want to edit the code in a separate browser. You
can edit this code using the Edit and Text menu commands. The following
figure shows the new browser that opens with initialize as its basis.
9. Select the name of the initialize method in the new browser to use it as a
template for a new method.
The Copy Special and Insert Special commands use the language databases
within Apple Dylan to retrieve code templates.
In the following example, initialize has been selected and will be used as the
basis of the template.
10. Choose the Copy Special command Method Template from the Edit menu.
The Method Template (Copy Special) command copies the template to the
Clipboard. The following figure shows initialize selected and Method
Template being chosen from the Edit menu.
11. Go to the source record where you want to use the template, click where
you want the code placed, and choose the Paste command.
In this example, go to the newly created source record in the new project and
click in the new source record. In the following figure the code template for
initialize has been pasted into the new source record in the new project. You
can see both the new project browser with the new code in its right-hand
pane and the separate browser in front of it with initialize still selected in it.
Click in the new source record to edit the template and create your own
version of initialize by specializing at least one of the parameters.
The Insert Special commands work in a similar way to the Copy Special
commands, but they do not use the Clipboard.
12. Choose Close from the Project menu to close the Streams project.
You can also use the close box on the project browser to close the project.
Don’t save the changes to the Streams project. Close your new project,
saving it if you wish.
There is no need to have any projects open for the next section because you
set the preferences for the development environment as a whole, not for
individual projects.
2. Choose the type of font you want used for display in the browsers.
3. Choose the size for icons.
The icons in the development environment are clearer if you choose an icon
size of 16 in the Browser Icon Size field.
4. Click Inspect Stack on Error if you want to open the Stack window on any
error that occurs while compiling your code.
See the chapter “Using Apple Dylan” on page 95 for more information on
the implications of this choice.
5. Click Launch Application Nub when Active Project is Opened if you want
to launch the application nub whenever you open a project.
See the chapter “Using Apple Dylan” on page 95 for more information on
the implications of this choice.
6. Click Update when Application Nub is Launched if you want to update
the active project whenever you launch the application nub.
See the chapter “Using Apple Dylan” on page 95 for more information on
the implications of this choice.
Editing sheet, you can choose the font to use when editing code, the meta key
you want to use, if any, how to automatically indent code, and whether you
want to display warnings with the source code.
The following figure shows the default values for the Editing sheet. Choosing
the Default button resets the defaults for all fields on all three sheets.
1. Choose the Editing sheet from the Category popup.
The following default sheet appears.
2. Choose the font family and size you want to use while editing code.
Changes you make in these fields apply only to edits you make after
changing this.
3. Change the meta key for editing with the Emacs-style key commands, if
you want.
4. Click in the boxes for the type of indentation you want applied to your
code.
5. Click Auto Display Argument List if you want to automatically display
the argument list.
6. Click Display Warnings with Source if you want to automatically display
any warnings within source records.
2. Choose the font family and size you want to use while editing code in the
Listener.
3. Choose a maximum number of lines you want printed in the Listener, if
you want to limit them.
4. Choose a maximum number of elements of a list you want printed in the
Listener, if you want to limit them.
5. Choose a maximum number of break levels you want displayed in the
Listener, if you want to limit them.
6. Click Detect Circularities if you want to stop printing after the first time
around a code circularity.
■ Next there is the icon of a source record for a class, the basic icon
superimposed on a standard document icon. This is the most commonly
encountered form:
■ Finally, there is the icon of an excluded source record, the basic icon
superimposed on a standard comment icon:
You control the display size of icons through the Environment sheet of the
Preferences command. See “Setting development environment preferences” on
page 84.
■ default size, 12 points
:
■ 16 points
■ 32 points
Following is a summary of the most commonly encountered Apple Dylan icons, displayed in their most
commonly encountered forms:
■ Project
■ Application seen in Finder. The Application Nub and Apple Dylan have this
icon.
■ Comment
■ Unrecoverable Error
■ Saved Browser
■ Source folder
■ Source module
■ Resource file
Close any open projects when you are done with this chapter. Don’t save the
changes to the sample projects.
The Apple Dylan development environment is powerful and easy to use. You
can create applications quickly because the environment is organized around
objects, just as the Dylan language is. You will see that the various types of
code elements appear in the environment with different icons so you can tell
them apart. These objects can be manipulated by dragging and dropping, just
as you would suppose.
The Project 2
The project is the central concept in Apple Dylan. A project is a set of
documents that encompass all the elements of your programming effort:
n libraries
n subprojects
You can add libraries to a project, just as you can add any project to another.
When you add them to a project, the added libraries and projects are
represented as subprojects in it. These subprojects, along with any resource files
you add, appear in the project at the same level in the hierarchy as modules.
A library is a namespace for module names. They allow you to use other
people’s libraries without causing name collisions between modules. Libraries
are created with the “define library” statement. A module is a namespace for
variables, so you can similarly avoid name collisions between variables when
using other people’s libraries. Modules are created with the “define module”
statement.
The end result of your work on a project is either an application or a library. An
application runs when you double-click it. A library is a building block used by
an application, allowing for sharing of reusable code.
A number of sample projects are included in the Apple Dylan distribution.
These sample projects are used for all examples in this document as well as
being available for independent learning.
When you start Apple Dylan, the first thing you see is the Listener. You can’t do
much with the Listener without an active project open, so open a sample
project, such as “paint-app”, using the Open command. Open the file in the
Apple Dylan folder with the path Sample Code: More Samples: paint-app:
paint-app.π. (The π is the suffix that identifies the document as a Dylan project.)
You should see the default project browser open. The Dylan-user module is
selected in the root pane in this example:
The root pane of the project browser (upper-lefthand pane) displays the major
elements of the project. Each project contains one or more subprojects, which
contain the libraries that the project’s library needs. Every library needs the
“Dylan” library, one language library, one or more modules contained by the
library (each library contains an implicitly defined “Dylan-user” module), and
any text or resource files, if needed.
Here is what you see in the root pane of a typical project’s project browser (you
might have to scroll or zoom the pane to see all its contents):
n Dylan library—a subproject that contains the Dylan language itself. This
subproject looks different from other subprojects because it has no source
code. All projects include this library.
n mac-toolbox—a subproject that contains a set of import statements in
Dylan that give access to the (non-Apple Dylan) routines in the Macintosh
Toolbox.
n dylan-framework—a subproject that contains an object-oriented class
library that implements (in Apple Dylan) a common set of features found
in Macintosh applications.
n Dylan-user—a module defined for each project. The module is intended
primarily for setting up other modules and libraries, but is useful in small
or experimental projects as a single module.
To see these definitions, move to the righthand pane of the project browser and
expand the two paint-app objects by clicking on their disclosure triangles:
It is here that the scope of the project is defined, that is, which libraries and
modules form part of the project.
Note
In this example, the module definition includes a use
statement for Apple-Dylan. If you were writing portable
code for use in non-Apple environments, the use statement
would name Dylan, not Apple-Dylan so the compiler
would catch any use of Apple extensions.
Note
The Dylan-user module is in each project, but you must
define for each project a unique version of the Dylan-user
module. It is possible to write a program without defining
a library or any other modules by simply using Dylan-user
for everything. With the exception of the tiniest
experiments, this practice is not recommended as it
circumvents the design of the language and the
development environment. When you create a new project,
you should create a new module or modules to hold all
your code.
Use the Finder to examine the directory for the paint-app sample project. You’ll
find the following on your hard disk:
n paint-app.π—the project file, which actually consists of pointers into other
files. This is the file to open when you want to use a project in the
development environment.
n _Source Database—all source records for the project, in database rather
than text form.
n paint-app.rsrc—an optional resource file. Use ResEdit or another resource
editor to change its contents. There may be no resource file, or many; they
need not be in the project folder.
n paint-app.dl—the project library file.
n _Compiler Results Database—all compiled objects for the project.
n _Library Model—equivalent to the compiler results database, but for
libraries. Created by Create Library.
n paint-app (the executable file)—the standalone application itself, which
can be double-clicked in the Finder to run paint-app.
Under normal circumstances you never do anything directly with any of these
documents. The main reason to mention them is to point out that you have the
option, in the case of a severe need for disk space, of deleting _Compiler
Results Database and _Library Model. These documents are created when you
compile your project and thus can be replaced. The document _Source
Database cannot be replaced.
Note that these two files, _Compiler Results Database and _Library Model,
grow along with your project but do not shrink along with it. As you
repeatedly compile, old compiler results are not eliminated, but simply cut off
from access. You may find it valuable from time to time to issue the command
Compact Project to perform a garbage collection on these files.
You open a project using the Open command on the File menu. When you do,
you see an Open Project dialog box like this, giving you status as the project is
being opened:
Only the active project can be browsed completely. Only one project, the root
project, can be active at one time, although all subprojects contained within
that project are also active. No other project, open or closed, is active. The first
project you open is the active project, but you can change active projects with
the Activate Project command from the Project menu. If you close an active
project, the project opened next becomes the active project.
Other open projects are inactive. You can browse the text portions of these
projects, but you cannot browse any relationships that depend on compiler
results. The source records of an inactive project can be edited and saved. You
can also cut and paste between active and inactive projects. Changed text in an
inactive project is marked as uncompiled when it is changed, but you cannot
compile it until you make it the active project.
Only the active project and its subprojects can be fully browsed. You could
think of the development environment as an interface to the compiler results
database. In other words, all information displayed by a browser depicts what
has actually been compiled. For instance, the call graphers and class graphers
depict calling or class structures that have been successfully compiled, not
what has been incorrectly written in the code and won’t compile. The same
goes for all cross-references, debug information, or other relationships in the
project. Keep in mind, you are working directly on your application or library,
not a representation of it.
Because each source record is a definition, individual definitions can be edited,
and compiled without disturbing the rest of the program. Thus, in compilation,
only modified definitions are compiled. This incremental compilation means
that you can interactively change the active project with a very short compile
time.
Note
The changes you make in the active project are not
reflected in the compiler results database until you compile
them. Therefore, many browsers do not reflect the changes
until you compile.
▲ WARNING
Since the compiler does not lock files, you are not
prevented from editing while compiling. However, you
absolutely should not do this. You should also not browse
while compiling.
Application or library? 2
Every project must have certain characteristics established, depending on
whether it is an application or a library. This is done through the Set Project
Type command from the Project menu. You can also use this command to
examine the characteristics of any project.
Internally, applications and libraries are identical, with the single exception that
an application includes a startup function. This means that an application can
be started and achieve some end result. A library does nothing by itself and
must be used as a building block of an application
For the sample project paint-app, you see the following dialog box when you
choose Set Project Type from the Project menu:
Set Project Type allows you to specify a version and a minimum compatible
version for each library.
Setting the version of a library controls which version is recorded in the
compiler results database. When a library file is created from a project, the
library versions of all of its subprojects are recorded in the library file header.
Then at runtime, when the library is loaded, it will only accept those versions
of the sublibraries that are compatible with the version of the sublibrary used
at library creation time.
The minimum compatible version is the lowest version that a library is
backward compatible with. The Min Version field is checked during runtime
library search.
For example, suppose library A uses library B, and at the time the library file
for A is built, library B was at version 17. Later, at runtime, when library A is
being loaded, it will look for library B, version 17.
n If it finds an instance of library B that has version 17, that version is used.
n If it finds an instance of library B that has version 16, that version is not
used.
n If it finds an instance of library B that has version 19, and the minimum
version is 17 or less, that version is used, because even though that library
has a later version, it claims to be backward compatible with version 17.
n If it finds an instance of library B that has version 19 and a minimum
version of 18 or more, that version is not used, because that library is not
compatible with version 17.
n If it finds more than one instance of library B which is compatible with
version 17, it picks one at random.
If library B version 17 had a minimum version of 16 at the time Library A was
built, it might seem that version 16 of Library B could be used, but it doesn’t
work that way. If library B has version 17 and minimum version 16, that means
only that version 17 is backward compatible with version 16. Thus, version 17
could be used where version 16 was expected. However, it doesn't mean that
version 16 is compatible with version 17. Library A could be using some new
features of library B version 17 that weren't in B version 16. Thus, version 16
cannot be used for libraries built on version 17, even if the minimum version is
16 or less.
Note
In other words, there is no way to specify that a library is
backward compatible.
Note
Launch Application Nub does not run the project!
Tether to Application has only a single effect:
n Establishes communication between the development environment and a
running standalone application or the Application Nub.
Note
The standalone application must already be running when
you issue this command! You also must have the compiler
results database for the standalone application.
You have the option on the Environment page of the Preferences dialog box
from the Edit menu, to automatically launch the Application Nub when you
make a project active. You also have the option of performing an Update
Project whenever a project is launched. These options are off by default and
independent of each other.
You are not limited to using the Application Nub supplied with Apple Dylan.
You may also add to it to create a custom Application Nub of your own. This
enables you to include object libraries from other languages or other resources
from outside the domain of the Dylan language, such as Creole files.
Note
Keep in mind that compiler results are saved to the
compiler results database each time you compile anything,
but the source database only changes when a source record
or the active project is explicitly saved with the Save or
Save All command, respectively.
Note
You can also eliminate an orphan definition by using an
Inspector to inspect the function and using the Inspector’s
remove command. However, this can lead to the reverse
situation, also confusing, where you have an object defined
in the source and compiler results databases that is not
present in the runtime.
The best information on whether your databases are synchronized comes from
the status indicators. At the left edge of each pane you can see a vertical gray
stripe, sometimes with tiny squares in it. This is the status indicator bar. You
can choose which kinds of status the bar shows for each pane, or whether it
shows anything at all.
Choose which status indicators you want active for each pane by selecting the
pane and then choosing Status Indicators from the Browse menu or by
double-clicking on the status indicator bar. The Status Indicators dialog box
opens. The more status indicators you choose from it, the wider the status
indicator bar in the pane. The status indicators you can choose are:
n Unsaved—blue square: the object or its contents have changed since the
last time it was saved or it has never been saved. You clear the indicator
by saving.
n Uncompiled—green square: the object or its contents include source code
that has changed since the last compilation or has never been compiled.
You clear the indicator by compiling.
n Warnings—orange square: when the object or its contents were compiled,
the compilation resulted in warnings. You clear the indicator by fixing the
problem and recompiling, if it’s a compilation warning.
n Read Only—red square: the object or its contents cannot be changed. You
cannot turn the read-only attribute off or on from within the development
environment; it is set by other applications.
n Other—dark gray square: the composite category of unchosen indicators.
If Other is the only status indicator chosen for the pane, then any object
that is unsaved, uncompiled, has warnings, or is read-only will be flagged
with the Other indicator. If Other is chosen along with one or more other
status indicators, then Other stands for the unchosen indicators. If all
other indicators are chosen, Other is not listed on the Status Indicators
dialog box.
The status indicators appear in the order named, with Unsaved farthest to the
left and Other farthest to the right. The status indicators are color coded as
noted. If you click on a status indicator in a pane, the Prompt Area at the
bottom of the browser identifies it. If the indicator is Other, the Prompt area
shows the current definition of Other.
You can also see the squares representing status indicators in the header of a
pane, if you choose. These show the status of the basis of the pane.
Restoring synchronization 2
While browsers allow you to look at the compiler results database and the
source database, the Listener allows you to interact directly with the runtime.
Inspector windows allow you to look at objects in the runtime. See the section
“Inspector windows” on page 116 for more information.
The Listener title bar includes “(Unconnected)” when the development
environment is not tethered to the Application Nub. Once you have launched
the Application Nub (or tethered to a running standalone application), the
Apple Dylan Listener is connected to the Application Nub and is, therefore,
available. The Listener allows you to interact with the application as it runs. In
fact, you can run an application by executing its startup function in the Listener.
Note
If the Listener prints no returned values, or prints only
warnings for syntax errors, you are not tethered to the
runtime.
By having the Listener open as you program, its feedback from listening to
your actions helps you monitor your progress. You can enter any Dylan
expressions into the Listener for immediate execution. For example, you can
call functions in the Listener (including your application’s startup function),
and you can define functions, variables, and classes in the Listener.
The Listener is useful for quickly testing expressions without creating
containers to hold them. In addition, the Listener provides access to parts of
your application that you cannot access any other way, such as data stored in a
database or off a hash table. The Listener is inherently temporary, similar to a
scratch pad. If you wish to make permanent changes in your project, you
should do so in a browser, saving, compiling, and downloading the changes
from there.
The form typed into the Listener and then compiled, results in zero or more
values when executed. These values are printed in the Listener, one per line.
For example, executing values () results in no values, so none are printed.
Executing 1 + 2 results in 3, which is printed on the next line. Executing
values (“first” “second”) results in two values that are printed on the next
two lines.
All values returned or any other results are printed to the Listener window for
any code executed by the application or anywhere in the development
environment, even in the browsers. The results of macro expansion are also
printed in the Listener.
You should launch the Application Nub before compiling code from the
Listener. You can do this by using the Launch Application Nub command on
the Project menu. Although you can compile without being tethered to the
runtime, all the compiler does in that case is check the code’s syntax.
Code typed into the Listener is compiled and downloaded to the application
under development. The objects created appear in browsers and behave in
most ways as if they were a permanent part of the project, but they are not.
When you compile and download to the Application Nub from the Listener,
you are creating a definition entity for the object, but you are not creating an
associated source record. Although every object has one or more associated
definition entities, definition entities created in this way are temporary, lasting
only as long as you remain tethered to the runtime. They disappear when you
untether. The Listener listens, but does not remember. The Listener is not a
browser. When you code in the Listener, you must use the editing tools to
move useful source text into a source record in a browser to make it permanent.
See the section “Orphan definitions in the runtime” on page 111 for more
information.
▲ WARNING
Nothing created in the Listener is saved. You should not
create methods and classes in the Listener even though it is
possible to do so. Use the browsers instead; they are
designed for that purpose.
The Listener is a place to test and compile code without permanently
modifying the project. It is useful for ephemeral code testing, for running of
individual functions to see what they do, and for inspecting and changing the
state of the runtime.
Before you type an expression into the Listener, choose the module the
expression is in from the popup list in the lower-left corner of the Listener
window.
▲ WARNING
Failing to choose the proper module in the Listener is
perhaps the single most common and confusing mistake
Apple Dylan users make. Remember, each module is a
namespace and all code is executed in the context of a
module. If you are not in the proper module, you are not
in the proper namespace and the Listener will literally not
know what your are talking about.
You can execute code from the Listener while you are in a break loop, allowing
you to investigate various results. When in a break loop, the Listener’s prompt
changes to the number of the break level on the stack, starting with the first
break loop as number one.
When the Application Nub is not executing code, it is in the Listener loop,
waiting for code to be sent from the development environment. This can be
from compiling something in the development environment by means of one
of the compilation commands or by means of typing code into the Listener. The
effect is the same; the code is executed and the result values are sent back to the
Listener. A break loop is the same as the Listener loop, except that there is code
waiting to be executed that was stopped by an error or Break and is waiting to
be aborted, inspected or resumed. The Listener loop can be thought of as break
level 0 or the null break level. For more information on break loops, see the
section “Debugging a project” on page 146.
The Listener supports three forms of interacting with your project or
application.
n If you observe behavior in your application that you wish to change, you
can enter a Break command to suspend the application while you make
your changes. All state is preserved, including the stack.
n If your application returns an error, it will be suspended and a backtrace
supplied that allows you to determine the exact source of the error.
n If you press command-option-. (command-option-period), the application
is suspended exactly as it is at that moment, without losing any state or
stack information. You are still in the middle of the application and can
see exactly what it is doing.
Inspector windows 2
While browsers allow you to look at the source database and the compiler
results database, and the Listener allows you to interact with the runtime,
inspector windows allow you to look directly at objects in the runtime. To use
inspector windows, you must be tethered to the application and the application
must be suspended.
The inspector windows offer your only opportunity to look directly at objects
in the runtime. In fact, objects only exist in the runtime, and furthermore many
objects in the runtime are created by the running application.
Several commands that open inspector windows are included in Apple Dylan:
n The most common use of inspector windows is through the Listener,
where you can compile, download and execute code, look at the results as
printed in the Listener, and then use the Inspect Listener Result command
to determine exactly what happened.
n After an error, the stack is presented in the form of a backtrace. Use the
Inspect Stack command to inspect the state of the program at the point of
the error.
n You can list all the modules in the Application Nub and select one from
the list to open an inspector window on it using the Inspect Module
Variables command.
n You can also look at your memory allocations and contents using the
Inspect Heaps command.
n Finally, you can select any object and inspect it using the Inspect Selection
command.
You can use inspector windows on any object in the runtime. To do so, you
must know where the object is located, such as a list or vector or other data
structure.
Note
You can open another inspector window from any
inspector window by double-clicking on an object in it.
This can lead to having numerous inspector windows
open at once. If you hold down the Option key while
closing one inspector window, all of them close.
Sometimes you need to forcefully stop the Application Nub itself. If you have
tried the commands Quit Application and Quit Application Nub, yet the
Application Nub’s status indicates it is still running, you might need to run the
Quit Application Nub program from the Finder. You can do this by leaving the
development environment and launching the executable file Quit Application
Nub, which is in the Application Nub folder. The Quit Application Nub
executable’s purpose is to seek out and destroy any Application Nubs that are
running, but it doesn't affect Apple Dylan.
When you cannot quit Apple Dylan itself, using command-period or
command-option-period should stop Apple Dylan so you can use the Quit
command. Usually, using command-shift-escape also lets you exit safely.
However, sometimes this might hang your machine. In case these don’t work,
it might be useful to create an AppleScript program that tells Apple Dylan to
quit. The script is:
You create a library using the Create Library command. This command first
untethers the Application Nub—prompting for confirmation—and then takes
the information in the compiler results database (and associated libraries) and
packages your project as a library that is then written out to a specified location
on the disk.
This completes our walkthrough of the Apple Dylan user model. The rest of
this chapter describes some detailed tasks and examples using the
development environment.
Starting a project 2
When you want to write your own application or library, you create a new
project using the New Project command. The new project will consist of
numerous other objects, most of which you will create. Your project can also
contain subprojects, which are other projects or libraries you include in your
project.
Projects consist of modules which contain source folders. The source folders
contain source records. A source record contains the source code, each source
record being one method, class, variable, constant, macro, generic function,
comment, or top level form. For more information about creating a user
interface for your application, see the book Creating a User Interface in Apple
Dylan.
You can create and open as many projects as you want, but only the active
project can be compiled or browsed. You can designate any open project as the
active project using the Activate Project command. Also, closing the active
project with other projects open makes the next frontmost of the open projects
the active project. It also closes all the active project’s subprojects, if they aren’t
also subprojects in another project that’s still open.
You also use the New Project command to create a new subproject. If the
project you want to use as a subproject already exists, you simply add it to
your project with the Add to Project command on the File menu. When the
project it is included in is not open, the subproject is simply a project again, so
it is best to think of a subproject as a type of project.
When you create modules, source folders, and source records, each will
automatically get its own type of icon. A generic icon is assigned to each object
as you are creating it. When you have completed enough of the object for the
development environment to determine what it is, the appropriate icon for it
appears automatically.
In addition to these objects that are in every project, you can add several others,
if you want, using the Add to Project command on the File menu. The
mac-toolbox subproject is a library containing the Macintosh toolbox calls that
you can add to your project. It is up to you to include any or all of the
individual Macintosh toolbox calls you want to use in your project.
The dylan-framework subproject is a library containing the Apple Dylan
application framework. You must add the framework to your project if you
want to use it. Since the source code for the framework is included in its
subproject, you could modify it if you want. However, this is not a common
practice, nor is it recommended.
Another type of file you can add to your project is a resource file. You must
create whatever resource files you need outside of Apple Dylan using your
favorite resource file editor. The resource file you add to your project will have
the suffix ”.rsrc” and be in the root pane of your project.
If you want to investigate Macintosh toolbox calls, you select a call and choose
the Look Up in Online Reference command. The Macintosh Programmer’s
Toolbox Assistant is launched, if you have purchased it and it is present on
your system. The reference entry for the call is displayed. You can also display
reference entries for the Dylan language and the Apple Dylan extensions to it,
including the framework, by selecting the function and choosing the Look Up
in Online Reference command.
1. Choose New Project from the File menu.
When you enter a name for your new project, you see a new project open
with a three-paned, project browser. The name of the project appears in the
browser’s title bar. Untitled is the default name until you save it with a name.
You do not have to close any open projects when you create a new project.
However, if there are other projects open already, be sure you set the active
project to the project you want to compile. Any open, inactive projects can be
edited, but not compiled or fully browsed. Use the Activate Project
command on the Project menu to make this the active project.
In the root (upper-left) pane are the two default objects, Dylan and
Dylan-user. The Dylan-user module contains an empty source folder and
source record. In the following example, the Dylan-user module has been
selected in the root pane so you can see its default contents.
Name the new project using the Save All command on the File menu.
2. Select the Dylan-user module in the root pane and choose New Module
from the File menu.
Name the module by typing its name into the dialog box. The new module
appears in the root pane below Dylan-user because you selected Dylan-user.
You can create as many modules as you want, but often a single module is
sufficient.
3. Select the new module and then choose New Source Folder from the File
menu.
An empty source folder appears, for which you can type in a name. You can
create as many source folders as you want.
The new source folder has an empty source record in it. When it is newly
created, you can type the name of the new source record next to its icon at
the prompt. When you enter code, the name of the source record is derived
from the text of the code. If you want to rename the source record later, you
must expand it using its disclosure triangle and edit the code.
4. Select the new source folder and then choose New Source Record from the
File menu.
The new source record appears at the end of any existing source records
unless you select a source record prior to creating a new one, then it appears
after the selected source record. You can create as many source records as
you want.
The following figure shows a new source record that has been created in the
“new proj” source folder of the “newproj” module. The new source record is
still unnamed in this example. Because no code has been entered yet, the
new source record is represented by the generic icon.
The following figure shows the source record random-state with its code
partially entered. It has the icon that represents a source record of an
unknown type because not enough code has been entered for the
development environment to decide what it is.
The following figure shows the source record random-state with its method
icon. Notice that the entire contents of the method are not needed for the
development environment to recognize it as a method.
7. Reorder your source folders and source records to reflect the load order
you want.
You can drag the objects around in a pane, just as you would in the Finder.
You can delete objects that you don’t want using the Delete key or the Clear
command on the Edit menu.
8. Before you save your project for the first time, see one of the following
tasks on setting your project type as an application or a library.
Separately loaded libraries save space because you only need one copy of
the common libraries, dylan-framework and mac-toolbox.
Note that Dylan libraries are not shared in RAM, so selecting “Use
separately loaded libraries” doesn’t save RAM. Libraries are loaded when
the application runs, if you check this box. They are also loaded whenever
you issue a Launch Application Nub command in the active project.
The library of the application being written is always bundled with the
application. Only the libraries of subprojects are kept separate.
9. Click Create Fat Binary, if you wish.
A Fat binary includes both native 68K and native PowerPC code. It runs
efficiently on both architectures, but is larger than an application created for
only one architecture. The Fat binary is created when you use the Create
Application command to build your standalone application.
10. Edit the Application Names fields, if you wish.
Change these fields to the name you want your final application to have,
according to the architecture you build it for.
11. Click OK.
Saving a project 2
You save an entire project with the Save All command on the File menu. All the
content in all open projects are saved. If you want to save only parts of a
project, use the Save command.
The Save All command cannot be undone.
1. Bring the project browser to the front, if it’s not already there.
2. Choose Save All from the File menu.
3. If this is the first time you have saved it, give it a name and location.
The suffix “.π” is automatically appended to the name of your project when
it is written to its folder in the Finder. Leave the development environment,
if you wish, and check that its file was created in the proper folder.
environment. Use the Import command on the File menu to add a Dylan text
file to a project. The framework is treated as a subproject by the development
environment.
Not all projects can automatically be used as subprojects, only those whose
project type has been set to “Library” using the Set Project Type command.
1. Make active the project you want to add a subproject to.
You can use the Activate Project command on the Project menu.
2. Make the root pane of the project browser active.
3. Choose Add to Project from the File menu.
If you are connected to the Application Nub, Apple Dylan alerts you that the
Quit Application Nub command will be issued before you can proceed any
further.
4. Choose the file containing the subproject or resource file you want to add.
A dialog box allows you to find the file’s location and choose the file to add.
To add a project as a subproject, choose the project’s file with the “.π” suffix.
An alias to the subproject or resource file is also acceptable.
5. Choose Update Project from the Project menu.
Including C code 2
A C library can be included in a project by adding it using the Add to Project
command on the File menu. You must add an entire C library, you cannot add
individual snippets of C code.
If you want to investigate toolbox calls, select a call and choose the Look Up in
Online Reference command on the Browse menu. The Macintosh
changed to Compile Region. If you have launched the Application Nub, the
Compile Selection command becomes Compile and Download Selection on the
menu.
Besides choosing to compile individual objects, you can choose to compile all
the code changed since your last compilation with the Update Project
command. Using the Recompile command, you can compile your entire
project, regardless of when it was last changed. If you have added subprojects
to your project, you can choose to update and compile them as well.
All these compilation commands compile the selected code and download it to
the Application Nub, if it is tethered to the development environment. The
Application Nub is the small (hence “nub”) essence of an application that
Apple Dylan provides. The Application Nub gives you a jump start on creating
your own application in a project. As you write code in your project and
compile it, it is being added into the Application Nub. When you build your
final application, the Application Nub and your project, which have now
merged, are bundled together and comprise your standalone application or
library.
If you want to exclude some code from being compiled, you can use the
Exclude Source Records command. All comment source records and
commented out code are automatically excluded.
You can use the Apple Dylan Listener for investigating runtime objects. The
Listener is a window with an interface that allows you to receive the results of
your programming efforts or type in expressions to execute. The Listener
reports all return values you get from executing code, even if the code is all in
browsers, not in the Listener.
You can execute an individual expression by typing it in at the Listener prompt.
This allows you to try out ideas without the overhead of creating a source
record in a browser to hold the code. The code executed in the Listener is
downloaded to the Application Nub.
To help you track each object in its development cycle, you can check its status
indicators using the Status Indicators command on the Browse menu. The
status indicators show whether an object has been compiled, saved, has
generated any warnings, or is read-only. Status indicators propagate upward in
the hierarchy of a project, if you set them in each pane of the project browser.
2. Choose Body as the location for your status indicators to be reported, if it’s
not chosen already.
You can choose to have the indicators appear in both the vertical status
indicator bar in the pane (Body), in the pane’s header (Header), or in both
places. Click OK if you changed the location.
3. Edit a source record in the project browser, but don’t save it or compile it.
The Unsaved indicator appears. Notice that the Uncompiled indicator is not
in the pane, even though you haven’t compiled the source record yet. That is
because that status indicator has not been chosen on the Status Indicators
dialog box.
You choose the type of status you want reported from the Show list. To
choose a status indicator, click to its left until a check mark appears. If you
choose all the indicators except Other, an indicator for each appears in your
pane when that status applies.
4. Choose Uncompiled from the Status Indicators dialog box.
The Uncompiled status indicator now appears in the row of indicators in the
pane.
5. Click on the second indicator in the pane and read its type in the prompt
area at the bottom of the browser.
In the following figure, the cursor has been clicked on the Uncompiled
indicator. The name of the indicator appears at the bottom of the browser in
the prompt area. The first indicator in the row is the Unsaved indicator.
The order of indicators is always the same, as is their placement in the
vertical status indicator bar.
6. Select only the Other status indicator in the Status Indicators dialog box,
deselecting all those with check marks.
Notice that the three status indicators have been replaced by Other in the
pane. Click it in the pane and the prompt area at the bottom of the browser
shows you what indicators Other currently represents.
The status indicator Other consolidates any of the unchecked indicators into
a single indicator. By checking only the specific indicators you want to see,
and also checking Other, you can see the specific indicators you want, but
still be informed that other status changes have occurred.
Compiling a selection 2
You can compile a source record by selecting its icon and then choosing
Compile Selection from the Project menu. You can also select one or more
expressions, even commented out code, within a source record and then choose
Compile Region to compile just the selected code. If you have launched the
Application Nub, the commands on the menu are Compile and Download
Selection or Compile and Download Region.
As you edit code, the source database grows. You should use the Compact
Project command to reduce its size when it gets too big. As you compile and
recompile your code using Compile Selection, the compiler results database
also grows; however, it cannot be compacted, so the only way to reduce its size
is to use the Recompile command to build a new compiler results database
from scratch.
You can choose to open the Warnings browser while you are compiling code.
This can be helpful when you want to quickly examine objects that generate
warnings. You can edit the code in the Warnings browser or in the original
pane you were working in.
1. Write or edit a source record in a pane so that it has a syntax error and
won’t compile.
2. Select the icon for the source record.
3. Choose Compile Selection from the Project menu.
You’ll get a warning about the problem.
4. Choose Undo from the Edit menu.
5. Select the revised code within the source record and choose Compile
Region from the Project menu.
When you select code within a source record in a pane, either all of it or
portions of it, the command on the menu is Compile Region.
If you had opened the Warnings browser and edited the code in it, you
could also compile it from there. The original source record in the original
browser would also show the changes made in the Warnings browser.
You can now enter other expressions at the next prompt or you can run any
of them again without recopying them to the prompt by simply clicking the
cursor in the expression and hitting the Enter key.
6. Place the cursor into the expression again and hit the Enter key again.
You can recompile an expression by simply placing the cursor in it and
hitting Enter, you don’t have to copy the code to a new prompt.
7. Place the cursor into the expression again and hit the Return key.
Any expression at a Listener prompt is printed at the next prompt by simply
placing the cursor in the expression and hitting Return. You can then edit it
before hitting the Enter key to compile the revised code.
8. Edit the copied expression and hit the Enter key.
The edited expression is compiled with the return value printed below its
prompt.
You can also run an application by typing its startup function into the
Listener, if you choose the module it’s in from the Listener’s module popup.
To find the startup function for a sample application or other project not
your own, use the Set Project Type command.
4. Click on an Apple Dylan window.
Notice that the cursor is now the watch cursor. This is because puzzle is still
running, although you can’t currently see it. To quit the application from
within Apple Dylan, choose the Quit Application command from the Project
menu. This also quits the Application Nub. To quit just the application, you
must get back to it by choosing Application Nub from the Finder list.
5. Choose Application Nub from the Finder list.
You can now quit the application by choosing its Quit command from its
File menu.
Note
You cannot use Apple Dylan again until you interrupt
your running application. Use Quit within your
application to do this.
Debugging a project 2
You can use the commands on the Debug menu to help you debug your
application while it is running. Many of these commands work in concert with
the Listener and inspector windows, allowing you to inspect runtime objects
and work on performance problems.
You can run code from the Listener even when you have already made an
error. This allows you to try out different ideas that might help you figure out
how to fix the error. Any result printed to the Listener can be investigated
further using the inspector window.
The commands that start with “Inspect” open inspector windows of some kind.
There are several kinds of inspector windows, most of which are accessible
from the Debug menu. Others you open by double-clicking on an object in
another inspector window. For example, in the Listener when code results are
returned, you can inspect those results in an inspector window using the
Inspect Listener Results command. You could then double-click on an object in
the inspector window and open another inspector window with that object as
its basis. You can also select any expression in the Listener and choose Inspect
Selection to inspect it in an inspector window.
The Reset Stack command discards the stack all the way to the top level
without running any of the clean-up code. Because it does not run any clean-up
code, this command is very risky; try the Abort command first. Severe side
effects can result from not running the clean-up code. For example, a file can be
left open with no way to close it or a data structure, such as the Dylan
subproject itself, can be left in a corrupted state.
If your code has errors in it or if you issue several Break commands, the stack
consists of as a series of break loops growing downward from the top level of
the stack. The top level loop is the first loop executed and consists of function
calls growing downward with each new command until an error or break is
encountered. At the break point, you can either resolve the error, execute the
cleanup code, or continue executing new commands, but any new commands
executed are in another break loop, not the top level loop. Within the second
loop another error or break might be encountered, in which case a third break
loop is created. The Reset Stack command discards this entire set of loops and
does not run the cleanup code, while the Abort command discards only the
break loop you are in, executes the cleanup code, and returns you to the next
break loop upward. The following figure shows the relative actions of Abort
and Reset, as well as the Listener prompts that correspond to the break levels.
Listener numbers
at prompt
Top level loop
starts here
fn
(top of stack)
foo
Abort here unwinds
Nothing
bar one break level
Reset here jumps
etc. Error or break directly to top
First
break loop
starts here fee
fi
Abort here unwinds
1
fo one break level
Reset here jumps
fum Error or break directly to top
Second
break loop
starts here do
re
Abort here unwinds
2 one break level
mi
Reset here jumps
fa Error or break directly to top
Third
break loop
starts here
You can execute code from the Listener while you are in a break loop. When
you want to stop debugging and abort the operation, you can use the Abort
command on the Debug menu.
1. Open a project, make it active, and choose Launch Application Nub, if
you haven’t already.
2. Choose the correct module from the Listener module popup.
3. Enter an incorrect expression, such as 3 divided by 0.
Notice that the Listener prompt has changed to the number 1 to indicate that
you are in the first break level.
Inspecting heaps 2
You can inspect heaps with the Inspect Heaps command when you want to
monitor how your application is using memory. The heaps shown in the Heaps
window are a snapshot of all the heaps in the runtime, which are downloaded
with a project or created by it. Macintosh heaps are not reflected in this
window. Those heaps, such as for windows and menus, are created by the
toolbox and are not monitored by the development environment.
There are several types of heaps in Apple Dylan, each for a different type of
object. The heaps are calculated for you. When you select a heap in the top
pane, its contents are displayed in the bottom pane. The top pane is a snapshot
of the heaps taken when the Inspect Heaps command was issued. The bottom
pane is a snapshot of the heap at the time you select the heap from the top
pane. You can issue several Inspect Heaps commands to take snapshots at
different times.
1. Open a project, make it active, and choose Launch Application Nub, if
you haven’t already.
2. Choose Inspect Heaps from the Debug menu.
The Heaps inspector window opens.
3. Select a heap you want more details on from the top pane.
Details about the heap appear at the bottom, including the classes in it, the
number of instances of each class, and their total sizes. You can order the
listing in the bottom pane by clicking the heading you want the list ordered
by. In the following example, the list of classes is ordered by the number of
instances, as is evident by Instances being underlined.
Inspecting modules 2
You inspect modules when you want to see all the module’s variables in the
Application Nub. You use the Inspect Module Variables command on the
Debug menu and choose a module from the list, which opens an inspector
window for it.
1. Open a project, make it active, and choose Launch Application Nub, if
you haven’t already.
2. Choose Inspect Module Variables from the Debug menu.
From the list, choose the module whose variables you want to inspect.
The following figure shows an example of the modules in a project’s
Application Nub.
The module inspector window displays the names, values, and kinds of
variables that are defined in a module, as well as their read/write status. A
menu item in the Commands popup menu toggles between “Show All
Variables” and “Show Exported Variables.”
The module inspector window shows only variables that are actually
created in that module. It does not show variables imported from other
modules, even if they are re-exported from the module being inspected. This
is why, for instance, the inspector doesn’t show any variables in the
Dylan-user module.
Metering expressions 2
You can use the Meter Expression command on the Debug menu when you
want to meter an expression in the runtime. When you type an expression into
the top pane and run it, the generic functions called and classes allocated
during the execution of the expression appear in the panes below. You can open
an inspector window for an object in either of the lower panes by
double-clicking on the object.
You must select the module the expression is in before metering it. You must be
tethered to the development environment for Meter Expression to work.
The total time used and bytes allocated are also calculated in the Meter
Expression window. The first time you call a function it sometimes runs more
slowly than it will normally. If the generic function Dylan.Dylan.finalize
appears on the list, this is the first time an instance of this class has been
created. You should run the expression again for accurate timing.
4. Choose the type of information you want to see for the expression in the
Data field.
Generic function calls that have been inlined are not displayed in the
Generic Function pane. Some built-in classes, such as <list> and
<byte-string>, are not displayed in the Class pane but are counted in the
Allocated bytes field.
To activate the user-interface builder, use the Load UI Builder command on the
Project menu. This loads the builder’s library into the Application Nub and
makes the command Show Interface Builder appear on the Apple menu. Make
sure you have have launched the Application Nub before using the Load UI
Builder command.
You then choose Show Interface Builder from the Apple menu to launch the
builder. This does not quit the development environment, but simply hides it
while you run the builder.
As you create your user interface using the builder, the high-level elements of
your interface, such as windows and menus, are saved by the builder to a
project file. This project file contains the user interface elements as resources,
although it is not a typical resource file. You then add the builder project file to
the development environment project it belongs to.
If you want to use a custom icon for your application, you must create the icon
using an icon editor outside of Apple Dylan. You then simply add the resource
file it is in to your project. If you don’t use a custom icon, the default Macintosh
icon for applications is used.
the builder, the Application Nub in the development environment and your
running application are also quit.
5. Choose Launch Application Nub from the Project menu.
6. Launch the user-interface builder using the Show Interface Builder
command from the Apple menu.
See the book Creating a User Interface in Apple Dylan for information on using
the interface builder.
If you need to debug the standalone application in the future, you can tether to
it and return to the use of all the facilities of the development environment. To
do this, you must have retained the project’s compiler results database file.
1. Make your project the active project, if it’s not.
The Activate Project command from the Project menu allows you to
designate the active project.
2. Choose the Set Project Type command from the Project menu.
You should have set these values already, but you should make sure the
fields are all correct.
3. Click OK.
4. Choose the Create Application command from the Project menu.
5. Click the destination platform for your application.
Building a library 2
You build your final library from your project using the Create Library
command on the Project menu. The Create Library command appears on the
Project menu when you set the project type as a library using the Set Project
Type command.
Before you build a standalone library, you should quit the Application Nub;
you will be prompted to do so in the Set Project Type dialog box. You must also
check that the information about your project is all correct in the Set Project
Type dialog box.
If you need to debug the library in the future, you can tether to it and return to
the use of all the facilities of the development environment. To do this, you
must have retained the project’s compiler results database file.
1. Make your project the active project, if it’s not.
The Activate Project command from the Project menu allows you to
designate the active project.
2. Choose the Set Project Type command from the Project menu.
You should have set these values already, but you should make sure the
fields are all correct.
3. Click OK.
4. Choose the Create Library command from the Project menu.
5. Keep the database files for your project.
To alter your library in the future, you can tether to it, edit the code in the
development environment, and rebuild it as a new application only if you
have at least kept the compiler results database file.
6. Leave Apple Dylan to make sure the file was created.
Sharing code 2
You can share code containers, either source folders or modules, with other
programmers by exporting them as text files, but you cannot share source
records individually. You can save your personal browsers and send other
programmers the browser file. You can also share a user interface by sending
others its resource file, which was generated by the user interface builder.
Remember, you should copy the files you want to share; moving or deleting
Apple Dylan files while not in Apple Dylan can have bad consequences, as
does renaming any folders. The development environment will not be able to
find the object and report it as missing. Missing files need to be found and
identified when the development environment is running or they will just be
ignored during compilations. When they have been identified, the project must
be recompiled and saved. While the development environment is not running,
you can move the entire Apple Dylan folder or a project’s entire folder and it
will be OK.
Sharing projects 2
You can share an entire project with someone by sending them a project’s
folder. You can send them a subproject by sending its project folder. You don’t
have to send them the sources when sending them the project. To use the
project or subproject, they add it to the project they want it in.
1. Save a project if you haven’t.
You send the file it’s saved into.
2. Leave the development environment.
3. Send the project’s file.
Send the entire folder, including the project’s databases, if you want the
other person to be able to alter your project.
However, not every object can be exported and imported without changes.
nA single source record with more than one top-level form or comment is
broken into an individual source record for each top level form or
comment when exported.
nIn addition, if any code within a source folder has the incorrect number of
begins or ends, or is any other way seriously malformed, the source
folder can be exported, but the resulting Dylan text file cannot be
imported.
Importing or exporting has no effect on objects marked for exclusion or
inclusion.
1. Select the object you want to export.
2. Choose Export from the File menu.
Dylan text files have the suffix “.dylan”.
3. Choose the location for the Dylan text file.
The following figure shows a portion of a Dylan text file.
This is the reference chapter for the Apple Dylan development environment.
It includes:
n List of command shortcuts
n Alphabetical list of all commands
File Menu 3
■ New Source Record—Command-N
■ Open—Command-O
■ Close—Command-W
■ Save— Command-S
■ Print— Command-P
■ Quit—Command-Q
Edit Menu 3
■ Undo (Clear, Typing)—Command-Z
■ Redo—Command-Z
■ Cut—Command-X
■ Copy—Command-C
■ Paste—Command-V
■ Select all—Command-A
■ Copy Special
n Argument List—Command-’
n Define Method Template—Command-T
n Class Template—Command-T
■ Insert Special
n Method Template—Command-Option-T
n Class Template—Command-Option-T
n Argument List—Command-Option-’
Text Menu 3
■ Style
n Plain—Command-Shift-T
n Bold—Command-Shift-B
n Italic—Command-Shift-I
n Underline— Command-Shift-U
n Outline—Command-Shift-O
n Shadow—Command-Shift-S
n Condense—Command-Shift-Option-C
n Extend—Command-Shift-E
■ Find and Replace—Command-F
■ Find Again—Command-G
■ Find Selection—Command-H
■ Replace and Find—Command-J
Project Menu 3
■ Run—Command-R
Browse Menu 3
■ Aspect—Command-Option-click on object
■ Show Home—Command-Y
■ Look Up in Online Reference—Command-=
Debug Menu 3
■ Inspect Stack—Command-B
■ Inspect Listener Result—Command-I
■ Expand Macro—Command-M
■ Expand Macro one level—Command-Option-M
■ Break—Command-,
■ Continue—Command-/
■ Abort—Command-;
Command Reference 3
The following list is alphabetized with the commands on the left margin. The
right margin shows the menu the command is on. Menus are altered
dynamically. Not all commands are available in all contexts. For instance,
Launch Application Nub and Quit Application Nub replace each other on the
Project menu.
Abort Debug3
Discards the stack in a break level loop to the next break level upward in the
stack after executing the clean-up code. Because it runs clean-up code, Abort is
usually preferable to Reset Stack, which does not.
See “Debugging a project” on page 146 for a comparison of using Abort and
Reset Stack.
Related command: Reset Stack.
Key shortcut: Command-;
176 Abort
C H A P T E R 3
and the module the Listener is set to are different, the module appears at the
prompt. This is also true if the libraries differ.
Note
Before you type an expression into the Listener, choose the
proper module from the popup list in the lower left corner
of the Listener window.
The current library is shown at the bottom of the Listener window to the right
of the Module popup. When you hold down the mouse on the Module popup,
as shown in the following figure, the modules in the current library appear in
the list above the separator line. When you choose one of these modules, it
becomes the module the Listener uses. The current module and library are
check marked in the popup. Below the separator line are other libraries you can
choose from. If you choose one of the libraries below the separator line, it
becomes the current library and, when you release the mouse, is shown at the
bottom of the Listener window. That library’s modules appear above the
separator line the next time you access the Module popup.
You can also select expressions in the Listener and choose commands from the
Apple Dylan menus. The expression is compiled, linked to the Application
Nub, and executed immediately. The Listener responds by printing its result or
return values on the line following the prompt. The Listener does not save any
code; you must copy the code into a source record to save it.
You can only use the Listener when it is connected to the Application Nub and
your application is running. You can, however, execute code from the Listener
while you are in a break loop, allowing you to investigate various results.
When in a break loop, the Listener’s prompt changes to the number of the
break level on the stack, starting with the first break loop as number one.
The Listener is also useful for quickly testing expressions without creating all
the scaffolding to hold them. In addition, the Listener provides access to parts
of your application that you cannot access any other way, such as data stored in
a database or off a hash table.
Note
To suspend a running application, make it the front
application and type command-option-period. When the
application has stopped you can issue Quit Application
Nub.
The following figure shows the status of an Application Nub that is tethered
and running locally. If the Application Nub were on a second machine, its
status would be Running remotely.
You can then paste these arguments into place in a source record, in a text file,
or in the Listener.
Related commands: Copy Special, Argument List (Insert Special).
See “Editing in Apple Dylan” on page 66.
(view, r)
Argument List (Insert Special) is handy when you are creating a new source
record and you already know the name of the method you want to call. Simply
type its name, select it, and then initiate Argument List (Insert Special).
This command does not replace the selection as the other Insert Special
commands do.
Related commands: Insert Special, Argument List (Copy Special).
See “Editing in Apple Dylan” on page 66.
Aspect Browse3
Displays a list of aspects for an object (or objects). You can change the aspect for
the basis of a pane, thus changing what is displayed in the pane, or simply
display the aspect inline for a selected object.
▲ WARNING
Aspect only works on the active project.
Every object in Apple Dylan has applicable aspects. Aspects express the
relationships between objects in Apple Dylan, such as what calls what, class
relationships, methods, or families of functions. A source record’s aspects, for
example, include its source code and also any warnings that it has generated.
An inheritance tree is an aspect of a class. Many objects, including all the
variables in the active project, have the aspects References To and References
From, and so on.
Key shortcut: Command-option-click on an object or in a pane without
selecting anything.
You can configure the panes in browsers to display various aspects of objects,
either by changing existing browsers or creating new ones. However, Apple
Dylan includes a number of built-in browsers that display many different
aspects. They are on the Browse menu. If you don’t see a built-in browser for
the aspect you are interested in, use this command to change the aspect to what
you want.
When no object in a pane is selected and this command is used, the aspects for
the basis of the pane are displayed. Each browser pane displays the aspect that
is the default aspect of the pane’s basis. If you change the basis of the pane, you
might see another aspect displayed since the new basis might have a different
Aspect 183
C H A P T E R 3
default aspect, but you can also change the aspect by overriding the default
aspect. You do that by choosing another aspect from the list that is displayed
when you use this command.
The name of the default aspect assigned to the object appears on the first line
on the list in parentheses. You cannot change the list of aspects available for an
object or its default aspect. The default aspect also dictates the aspect that is
displayed in a new browser opened after an object is selected.
In the following example, a source record, output-buffer-offset, has been
double-clicked to open a new browser with it as the basis. The source record’s
default aspect, Source Code of +Warnings of, is the aspect on view in the pane,
as is noted in the pane’s header (there are no warnings at the moment, so none
appear, only source code).
The following figure shows the list of aspects available for source records. This
list can be generated by selecting a source record, such as output-buffer-offset,
and then using the Aspect command.
184 Aspect
C H A P T E R 3
From the list of aspects, you can choose another aspect, such as Function
Family. The pane now displays this aspect, as is shown in the following figure.
The basis of the pane remains the same, but the name of the aspect in the
header is changed to Function Family and the function family is shown within
the pane.
If you select an object in a pane and use this command, the aspects for that
object are listed rather than those for the basis of the pane. The list of aspects
displayed is all those aspects that apply to the selected object and only those
aspects. If you select multiple objects, you see the union of aspects for all the
objects. In this case, if an aspect does not apply to one of the multiple objects
selected, you receive a message saying that the aspect is unavailable for that
object.
Aspect 185
C H A P T E R 3
When you expand an object by clicking its disclosure triangle, one aspect of the
object is displayed inline below the name of the object. For instance, source
records expand to reveal their source code right below the name of the source
record. No new pane or browser opens. The aspect revealed is the default
aspect, unless you select another using this command.
For example, in the following figure the source record output-buffer-offset is
expanded inline to show its default aspect, Source Code+Warnings.
In the following figure, the Aspect command has been used to show the
References From aspect for output-buffer-offset inline. Notice that the aspect
listed on the pane’s header is still Contents Of because the basis of the pane, the
source folder stream basics, has not changed.
186 Aspect
C H A P T E R 3
You can also see the list of aspects for a pane’s basis by holding down
command-option while pressing on the name of the pane’s basis in the pane’s
header. The following figure shows the pop-up list for the source folder stream
basics. It was generated by clicking within the right-hand pane without
selecting anything, pressing command-option, and then holding down the
mouse button with the cursor on the name “stream basics” in the pane’s
header. This pop-up list is the same as would be generated by using the Aspect
command on the Browse menu.
If you change the aspect of an object and wish to reset it to the default, choose
Default from the list. You can reset to the default aspects of several objects at
once by selecting all of them and then choosing Default from the list. If you use
Select All and then choose Default, the original default aspects of all browser
panes are restored.
Aspect 187
C H A P T E R 3
The following table shows all possible aspects and the objects to which they
apply. You can create a custom browser pane displaying any aspect of any
object or objects that have that aspect.
Aspect Objects
All Methods of class
All Slots of class
All Subclasses of class
All Superclasses of class
Classes of module, project, source folder
Contents module, project, source folder
Direct Methods of class
Direct Subclass of class
Direct Superclasses of class
Direct Slots of class
Duplicate Definitions of module, project, subproject, source folder
Function Family generic function, method
Functions of container
Modules of project, subproject
References From class, constant, function, interface,
macro, method, slot, top level form,
variable
References To class, constant, function, interface,
macro, method, slot, top level form,
variable, warning
Resource Files of project, subproject
Source Code of class, constant, function, interface,
library, macro, method, module, slot, top
level form, variable
Source Folders module, project, subproject
Source Records module, project, subproject, source folder
Source Records with Warnings project, subproject, module, source folder
continued
188 Aspect
C H A P T E R 3
Aspect Objects
Subprojects project
Text of error
Uncompiled Modules of project, subproject
Uncompiled Source Folders module, project, subproject
Uncompiled Source Records project, subproject, module, source folder
Undefined Variables module, project, subproject, source folder
Unsaved Modules of project, subproject
Unsaved Source Folders module, project, subproject
Unsaved Source Records module, project, subproject, source folder
Variable Definitions of module, project, subproject, source folder
Warnings for Downloaded code of class, constant, function, interface,
macro, method, module, project,
subproject, slot, source folder, top level
form, variable
Warnings of class, constant, function, interface,
macro, method, module, project,
subproject, slot, source folder, top level
form, variable
Warning Source Record of warning
Break Debug3
Stops an application from running without untethering from the development
environment. No state is lost; everything is frozen. The action is the same as if
the code had executed break ().
Key shortcut: Command-,
Break 189
C H A P T E R 3
Break starts a break loop one level greater than the one in which the current
code was executing. You can resume running the application with Continue or
Abort.
Note
Break levels are recursive. This is because inspecting and
altering values is executing code in the Listener. It is
possible for that code to have error or break statements, so
if the new code stops, you enter another break level, which
you can use to debug the code that inspected or altered
values that you ran in the previous break level.
In the figure, the method <random-state> is the basis of the Call Grapher
browser. Therefore, while you can go up and down the graph from
<random-state>, full information is shown only for <random-state>.
Control-click on another object to make it the basis of the browser so you can
see full information on it.
See the task “Using the browser Info for Selected Class” on page 53 for more
information on using grapher panes.
You then select the module the function is in, the name of the function, and the
specializer you want to record. The following figure shows some of the
specializers you could choose for the function “initialize” in the puzzle module.
If you want to record a function and print the results to the Listener, choose
Print Entry and Exit from the Options field. If you want to meter a function,
choose Meter from the Options field.
When you have made your choices, click Record. The results are printed to the
Listener and the recorded function is listed in the Call Recording window.
The Remove button deletes a selected function from the list. The Remove All
button deletes all the functions from this list.
Continue clicking on the left-most arrow until you reach the base class. If you
click on the arrows on the right end of the bars that separate each class, you can
collapse the graph, hiding the superclasses.
Related commands: Call Grapher, Grapher Pane, Info for Selected Class.
See the task “Using the browser Info for Selected Class” on page 53 for more
information on using grapher panes.
You can select several classes at once and then use Class Template (Copy
Special) to create a class that is a subclass of all the selected classes. For
example, if you select the classes <cell> and <cell-view> and then choose Class
Template (Copy Special), you copy the following template to the Clipboard:
define class <foo> (<cell>, <cell-view)
end class;
Note that this command appears in the menu only if you select a class. If you
select a generic function or method, Method Template (Copy Special) appears
instead.
Key shortcut: Command-T
Related Commands: Copy Special, Class Template (Insert Special), Method
Template (Copy Special).
See “Editing in Apple Dylan” on page 66.
end class;
If you want to create a subclass based on a class, simply type its name, select it,
and then initiate Class Template (Insert Special).
This command is made available by pressing Option when clicking on Copy
Special on the Edit menu.
Key shortcut: Command-Option-T
Note
Class Template (Insert Special) creates a subclass based on
a single class. Class Template (Copy Special) creates a
subclass based on one or more classes.
Clear Edit3
Deletes the selected text or object. The deleted text is not copied to the
Clipboard. You can use Undo Clear to reinstate the cleared text. Undo, Clear,
Redo Clear, and Undo Clear replace one another on the File menu, depending
on which is appropriate.
See “Editing in Apple Dylan” on page 66.
Pressing Delete or inserting text when there is a highlighted region present is
the same as doing a Clear.
▲ WARNING
Clear supports Undo and Redo only for text. If you have
cleared an object, folder, or subproject, it cannot be undone
or redone. If you are about to clear a subproject, you are
warned. You cannot clear required subprojects.
Close File3
Closes a browser, window or project. Closing the project window closes the
project and all of its subprojects, unless the subprojects are used in another
project that is still open. You are prompted to save changes, if any. Closing the
active project while unrelated projects are still open makes the next project the
active project. You can close all open windows and browsers except the project
browser by holding down the Option key when you choose Close.
If you have a window active and hold down the Option key when you choose
the Close command, all open windows of the same type, such as browsers or
inspector windows, are closed. However, the project browser is not closed with
the Option-Close command.
Key shortcut: Command-W
Collapse Edit3
Collapses the selected object so you cannot see its contents. You can also
collapse an object by clicking on its disclosure triangle, which is the triangle to
the left of the object’s icon. You can collapse several objects at once by selecting
them and choosing Collapse.
Related command: Expand.
The following figure shows the object “behavior-event” selected and Collapse
about to be chosen.
198 Close
C H A P T E R 3
Color Text
3
Changes the color of the selected source text. This choice changes only the text
in a source record and has no semantic impact but it does flag the record for
recompilation. You can use color to help organize your sources.
Color 199
C H A P T E R 3
To select a source record, select its icon rather than its name or text. You can
select more than one source record. Source record objects are methods, classes,
variables, constants, macros, generic functions, comments, and top level forms.
To compile code within a source record, you can highlight the code you want to
compile, in which case Compile and Download Region replaces Compile and
Download Selection on the menu.
Compile and Download Selection can also compile commented out code if you
select the code within the range of the comment.
In general, Command-E compiles whatever is there to be compiled.
Related commands: Compile and Download Region, Compile Expression,
Compile Region, Recompile, Update Project.
the cursor in the text, the Compile Selection command appears on the menu
instead. In the Listener, if you place the cursor in the text, Compile Expression
appears instead.
Related commands: Compile and Download Region, Compile Expression,
Compile Selection, Recompile, Update Project.
Continue Debug3
Resumes running an application that has been stopped with a Break.
Key shortcut: Command-/
Related command: Break.
Copy Edit3
Copies the selected text (or text of the selected object) to the Clipboard. You can
then use Paste to insert the contents of the Clipboard into a source record or the
Listener.
Key shortcut: Command-C
Related commands: Cut, Paste, Copy Special.
See “Editing in Apple Dylan” on page 66.
Continue 203
C H A P T E R 3
See: Argument List (Copy Special), Class Template (Copy Special), and Method
Template (Copy Special).
Related commands: Insert Special.
See “Editing in Apple Dylan” on page 66.
Note
The Copy Special and Insert Special commands are useful
for getting information as well as for writing code.
204
C H A P T E R 3
Cut Edit3
Deletes the selected text and saves it to the Clipboard.
Key shortcut: Command-X
Related commands: Copy, Paste.
See “Editing in Apple Dylan” on page 66.
Expand Edit3
Expands the selected object so you can see its contents. To expand an object you
click on its icon and then choose Expand. The object’s contents then appear
below its name. You can also expand an object by clicking on its disclosure
triangle, which is the triangle to the left of the object’s icon. You can expand
several objects by selecting their icons and then choosing the Expand command.
Related command: Collapse.
The following figure shows the object “behavior-event” about to be expanded.
Expand 209
C H A P T E R 3
Export File3
Exports the selected source folder from the development environment, along
with everything in the source folder. You cannot export an individual source
record. Export creates a Dylan text file with the suffix “.dylan”.
Not every object can be exported and imported without changes.
n A single source record with more than one top-level form or comment is
broken into an individual source record for each top level form or
comment when exported.
n In addition, if any code within a source folder has the incorrect number of
begins or ends, or is any other way seriously malformed, the source
folder can be exported, but the resulting Dylan text file cannot be
imported.
The exported object is stored in a Dylan text file, which has the suffix “.dylan”.
The Dylan text file has a header. Dylan text files can be edited outside of Apple
Dylan in other word processors or editors and mailed electronically.
Related command: Import.
Importing or exporting has no effect on objects marked for exclusion or
inclusion. Markings remain as they were.
Find/Replace Text
3
Finds and optionally replaces the text you specify in the Find&Replace dialog
box. This command searches through source code only, not the names of
containers, modules, etc. Find/Replace opens the object containing the
specified text. You can choose whether to search the current pane or the entire
project. If you choose to search the entire project, opens a new browser. You
may choose simply to find the text, find and replace one instance of the text, or
find and replace all instances.
Key shortcut: Command-F
See “Editing in Apple Dylan” on page 66.
Export 211
C H A P T E R 3
Font Text
3
Changes the font of the selected source text. This choice changes only the text
in a source record and has no semantic impact, but it does flag the source
record for recompilation. You can use fonts to help organize your sources.
See “Formatting commands” on page 70.
You can change the default font for the Listener and browsers, as well as the
font for editing code, using Preferences.
Full information, such as multiple inheritance, is shown only for the object that
is the basis of the pane. Click on the arrows on the graph to expand and
collapse it.
Only a single relationship is shown for other objects in the pane. Control-click
on another object to make it the basis so you can see full information on it.
Related commands: References To, References From, Call Grapher, Class
Grapher, Info for Selected Class.
See the task “Using the browser Info for Selected Class” on page 53 for more
information on using grapher panes.
Note
The Insert Special and Copy Special commands are useful
for getting information as well as for writing code.
snapshot of the heap at the time you select the heap from the top pane. You can
issue Inspect Heaps repeatedly to take snapshots at different times.
Note
Macintosh heaps are not shown in this window. Macintosh
heaps, such as for windows and menus, are created by the
toolbox and are not monitored by the development
environment.
The following figure shows the heap inspection window with “method”
selected in the top pane.
The gray bars indicate that memory has been allocated but is unused, while the
black bars indicate the memory used. The Mac free and free heaps are always
completely empty and the Mac used heap is always completely full. Memory
moves from the Mac free heap into the Mac used heap, neither of which
contains any Apple Dylan objects nor is under Apple Dylan control. The free
heap is for use by Apple Dylan objects, but has not been allocated yet.
In the example above, two different libraries in the project show up separately.
Library heaps cannot be grown or garbage collected. Libraries are displayed as
subprojects in the project window. Every project has at least one library heap
for the Dylan subproject.
The other heaps contain Apple Dylan objects that have been dynamically
allocated by the application and can be garbage collected. Most instances of
user-defined classes go into the vector heap.
Use this window to find an object you couldn’t find programmatically. If you
double-click on a heap, a window opens listing of all the classes in that heap. If
you then double-click on a class, an inspector window on that class opens. You
can also double-click on a class in the bottom part of the Heaps window to
open an inspector window on a class. See the description of Inspect Stack for
more information on inspector windows.
You can sort each part of the Heaps window by clicking on a column’s name.
For instance, in the figure above, the bottom part is sorted by Instances, which
is indicated by the underlining. The number of instances is always one greater
than the actual number because the prototype instance for the class is included
in this count. The Total Size column is in bytes.
The module inspector window displays the names and values of the variables
that are defined in a module, as well as their read/write status. A menu item in
the Commands popup menu toggles between “Show All Variables” and “Show
Exported Variables.”
Note
The module inspector window shows only variables that
are actually created in that module. It does not show
variables imported from other modules even if they are
re-exported from the module being inspected. This is why,
for instance, the inspector doesn’t show any variables in
the “Dylan” module.
In addition, the inspector window displays the kind of variable it is. Typically,
variables created by “define-class” and some variables with type declarations
are “obj” kind variables, which are slightly smaller than the other kinds.
Kinds of variables:
n blank—a variable that can hold an object or code.
n “obj”—a variable that can hold only objects.
n “jump”—a variable that can hold only code.
n “byte”—a variable that can hold only unboxed bytes.
n “shor”—a variable that can hold only unboxed shorts.
n “long”—a variable that can hold only unboxed longs.
n “doub”—a variable that can hold only unboxed doubles.
n “code”—a variable that can hold only unboxed code.
Double-clicking on a variable in the inspector window opens another inspector
window on the value of the variable.
See the description of Inspect Stack for more information on inspector
windows.
The following figure shows the commands for the top pane of the Stack
window. The commands for the Stack window are Show Home, Inspect
Method, Copy Stack as Text, Compute More Frames, Compute All Frames, and
Hide/Show Internal Frames. These commands apply only to the top pane. The
bottom pane displays the active parameters and local variables for the frame
selected in the top pane, as well as other information.
You can double-click on a frame in the top pane to open a window for editing
the object’s source code. You can press the option key and then double-click to
open an inspector window on a frame’s function. You can double-click on a line
in the bottom pane to open an inspector window for the selected parameter.
The Stack window has seven commands: Show Home, Inspect Method, Copy
Stack as Text, Compute More Frames, Compute All Frames, and Hide/Show
Internal Frames.
Show Home 3
Expands and highlights the home of the selected object. This is the same as the
Show Home on the Browse menu. See Show Home for more information.
Key shortcut: Command-Y, or double-click the stack frame.
Inspect Method 3
Copies the stack as text into the Clipboard so you can print out a copy of the
top frame. Shows only the names of stack frames, not local variables.
The internal frames are listed in the top pane. The internal frames are generally
uninteresting to most programmers and should be set to Hide Internal Frames.
All inspector windows display the selected object and its class. The commands
on inspector windows are Resample, Edit, and a list of commands specific to
the object being inspected. The complete list of these commands include Show/
Hide Slots, Who Uses Object, Show/Hide Disassembly, Edit Definition, Graph
Class, Inspect General Instances, Inspect Direct Instances, and Show/Hide
Elements.
Resample 3
Edit 3
Opens a window where you can edit the text of the object selected in an
inspector window.
Show/Hide Slots 3
Hides and displays the slots of the object shown in the top line of the inspector.
In the following figure the slots are on display and the command to hide them
is about to be chosen.
Opens a windows that lists all the objects that contain a direct reference to the
object. The reference can be a slot that refers to the object or a collection that
contains the object.
The following window is a typical result of Who Uses Object. In this example,
the method error (<condition>…) was selected in the inspector window and
the Who Uses Object was issued.
Show/Hide Disassembly 3
Hides or displays the machine instructions compiled for the inspected function.
The following figure shows disassembly code.
Edit Definition 3
Opens a browser displaying the source code of the function or the class,
whichever is selected.
Graph Class 3
Opens the inspector window Inspect Object of Class, which lists all the objects
whose type is that of the selected class or a subclass of it.
Opens the inspector window Inspect Object of Class, which lists all the objects
whose type is that of the selected class.
Show/Hide Elements 3
that list, you see that no windows or menus appear. You can return to the
development environment by clicking in one of its windows.
The notation “(Unconnected)” disappears from the Listener when the
Application Nub is tethered to the development environment.
See the Environment sheet under Preferences for whether to launch to the
Application Nub automatically when a project is opened. Using Preferences,
you can also choose to automatically issue Update Project before launching the
Application Nub.
You can replace an Application Nub with another by removing the file
Application Nub from your project’s folders and replacing it with another
Application Nub. The development environment searches first in the project
folder and then in the folder Application Nub. You can also use an alias to
another Application Nub as the replacement.
Listener 3
See Apple Dylan Listener.
228 Listener
C H A P T E R 3
Most of the objects on this list are browsers listed on the Browse menu; they are
the same browsers. This list also contains the command New Browser from the
Browse menu. Find in Project and Project are not on the Browse menu. Find in
Project opens a browser with the object you are looking for as its basis. The
Project object is the Project browser for the active project, which is brought to
the front when this object is selected. Browsers appear on this list because their
files are in the subfolder _System Browsers of the Browsers folder in Apple
Dylan.
You cannot delete a browser from this list. To delete a browser, quit the
development environment, find the browser file in the Browser folder _System
Browsers and move it out of the Browsers folder entirely. When you restart the
development environment, the moved browser will no longer be listed.
Generic function calls that have been inlined are not displayed in the Generic
Function pane. You can double-click on a generic function to open an inspector
window on the generic function.
Some built-in classes, such as <list> and <byte-string>, are not displayed in
the Class pane but are counted in the Allocated bytes field. You can
double-click on a class in the Class pane to open an inspector window on the
class. The number of instances of the class are listed in the inspector window.
See Inspect Stack for more information on inspector windows.
Method Template (Copy Special) helps you create new methods, especially if
you are specializing the arguments of a method. For example, if you select the
method floor, Method Template (Special Copy) copies the following template
into the Clipboard:
end method;
If you want to have more than one pane in a browser, you split the pane in two.
Each of the two new panes can also be split, both horizontally and vertically.
You split a pane with its splitter controls; the horizontal splitter control is a
short, horizontal bar just above the scroll bar on the right of a pane. The vertical
splitter control is a short, vertical bar just to the left of the scroll bar at the
bottom on a pane. To split a pane, hold down the mouse on the bar and then
drag the dashed line that appears to wherever you want the pane split.
Another method is to drag the outbox of a pane onto any splitter on any pane.
This splits the pane you drop it in and creates a link to the new pane.
You can close a pane by clicking its close box in the upper-left corner of its
header. The browser remains open as long as you don’t close the only pane in
it. You can resize a pane by dragging its resizing control in its lower-right
corner.
You can change the relative size of panes by dragging the line that separates
two panes. You move the cursor to the separating line until it changes into a
slider cursor, then you hold down the mouse and slide it to where you want
the new separating line to be. For more information on splitting panes and
resizing them, see the task “Customizing browsers” on page 58.
The panes in a browser work together through links. The contents of an object
you select in one pane shows up in another through a link you can create or
change. To see a link’s origin or destination, hold the cursor over the link’s
inbox or outbox (the small arrows at the edges of the header of each pane).
When a link has been established, the arrow turns red.
In the following figure the origin of the incoming link of the lower-left pane is
revealed by holding down the mouse on its inbox. The origin of this incoming
link is root pane for the puzzle project, which is the upper-left pane.
When you split a pane, the original and the new panes are automatically
linked. In the following figure the split is complete, so the outbox of the
original pane on the left and the inbox of the new pane on the right are red. You
can now click on objects in the left pane and they are displayed in the right
pane. Because <puzzle-view> was selected in the original pane, it is displayed
in the new pane.
For more information on using links, see the task “Linking panes and
browsers” on page 34.
Related Command: Save Browser.
Note
The New Module command identifies a module to Apple
Dylan, but you must also identify the module to the
compile. To do this, you must create a source record with a
define module statement or add a use statement to the
current library defined with define library. See “What
goes into a project?” on page 97.
New modules are placed at the end of the list of modules. You can reorder the
modules by dragging them. Changing the module order changes the load
order. In the Dylan language, forward declarations do not create load order
The following figure shows a new source record that has been created for the
puzzle module. The new record appears at the end of the list of other records
by default. If you place the cursor into the name of an existing source record,
the new source record is placed directly after it instead of at the end. Because
the order of the source records within a source folder and the source folders
within a module indicates the load order, you might need to move an object
into its proper place after it’s created. You can reorder the objects by dragging
them.
Open File3
Opens a project. You can also open a project by double-clicking on the project’s
icon from outside Apple Dylan. This launches Apple Dylan if it is not already
running.
Key shortcut: Command-O
You can have several projects open at once, but the first one you open is the
active project. The active project is the only project that can be browsed,
compiled, and downloaded.
You can also open text files with this command.
Paste Edit3
Pastes text from the Clipboard into the current text selection or at the current
cursor location. Text is placed into the Clipboard using Cut and Copy, as well
as by all three of the Copy Special commands.
Key shortcut: Command-V
Related commands: Copy, Copy Title Text, Cut, Copy Special.
See “Editing in Apple Dylan” on page 66.
▲ WARNING
Emacs-style editing commands create a kill ring that may
interact unpredictably with the Clipboard. See “Editing in
Apple Dylan” on page 66.
Open 241
C H A P T E R 3
Preferences Edit3
Opens the Preferences dialog box, which consists of four sheets:
Application Nub
n
Environment
n
Editing
n
Listener
n
The following figure shows the default Application Nub Environment sheet.
Preferences 243
C H A P T E R 3
244 Preferences
C H A P T E R 3
Preferences 245
C H A P T E R 3
Choices are reflected in the text you write or edit, such as source code. Any
code entered before this preference is set remains unaffected. Changing this
font setting only affects new source text.
Preferences on the Editing sheet:
n Default editor font— the font for editing source code. The fonts used for
code entered before setting this are not affected.
n Assign Meta To—assignment of meta key. See “Emacs-style key
commands” on page 72.
n Indent Current Line on—part of auto-indent system. Choose how often
you want the current line checked for “pretty” indentation.
n Indent New Line on Return—extends auto-indent to the next line.
n Auto Display Argument List—Automatically display the argument list.
n Display Warnings with Source—Automatically display warnings with
source code.
The following figure shows the default Preferences sheet for the Listener.
246 Preferences
C H A P T E R 3
Print File3
Displays the standard Macintosh Print dialog box for printing. You can print
the contents of the Apple Dylan Listener or source text from a browser. If
nothing is selected, the entire project is printed.
Key shortcut: Command-P
Related command: Page Setup.
Quit File3
Quits the development environment. You are prompted to save unsaved
changes and prompted to confirm that you wish to quit. Issuing this command
also quits the Application Nub if you are tethered and performs an orderly
shutdown of Apple Dylan.
Key shortcut: Command-Q
247
C H A P T E R 3
Quit Application Nub quits a running application and also untethers the
Application Nub from the development environment (if tethered). Quit
Application Nub is the opposite of Launch Application Nub.
If you encounter difficulty quitting the nub, run the Quit Application Nub
application from the Finder.
Related command: Launch Application Nub.
Recompile Project3
Initiates a complete compilation of the entire project, including, optionally, its
subprojects. All code within the chosen scope is recompiled whether it needs it
or not, regardless of status marking. Recompile throws away all caches and
cleans up all databases.
▲ WARNING
Recompile is of limited value when tethered because it
adds all results of its recompilation to the existing compiler
results database and removes nothing.
Related commands: Compile Expression, Compile Region, Compile Selection.
See also: Create Application, Create Library.
▲ WARNING
Clear supports Undo and Redo only for text. If you have
cleared an object, folder, or subproject, it cannot be undone
or redone. If you are about to clear a subproject, you are
warned. You cannot clear required subprojects.
248 Recompile
C H A P T E R 3
References To Browse3
Operates on the selected class in the active project, method, or variable,
opening a browser that lists all objects making reference to it.
See “Using the browser References To” on page 49.
Related commands: References To (Aspect), References From.
Revert File3
Reverts to the saved version. This command works on either the whole project
or on selected objects. If you select more than one object, the next higher
container and all its contents are reverted. All changes you made since issuing
the last Save or Save All are lost. Revert cannot be undone.
Run Project3
Runs the active project’s startup function after tethering the Application Nub to
the development environment and performing an update. Run performs
different functions depending on the state of your project, but it does compile
all sources marked as uncompiled and downloads the results, just as Update
Project does. It also tethers to the development environment, if needed, and
runs the startup function.
You can designate the active project using Set Project Type. The name and
location of the project’s startup function must have been specified using Set
Project Type or Run will not work.
Key shortcut: Command-R
When you run a project from within Apple Dylan, the user interface for the
application and its menu bar overlay the development environment. The
application’s menu bar can be used to manipulate the application and to quit it.
You can return to Apple Dylan by clicking in one of its windows or choosing
Application Nub from the Finder’s list. If you leave the application running
and return to Apple Dylan, the cursor becomes the watch cursor to remind you
that the application is still running, even though you can no longer see it.
Note
You cannot use Apple Dylan again until you interrupt
your running application. Use Quit within your
application to do this.
Save File3
Saves the sources of the active pane and all the objects it contains. Save cannot
be undone.
Key shortcut: Command-S
Related commands: Save All, Revert.
For saving a new or revised browser configuration, see Save Browser.
252 Save
C H A P T E R 3
You must set certain characteristics of a project before building your final
application or library. After setting a project’s features, you complete the
building process by untethering from the development environment and using
Create Application or Create Library. It is also recommended that you issue a
Recompile command before building your final application or library.
The most important setting is whether the project is an application or library, as
shown in the following figure.
Specify the startup function by entering it in the Startup Function field. Specify
the module your startup function is in with the Module field; this module must
be exported from its library. The Creator Type field holds the creator ID you
want your new application to have. Designate your memory requirements for
suggested and maximum sizes in the spaces provided.
Check “Create Fat Binary” if you want to build a Fat application.
Check “Use separately loaded libraries” if you want the Dylan subproject and
framework subproject not to be bundled with your application. They will not
be included in your project’s link library in the binary, but instead the link
library is loaded in from the extensions folder when the application is run. This
option saves disk space, but not memory. This setting also allows you to revise
and load new libraries for an application without changing the rest of the
application.
Note
If there are multiple objects with the same name, and one
is defined in the current module, you are not presented
with a choice, but rather go immediately to the definition.
Key shortcut: Command-Y
For example, if you are in the Listener and have not been working with a
certain function, you might not have its source record on display. In that case, it
is easy to find the source code using Show Home. To use Show Home, place the
cursor in the name of the function you are interested in, or select it, and then
issue Show Home.
In the following figure you can see the result of clicking on “initialize” in the
Listener and then choosing Show Home; “initialize” is expanded and
highlighted.
The following figure shows the result of clicking on the “text-app” module in
the root pane and then choosing Show Home; a new browser is opened with
text-app as its basis.
name-mapper: identity-name-mapping,
define: {"SystemSevenOrLater"}, // for Gestalt
CFM-library: "InterfaceLib",
import: {"ErrorSound", "Alert", "ParamText"},
// These next two will be null pointers anyway
type: {"SoundUPP" =3D> <machine-pointer>},
type: {"ModalFilterUPP" =3D> <machine-pointer>};
#include "Resources.h",
name-mapper: identity-name-mapping,
define: {"SystemSevenOrLater"}, // for Gestalt
CFM-library: "InterfaceLib",
import: {"OpenResFile"};
end interface;
Size Text
3
Displays a list of font sizes. The size you choose is applied to the selected text.
This choice changes only the text in a source record and has no semantic
impact. but it does flag the record for recompilation. You can use font size to
help organize your sources.
See “Formatting commands” on page 70.
You can change the font sizes for the Listener and Browsers (as well as the
source font size) using Preferences.
258 Size
C H A P T E R 3
class in a pane and display its source records inline. See Aspect and
“Customizing browsers” on page 58 for more information.
The Location field allows you to select where the status indicators will appear,
in the status indicator column (choose Body) or in a pane’s header (choose
Header). You can choose to have them appear in both places if you wish.
The following figure shows a typical project with the Uncompiled indicator
chosen and pointed to in the status indicator column. Note that the cursor is
pointing at the green (second) indicator, which is the Uncompiled indicator.
This causes the name of the indicator to appear in the prompt area at the
bottom of the browser.
The following figure shows a typical project with the Unsaved indicator chosen
and pointed to in the status indicator column. Note that the cursor is pointing
at the blue (first) indicator, which is the Unsaved indicator. It is identified as the
Unsaved indicator in the prompt area at the bottom of the browser.
Style Text
3
Changes the font style of the selected source text. This choice changes only the
text in a source record and has no semantic impact, but it does flag the record
for recompilation. You can use font style to help organize your sources. For
example, it is common to use bold for the name of objects being defined.
The font styles available are Plain, Bold, Italic, Underline, Outline, Shadow,
Condense, and Extend.
Key shortcuts:
■ Plain—Command-Shift-T
■ Bold— Command-Shift-B
■ Italic—Command-Shift-I
■ Underline—Command-Shift-U
■ Outline—Command-Shift-O
■ Shadow—Command-Shift-S
■ Condense—Command-Shift-Option-C
■ Extend—Command-Shift-E
See “Formatting commands” on page 70.
You can change the font styles for the Listener and Browsers (as well as the
source font style) using Preferences.
Note
Remember that a subproject is simply a project that has
been included in another project.
Subprojects (Aspect) is commonly used to customize a browser pane
displaying that aspect of project.
See Aspect and “Customizing browsers” on page 58 for more information.
Style 263
C H A P T E R 3
After you switch architectures, you must use the Update Project command to
refresh the compiler results database and library model files. Otherwise, they
will reflect the state they were in the last time the architecture was switched.
There is no provision in Apple Dylan for automatically using different source
code for the two target machines.
Related commands: Set Project Type, Launch Application Nub, Quit
Application Nub.
Apple Dylan or it may be running on some other system to which you have
access.
The standalone application must be halted before you can use this command.
You can cause it to halt by setting the event-check variable to be your own
method for detecting a break request. For more information on event-check, see
the book Apple Dylan Extensions and Framework Reference.
Here is an example of typical usage: if you get an error while running a
standalone Dylan application, launch Apple Dylan and issue the Tether to
Application command. You can then debug the application.
The notation “(Unconnected)” disappears from the Listener when the project’s
compiler results database file is tethered to the Application Nub.
See “Apple Dylan User Model” on page 95.
Related commands: Create Application, Launch Application Nub, Quit
Application Nub.
Note
Remember a subproject is simply a project that has been
included in another project.
Uncompiled Modules of (Aspect) is commonly used to customize a browser
pane displaying that aspect of a project. See Aspect and “Customizing
browsers” on page 58 for more information.
Undo Edit3
Undoes your last edit.
Key shortcut: Command-Z
Undo, Clear, Redo Clear, and Undo Clear replace one another on the File menu,
depending on which is appropriate.
See “Editing in Apple Dylan” on page 66.
▲ WARNING
Clear supports Undo and Redo only for text. If you have
cleared an object, folder, or subproject, it cannot be undone
or redone. If you are about to clear a subproject, you are
warned. You cannot clear required subprojects.
▲ WARNING
Clear supports Undo and Redo only for text. If you have
cleared an object, folder, or subproject, it cannot be undone
or redone. If you are about to clear a subproject, you are
warned. You cannot clear required subprojects.
Undo 267
C H A P T E R 3
eliminated with this command. Orphan definitions are caused when source
records are created, compiled, and then deleted.
Key shortcut: Command-U
Only the active project can be updated. Use the command Activate Project to
make any open project the active project.
See the Project Interaction sheet under Preferences to choose whether to update
a project automatically when it is opened.
Related commands: Recompile, Revert.
▲ WARNING
This is not a text search, but a search of the compiler
results database. Uncompiled variables and text in
comments will not be found.
Warnings Browse3
Opens the Warnings browser listing any objects in the active project that have
generated warnings. The warnings are included. You can have more than one
Warnings browser open at a time.
The following figure shows a typical Warnings browser.
273
basis − the object that forms the input for a definition entity − the compiled
browser pane. The basis of a pane is representation of an object. In most uses of
displayed in the pane header. Apple Dylan you are looking at the object
as compiled. However, each object has at
browser − a paned window where you
least one definition entity and may have
create and examine Apple Dylan objects.
more, as in the case of a class, which has a
Typically, browsers comprise a set of linked
definition entity for each slot. It is rare that
panes displaying successively finer detail
you will need to work directly with a
about a project or object. For example, the
definition entity, but certain browsers may
default project browser has three panes, the
display them, using the bare icon for that
first showing the libraries and modules in a
kind of object. (See “Orphan definitions in
project, linked to a pane showing the source
the runtime” on page 111, “Apple Dylan
folders in one of those modules, linked to a
Listener” on page 113, and “Using icons in
pane showing the objects in that folder. If
Apple Dylan” on page 88.
you change the selection in any of the first
two panes, the succeeding panes change development environment − the set of
accordingly. See hot link. browsers, commands, and tools that
support programming activities, also called
call tree − the references to an object and
Apple Dylan. The development
references from an object are aspects that
environment can link to any application or
can be combined to create a graphic display
library built with Apple Dylan.
of that object’s calling relationships called a
call tree. download − to move compiled code from
the development environment to the
cold link − See hot link.
application nub. Performed automatically
compiler results database −the database by the development environment as part of
that holds object code, debugging updating, compiling, or recompiling.
information, and other information
Dylan text file − a file that contains a text
generated by the compilation.
version of Dylan source code with the
connected − in the Listener, short for .dylan suffix. Used for representing Dylan
connected to the runtime, which means the source code outside the Apple Dylan
Application Nub is connected to the development environment.
development environment. See tethered.
Dylan-user module − A source module
container − any object that contains other included in all projects. In the simplest
Apple Dylan objects, such as projects, projects, it contains all the code for the
subprojects, modules, and source folders. project. In more complex projects, it
contains the module and library definitions
Creole − feature of Apple Dylan providing
used to structure the rest of the project.
cross-language support, used primarily for
accessing the Macintosh Toolbox and other
existing C libraries.
274
G L O S S A RY
275
G L O S S A RY
kill ring - the means of copying text as you OODL − object oriented dynamic language
edit in Fred. This is analogous to the
open project − a project with a project
Clipboard, but sometimes conflicts with it.
browser available. See active project.
See also Fred.
orphan definition − a definition that exists
launch application nub − start the nub
in the runtime but has no apparent source.
running and tether the development
This can be caused when a source record
environment to the application nub. See
that defines an entity is compiled and then
connected, tethered, runtime.
subsequently renamed or deleted. Another
library − a set of linked modules built in cause is when the definition is defined,
Apple Dylan with the Create Library compiled and downloaded in the Apple
command. Dylan Listener.
Listener − See Apple Dylan Listener. outbox − the arrow at the right of a pane’s
header that represents the output from the
load order − the order of the source records
pane. Whatever is selected in the pane
within a source folder and the order of
drives the context of the next links.
source folders within a module and the
order of modules within a project indicates pane − Each browser consists of one or
the load order. more panes. Each pane has a basis (the
object displayed in the header region) and a
Two-pass compilation eliminates load-order
default aspect (the kind of information
restrictions of the type solved by forward
displayed about the object).
declarations in other languages, but true
load-order dependencies must still be project − an application or library under
addressed. development. The project document has a
suffix of π.
meter expression − to track the use of an
expression. project file − the file in the Finder that
contains pointers into all the documents
module − a namespace for variable names.
that make up a project.
Items can be exported and imported
between modules. Only specifically project browser − browser whose root pane
exported variables are visible outside of has a project as its basis. The default project
their module. Modules are contained in browser has three panes.
projects. Modules contain source folders.
prompt area - See information line.
nub − see application nub.
resource file − a standard Macintosh
object-oriented dynamic language − resource file with the suffix .rsrc. Use
Programming language supporting ResEdit or another resource editor to
self-identifying objects, with automatic change the contents of a resource file.
memory management, dynamic linking,
and incremental development.
276
G L O S S A RY
root project − The active project is source record − the container that holds a
sometimes called the root project because it single piece of source code, usually
makes all its subprojects active as well. representing a single object. Source records
are contained in source folders.
runtime − everything that has been
downloaded to the application nub or that splitter control− splits a pane. The
has been built into an application. When the horizontal splitter control is a short,
development environment is tethered to the horizontal bar just above the scroll bar on
application nub, or to a running the right of a pane. The vertical splitter
application, it is said to be tethered to the control is a short, vertical bar just to the left
runtime. of the scroll bar at the bottom on a pane.
select, selection− Using the mouse, you can status indicator − a small colored square
select modules, source folders, source that appears in a browser pane or its header
records, or text within source records. Most to indicate the status of an item or object.
actions in the Apple Dylan development
status indicator column − the gray bar at
environment depend on what you have
the left of a browser pane where the status
selected. You can create a browser by
indicators appear.
selecting an object and double-clicking it.
You can examine the union of aspects of subproject − a project that has been
several objects by selecting them all. You included in another project.
can compile individual source records or
tethered − short for tethered to the runtime,
portions of source text through selection.
or application nub. To be tethered means
Whatever is selected is highlighted.
that the application nub is running, and
source database − all sources for a project Apple Dylan is connected to it.
are included in this database. This database
unconnected − in the Listener, short for
stores all the source code seen through the
unconnected from the runtime. See runtime.
browsers. See compiler results database.
update − to automatically compile all
source folder − a container within a
uncompiled code and download it to the
module that contains individual source
application nub. The action of the Update
records. Source folders are used primarily
Project command.
for organizing your project, but the order in
which they are listed determines load order. user-interface builder − the portion of the
There is no Dylan language construct development environment that helps you
corresponding to the source folder. create a user interface for an application.
source module − See module.
277
G L O S S A RY
278
Index
279
280
I N D E X
importing 171 D
retrieving by importing 171
sharing 168 Debugging
by exporting 168 projects 146
uncompiled Debug menu
compiling 140 Abort command 176
Cold link 274 Break command 189
Collapse command 198 Call Recording command 191
Color command 199 Continue command 203
Compact Project command 200 Expand Macro command 210
Compilation Inspect Heaps command 216
incremental 275 Inspect Listener Result command 218
Compile and Download Region command 200 Inspect Module Variables command 218
Compile and Download Selection command 200 Inspect Selection command 221
Compile Expression command 201 Meter Expression command 231
Compile Region command 201 Pattern Match Macro command 242
Compiler results database 1, 2, 274 Pattern Match Macro Including Builtin
Compile Selection command 202 command 242
Compiling Reset Stack command 250
code Defaults
excluding 143 setting
including 143 editing 86
from Listener 141 Listener interaction 87
projects 133 Definition entity 274
selections 139 Development environment 274
uncompiled code 140 customizing 83
Container 274 introduction 1, 2
Containers 5 running 8
Contents of (Aspect) command 202 setting preferences 84
Continue command 203 Direct Methods of (Aspect) command 206
Copy command 67, 203 Direct Methods of command 206
Copy Special command 68, 203 Direct Slots of (Aspect) command 206
Copy Title Text command 204 Direct Slots of command 206
Create Application command 204 Direct Subclass of (Aspect) command 207
Create Library command 205 Direct Superclasses of (Aspect) command 207
Creole 274 Disclosure triangles 3
Customizing Duplicate Definitions command 207
browsers 58 Duplicate Definitions of (Aspect) command 208
development environment 83 Dylan text files 274
Cut command 67, 205 exporting 70
importing 70
Dylan-user module 274
281
I N D E X
E Expression 275
Expressions
Editing 66 executing in Listener 5
code 76 metering 156
commands
Emacs-style 66, 72, 76
Macintosh-style 71, 72
setting defaults 86 F
tools 66
Edit menu Fat applications 103
Argument List (Copy Special) command 182 File menu
Argument List (Insert Special) command 182 Add to Project command 177
Class Template (Copy Special) command 195 Close command 198
Class Template (Insert Special) command 196 Export command 211
Clear command 69, 197 Import command 214
Collapse command 198 New Module command 120, 237
Copy command 67, 203 New Project command 238
Copy Special command 68, 203 New Source Folder command 239
Copy Title Text command 204 New Source Record command 239
Cut command 67, 205 New Text Window command 240
Expand command 209 Open command 241
Insert Special command 68, 216 Page Setup command 241
Method Template (Copy Special) Print command 247
command 232 Quit command 247
Method Template (Insert Special) Revert command 251
command 233 Save All command 252
Paste command 67, 241 Save command 252
Preferences command 243 Find Again command 212
Redo Clear command 248 Find command 69
Redo command 69 Find/Replace command 211
Select All command 253 Find Selection command 212
Undo Clear command 267 Font command 212
Undo command 69, 267 Formatting commands
Undo More command 69, 267 Color 70
Emacs 66, 275 Font 70
editing commands 72 Size 70
Exclude Source Records command 208 Style 70
Expand command 209 Framework 275
Expand Macro command 210 adding 131
Export command 211 Fred 72, 275
Exporting 275 kill ring 276
code Function Family (Aspect) command 213
sharing by 168 Function Family command 212
Dylan text files 70 Functions
282
I N D E X
283
I N D E X
M P
Meter Expression command 231 Page Setup command 241
Meter expressions 276 Panes 2, 276
Metering basis 2, 34
expressions 156 disclosure triangles 3
Method Template (Copy Special) command 232 information line 4
Method Template (Insert Special) command 233 Linking 34
Module linking 3
source 277 outbox 276
Modules 276 root 2
inspecting 154 saving objects in 130
Modules of (Aspect) command 234 splitter control 277
Monitoring Paste command 67, 241
individual functions 159 Pattern Match Macro command 242
Pattern Match Macro Including Builtin
command 242
Preferences command 84, 243
N Print command 247
Project browser 276
New Browser command 234 Project files 276
New Module command 120, 237 Project menu
New Project command 238 Activate Project command 176
New Source Folder command 239 Application Nub Info command 181
New Source Record command 239 Compact Project command 200
New Text Window command 240 Compile and Download Region command 200
Compile and Download Selection
command 200
Compile Expression command 201
O Compile Region command 201
Object-oriented dynamic language 276 Compile Selection command 202
Objects Create Application command 204
saving in panes 130 Create Library command 205
OODL 276 Exclude Source Records command 208
Open command 241 Include Source Records command 214
Open project 276 Inspect Stack command 221
Orphan definitions 111, 276 Launch Application Nub command 227
Outbox 276 Load UI Builder command 230
outbox 34 Quit Application command 247
Quit Application Nub command 247
Recompile command 248
Run command 251
Set Project Type command 253
Target architecture command 264
284
I N D E X
285
I N D E X
286
I N D E X
287
T H E A P P L E P U B L I S H I N G S Y S T E M
PRODUCTION MANAGER
Trish Eastman
LEAD WRITER
Linda Kyrnitszke
WRITERS
Sarah Lee Bihlmayer, Tom Parmenter,
Daphne Steck
ILLUSTRATOR
Sandee Karr
PRODUCTION EDITORS
Lorraine Findlay, Alexandra Solinski
SPECIAL THANKS TO
Jeremy Jones, Paige Parsons, Andrew
Shalit