Next Previous Up Top Contents Index

6.9 Interacting with an application

6.9.3 Interaction basics using the Dylan playground

The Dylan playground allows you to carry out interactive Dylan programming experiments. The playground is a pre-built Dylan application that you can start from the main window using the Open Playground button (), or with the menu command Tools > Open Playground from any Functional Developer window. The playground has its own project, which also opens when you start it.

1. Start the playground with Tools > Open Playground in any open window.

Upon opening the playground, its project window appears. Then the playground application starts automatically and enters the debugger. The debugger window has a large interaction pane, and no visible stack or source panes. This is the debugger's interaction layout. (We can change the layout to the normal debugging layout with View > Debugging Layout.)

One of the simplest things we can do in the interaction pane is to use it as a desktop calculator.

2. Enter 56 - 24; at the interaction pane prompt.
Make sure to include the terminating semi-colon, and to include spaces between the numbers and the - sign.
? 56 - 24;
=> $0 = 32

?

Here, text entered after the ? represents interaction pane input, and text after the => represents interaction pane output.

Any compilation warnings resulting from typing errors are displayed in the interaction pane itself.

The interaction pane offers a history facility which allows us to refer to previous interaction results. Each value returned by an interactive expression is bound to a name, which we can then use in subsequent expressions. We call these bindings history variables. They are named using a dollar sign ($) suffixed with an integer. To keep the history variable names unique, the integer suffix increments each time a new history variable is created. So far, our one result was assigned to the history variable $0.

We can add the value bound to $0 to itself.

3. Enter $0 + $0; at the interaction pane prompt.
? $0 + $0;
=> $1 = 64

?

This expression produces the expected result of 64 and creates a new history variable, $1, bound to that result.

Note: History variable values are local to the debugger in which they were created, so you cannot refer to a history variable from any other debugger's interaction pane.

We can define new classes and methods interactively simply by entering their definitions.

4. Enter the following definition of <my-class> at the interaction pane prompt.
define class <my-class> (<object>)
    slot my-slot :: <integer>
end class <my-class>;

Note: You can hit Return to format your input in multi-line form where you prefer. (An expression is only evaluated when you hit Return after a semicolon.)

The output in the interaction pane is:

? define class <my-class> (<object>)
    slot my-slot :: <integer>
end class <my-class>;

=> No values 

5. Enter <my-class>; at the interaction pane prompt.
? <my-class>;
=> $2 = {<class>: <my-class>}

?

Return values in the interactor are "live". You can use the shortcut (right-click) menu to perform a variety of useful operations on them.

The Show Contents command allows you to browse the contents of values within the interaction pane itself. What you see depends on the type of the value; with a class, each slot name and slot value is listed. Each slot value is bound to new history variable so you can refer to it in future interactive expressions.

6. Right-click over $2 = {<class>: <my-class>} and choose Show Contents.
=> $2 = {<class>: <my-class>}

? Contents of {<class>: <my-class>}
=> {<class>: <my-class>} is a <class>
    $3 = instance?-iep                : '\<-49>'
    $4 = debug-name                  : "<my-class>"
    $5 = class-implementation-class  : {<implementation-class>}
    $6 = class-subtype-bit           : 0
    $7 = class-module                : {<module>}

?

For the duration of the interactive session with a project, interactively created definitions, objects, and any resultant warnings are layered onto the project's compiler database. During an interactive session, these items will be available in the project window and browser. You can think of them as being like any definition or object, with the exception that they do not come from a source file.

7. Enter define variable *obj* = make(<my-class>); at the interaction pane prompt.
8. In the playground's project window, go to the Definitions page.
9. Expand library dylan-playground and then module dylan-playground.

Three definitions are listed under module dylan-playground: one for *obj*, one for <my-class>, one for the my-slot accessor, one for its getter, and one for the method main. Thus we see two interactively created definitions alongside one definition created at compile time.

Figure 6.5 Interactively created definitions alongside a compile-time definition.

We can also use the interactor to make a GUI window by using the Dylan User Interface Manager (DUIM) capabilities. For example:

1. At the interaction pane prompt, enter:
contain(make(<push-button>,
             label: "Hello World! This is my DUIM window."));

2. The code is compiled and run and a DUIM window opens.

Figure 6.6 Window created interactively with the Dylan User Interface Manager.

For more information about creating GUI interfaces with Functional Developer, see the Building Applications Using DUIM and DUIM Reference manuals.


Getting Started with Functional Developer - 31 MAR 2000

Next Previous Up Top Contents Index