Computer Languages

Snobol4/Spitbol

Introduction.

The names of these languages barely pass as acronyms as the letters have a fairly tortured extraction from their full names - I believe this was in no small part to it's inventors deliberately making fun of all the convoluted acronyms that existed in computer terminology; I don't think anyone has topped this yet:

StriNg Oriented SymBOLic Language

Speedy implementation of Snobol

These are basically the same language, with Spitbol being an implementation of Snobol4 written in macros for portability and speed.

History of SNOBOL / SPITBOL.

SNOBOL4 began its life as just SNOBOL sometime around 1962 at Bell Telephone labs; it was the brainchild of Ralph Griswold, Ivan Polonsky and David Farber. SNOBOL2 came along later with some improvements, followed curiously by SNOBOL4 sometime around 1967. Exactly what became of SNOBOL3, I guess nobody knows as it's rarely mentioned. SPITBOL followed soon after around the start of the 70's. This variant was faster and built around macros to enhance porting to different processors.

The language has perhaps been described aptly not as a High Level Language, but a Very High Level Language. This is readily confirmed by the ease at which it can parse and extract information from text using patterns rather than iterative procedures. Hopefully, this should be apparent from the example code below.

The tasks laid out below are described more fully on the main language page.

Task 1 - Convert a string to "Title Case".

               Define('Title(sentence)alpha,parse')        :(TITLE_END)

    Title      alpha = &ucase &lcase
               parse = span(alpha) . word (break(alpha) | rem) . gap
    nextword   sentence parse =                            :F(RETURN)
               word len(1) . first rem . rest
               titleWord = replace(first, &lcase, &ucase)
    +                      replace(rest,  &ucase, &lcase)
               Title = Title titleWord gap                 :(nextword)
    TITLE_END


               sentence = 'This is SOME text, is it not?'
               titleLine = Title(sentence)
               output = '[in ] ' sentence
               output = '[out] ' titleLine
    END
			

Post-Mortum

The first line defines the function name, Title, with one parameter called sentence and two local variables called alpha and parse. At the end is a go to directive to prevent execution of the code (this is a peculiarity of the way the language works.)

The function starts with the label Title and finishes with the label TITLE_END. alpha is assigned a string comprising all upper and lower case letters, parse is defined as a pattern. The pattern is set to match a run of letters followed by any non-letters, these two groups when matched against some text will be assigned to word and gap respectively.

The line starting nextword performs a pattern match against the text in sentence, the equal sign at the end deleting the matched area from the text as it has now been processed. If the match fails, the function returns.

The following lines split the word into its first letter and remainder, the first letter is converted to uppercase and the rest to lowercase. The converted word and the non-word characters that followed it are then appended to the text of title (the function name is also it's value) and the process is repeated until the pattern no longer matches.

Valid HTML 4.01! Valid CSS!