SHOW does not show the ORIGIN of an array
A Logo programming environment for Microsoft Windows
Brought to you by:
david_costanzo
In version 8.3.2 these two show the same thing:
show (array 3 0)
{[] [] []}
show (array 3)
{[] [] []}
was expecting
show (array 3 0)
{[] [] []}@0
Otherwise, I don't know a way to write arrays to files, while preserving their ORIGIN information
The Help concerning ARRAY mentions:
FMSLogo has a special syntax for creating arrays and specifying its members at the same time. Arrays are delimited by curly braces and the origin can be optionally specified by appending an @ character after the closing curly brace, followed by the origin. For example, {a b c}@0 creates an array with three items and an origin of 0. PRINT and friends render arrays using the same syntax.
However:
print (array 3 0)
{[] [] []}
This looks like a doc bug to me. UCBLogo 6.2.3 has the same behavior as FMSLogo 8.3.2. The UCBLogo documentation for ARRAY has different wording
This behavior looks intentional in the source code. The output of PRINT and SHOW are intended to be shown to people, not used for preserving a workspace, so they don't show things like backslashes. Brian must have felt that the origin was similarly unimportant, only including it if you're using a workspace printing procedure. From
print.cppDaniel writes:
SAVE, PO, PONS, and similar commands use the origin-preserving code path, so if you save a workspace with a command that's designed for saving workspaces, the origin of array variables will be preserved. If you're writing arrays to a file and you're defining your own file format, you can also include the origin when you print the array with
WORD "@ FIRST :arraythat makes sense.
I have committed [r6152], which documents that PRINT doesn't show an array's origin, or a word's backslashes or vertical bars. The documentation for SHOW still says it mostly behaves like PRINT. This will be included in the manual for FMSLogo 8.5.0.
Related
Commit: [r6152]