x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 

Pocket Scheme 1.2

Open Source
LISP like programming language
You must be registered and logged into HPC:Factor in order to contribute to the SCL.

Description

Pocket Scheme is a compact Scheme interpreter for Windows CE-powered Handheld and Pocket PCs.

To start Pocket Scheme on the Handheld PC, double-tap on the desktop shortcut.
Back Next
Basic Usage

Pocket Scheme operates using the traditional read-evaluate-print loop of LISP and Scheme environments.

To evaluate a Scheme expression, enter it in the lower pane of the main window and issue the Scheme - Evaluate command, or tap the green lambda on the toolbar. Pocket Scheme will print the results of evaluating the expression in the upper pane of the main window.

You may also load expressions from a file, using either the File - Load... menu command or the Scheme procedures load or require. Pocket Scheme accepts both Unicode and ANSI sourcefiles. To create a Scheme file, use the Pocket Scheme Editor, or any other editor that can save a file as plain text.

To pause a running program momentarily, issue the Scheme - Pause command. To resume a paused program, issue Scheme - Pause again. To stop a running program, use the Scheme - Break command.

You may end your session with Pocket Scheme at any time via either the close box, the File - Exit command, or the Scheme procedure quit.

Most commonly used commands have convenient shortcuts on the command bar or keyboard.
Back Next
Entering Expressions

Pocket Scheme displays its data in two panes: a lower pane of editable text, used to input expressions into the interpreter, and an upper, read-only pane that displays the results of evaluating expressions. The Edit menu supports standard clipboard operations on each pane.

Use the View - Change Focus command to toggle keyboard focus between panes. The other commands on the the View menu adjust the panes' font sizes and positions for easier reading.

Pocket Scheme offers simple parenthesis matching to assist in the input of complex S-expressions. The Edit - Match Parenthesis command will move the input cursor to the parenthesis that matches the closest parenthesis; Edit - Select Parenthesis does the same, but also selects the delimited S-expression. (Please note that neither function will work if the current selection is within a literal string constant.)

The Edit - History commands put previously entered expressions into the lower pane. Use the green arrows on the toolbar to scroll through this history.
Back Next
Performance

The number of display calls that a Pocket Scheme program makes typically constrains its running speed. Eliminate all extraneous displayed information to increase program speed.

Escape continuations (bound by call/ec) are cheaper and faster than reentrant continuations (bound by call/cc). Use them wherever you want a nonlocal exit.
Back Next
Pocket Scheme Editor

Pocket Scheme includes a simple text editor, which you can use to compose or edit small .scm and .smd files.

Double-tap on the icon of a .scm file to open that file in the Pocket Scheme Editor. Note that double-tapping a .smd file will instead execute that file's contents - hence the exclamation point on the .smd icon. To edit a .smd file, run the editor from its desktop shortcut, then open the file via File - Open.

The Pocket Scheme Editor can balance parentheses in the same manner as Pocket Scheme, and can indent or unindent blocks of text. In most other aspects it resembles Windows Notepad.

The View - Indentation dialog specifies how Pocket Scheme Editor will format typed expressions. Set Indent automatically to have the editor position the cursor correctly for each new line.

Use the File - Unicode switch to control whether the editor will save the current buffer in Unicode format.
Back Next
Debugging

The procedures trace and untrace implement call-tracing for user-defined functions. trace shadows a function with a shell that reports every call to and return from that function, while untrace removes the shadow from a function. Warning: calls to a traced procedure are no longer tail-recursive, even in tail position.

Printing call traces will greatly slow a program. To increase the speed of a deeply recursive traced procedure, hide the output window, either by tapping the taskbar rectangle to send Pocket Scheme to the background, or by tapping the little desktop box to bring the desktop to the foreground.

