snobol4.org: SNOBOL4 with BLOCKS (SNOBOL4B)

The BLOCKS extension was developed by Jim Gimpel while at Bell Labs in the 1970s. A BLOCK is a data type that extends string concatenation to three dimensions.

The extension is described in Blocks a new datatype for SNOBOL4, James F. Gimpel, Communications of the ACM, Volume 15 Issue 6, June 1972, Pages 438-447.

BLOCKS were originally implemented in SNOBOL4, and then re-implemented in in SIL (the Macro SNOBOL4 SNOBOL Implementation Language).

A manual appears in the Michigan Terminal Service (MTS) SNOBOL in MTS Manual (pdf).

The following program:

* MTS Volume 9 (Sept 1975) p151

        DEFINE('OUTLINE(B,DH,DW)UL,UR,LL,LR')           :(OUTLINE_END)
OUTLINE
        UL = UR = LL = LR = '+'
        B = VER(DH) % HOR(DW) B HOR(DW) % VER(DH)
        B = UL REP('-') UR %
+           IT('|') B IT('|') %
+           LL REP('-') LR
        OUTLINE = FIX(B)                                :(RETURN)
OUTLINE_END

	PRINT(OUTLINE('ABC', 5, 10))

* MTS Volume 9 (Sept 1975) p146
	PRINT(OUTLINE(OUTLINE('ABC', 5, 10),,1))
Produces:
 +-----------------------+
 |                       |
 |                       |
 |                       |
 |                       |
 |                       |
 |          ABC          |
 |                       |
 |                       |
 |                       |
 |                       |
 |                       |
 +-----------------------+

 +---------------------------+
 | +-----------------------+ |
 | |                       | |
 | |                       | |
 | |                       | |
 | |                       | |
 | |                       | |
 | |          ABC          | |
 | |                       | |
 | |                       | |
 | |                       | |
 | |                       | |
 | |                       | |
 | +-----------------------+ |
 +---------------------------+
And this:
        N1 = NODE(OUTLINE('N1',2,4))
        N2 = NODE(OUTLINE('N2',1,2))
        N3 = NODE(OUTLINE('N3',3,1))
        N4 = NODE(OUTLINE('N4',2,8))
        VERT = '|' % '|' % '|'
        B = MERGE(N1 '-----------' N2,
+               N1 % VERT % N3,
+               N2 % REP('|') % N4,
+               N3 REP('-') N4)
        PRINT(B)

Produces this output:

 +----------+
 |          |           +------+
 |          |           |      |
 |    N1    |-----------|  N2  |
 |          |           |      |
 |          |           +------+
 +----------+              |
      |                    |
      |                    |
      |                    |
    +----+                 |
    |    |        +------------------+
    |    |        |                  |
    |    |        |                  |
    | N3 |--------|        N4        |
    |    |        |                  |
    |    |        |                  |
    |    |        +------------------+
    +----+

Phil Budne resurected SNOBOL4B in CSNOBOL4 version 2.0 with files from MTS, supplied by Mike Alexander.

Test programs & reference output.

back to snobol4.org