The procedure debug activates callstacks, a listing of pending procedure calls that Pocket Scheme will display when stopping with an error. For best performance, always leave this feature disabled (the default). Once code stops with an error, enable callstacks via (debug #t), then reevaluate the offending expression.

The procedure gc-verbose instructs the garbage collector whether to report its activity. Again, for best performance, always leave this feature disabled (the default). Enabling it via (gc-verbose #t) results in a pop-up window periodically appearing whenever Pocket Scheme recycles unused memory. The procedures gc-stats and gc-reset-stats are also useful to this end.

Note: Scheme - Break returns control to the topmost environment. It does not leave the user in the context of the interrupted evaluation, as the name might imply.
Back Next
Scripting

In much the same fashion that a MS-DOS PC can run .BAT files via COMMAND.COM, or a Unix workstation can run shell scripts via /bin/sh, the H/PC can run Scheme scripts via Pocket Scheme.

To run a script, open it from the Explorer. Pocket Scheme recognizes any file ending in the suffix .smd as its own, and will attempt to run the contents of that file as a Scheme program. See the description of the /r command line switch for an explanation of this mechanism. Note that double-tapping the icon of a .scm file will instead open that file in the Pocket Scheme Editor.

The following script, when run, will count the number of ways to change a U.S. one dollar bill into coins.

(define us-currency '(50 25 10 5 1))
(define (count-coins am c)
(cond
((= am 0) 1)
((or (< am 0) (null? c)) 0)
(else
(+ (count-coins (- am (car c)) c)
(count-coins am (cdr c))))))

(display "Counting coins...")
(newline)
(count-coins 100 us-currency)

If the command line passes any arguments after the mandatory /r scriptname.smd, a script can access those arguments through its *argv* global. E.g., the invocation pscheme.exe /r "\My Documents\mail.smd" root@x.com would run the Scheme program \My Documents\mail.smd, setting the global symbol *argv* to the list ("\\My Documents\\mail.smd" "root@x.com").

By default, a script that stops with an error leaves Scheme in interactive mode, while a script that completes successfully closes the Scheme window when finished. A script may issue (reset) to leave Scheme in interactive mode, or (quit) to force Scheme to quit.
Back Next
Configuration

The Scheme/Configure command evokes a dialog used to configure the language interpreter. Leave a field empty to retain the interpreter's default configuration.

Library path defines a directory automatically searched by the procedures require and find-library-file. This defaults to the application installation directory.
Initialization file names a file of definitions to evaluate when first starting Pocket Scheme. If this is a complete pathname, e.g., \My Documents\init.scm, then it will set the current working directory as well. Otherwise the filename is interpreted relative to the installation directory.
Heap page size specifies the number of cons cells in each page of the heap, while limit specifies the maximum amount of memory that the heap may occupy, in Kilobytes (K). Each cell requires 16 bytes of memory. Pocket Scheme initially allocates only the first page of the heap, deferring the others until their need arises.

Any changes made in this dialog will not take effect until the next Scheme session. You must force Pocket Scheme to exit (via Tools - Exit) and restart it rather than dismissing it with the cross button in the upper right-hand corner.
Back Next
Command line switches

The Pocket Scheme executable file, pscheme.exe, accepts a number of command-line switches that change its behavior. Most of these override the settings of Scheme - Configure.

Switch Effect
/! Displays the configuration dialog.
/? Displays information about the program.
/n Suppress the introductory copyright window.
/r scmfile Evaluate every expression in the named file, then close the Scheme window. Pass all subsequent command-line switches and arguments in the *argv* variable. (Use this to implement scripts in Pocket Scheme.)
/i initfile Specifies an initialization file to load at startup. If this is a fully qualified path, this also sets the initial current working directory, which otherwise defaults to the application installation directory.
/d librarypath Overrides the library directory for require. (By default this is \Program Files\Pocket Scheme
/h pagesize[:heaplimit] Heap size, as described under Configuration. Be careful when experimenting with this.
Back Next
Keyboard shortcuts

In both Pocket Scheme and Pocket Scheme Editor:
Press To
Ctrl+H View this Help file
Ctrl+Z Undo last change to lower pane
Ctrl+X Cut selection from lower pane to clipboard
Ctrl+C Copy selection from pane to clipboard
Ctrl+V Paste clipboard to lower pane
Del Clear selection from lower pane
Ctrl+A Select all text in pane
Ctrl+B Jump to matching parenthesis in Eval window
Ctrl+Shift+B Jump to matching parenthesis, selecting the delimited expression

In Pocket Scheme only:
Press To
Ctrl+L Load a Scheme sourcefile
Ctrl+G Evaluate the current buffer
Ctrl+Q Break into a running program
Ctrl+E Toggle keyboard focus between panes
Ctrl+R View previous expression in evaluation history
Ctrl+Shift+R View next expression in evaluation history
Ctrl+S Pause a running program

In Pocket Scheme Editor only:
Press To
Ctrl+O Open a new file
Ctrl+S Save the current file
Ctrl+F Search for a word
Ctrl+Shift+F Search for the next occurrence of the word
Tab Move the cursor one tab stop to the right, inserting spaces
Shift+Tab Move the cursor one tab stop to the left
Ctrl+Tab Shift a block of text one tab stop to the right
Ctrl+Shift+Tab Shift a block of text one tab stop to the left

Installation Instructions

Copy .cab file to handheld and tap on it to install.

Tags

ProgrammingLanguageOpen Sourcelispscheme

   
License Open Source
The program is open source, free and the source code is available on-line.
   
Website http://www.pocketschme.org
Not working? Try this website on the WayBack Machine
   
Popularity 2040
Total Downloads  4
   
Submitted By torch
Submitted On 20 January 2023

Comments

No comments have been submitted against this application. Be the first!

You must be signed-in to post comments in the SCL. Not registered? Join our community.

Software Compatibility List: The SCL is provided for free to the Handheld PC Communty and we do not carry advertising to support our services. If you have found the SCL useful, please consider donating.