Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
SNOBOL
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== SNOBOL4 features == {{Original research|date=August 2020}} SNOBOL is distinctive in format and programming style, which are radically different from contemporary procedural languages such as [[Fortran]] and [[ALGOL]]. SNOBOL4 supports a number of built-in [[data type]]s, such as [[integer]]s and limited precision [[real number]]s, [[string (computer science)|strings]], [[pattern matching|pattern]]s, [[Array data type|array]]s, and [[associative array|table]]s (associative arrays), and also allows the programmer to define additional data types and new [[function (programming)|function]]s. SNOBOL4's programmer-defined data type facility was advanced at the time—it is similar to the records of the earlier [[COBOL]] and the later [[Pascal programming language|Pascal]] programming languages. All SNOBOL command lines are of the form :''label subject pattern'' '''=''' ''object'' ''':''' ''transfer'' Each of the five elements is optional. In general, the ''subject'' is matched against the ''pattern''. If the ''object'' is present, any matched portion is replaced by the ''object'' via rules for replacement. The ''transfer'' can be an absolute branch or a conditional branch dependent upon the success or failure of the subject evaluation, the pattern evaluation, the pattern match, the object evaluation or the final assignment. It can also be a transfer to code created and compiled by the program itself during a run. A SNOBOL pattern can be very simple or extremely complex. A simple pattern is just a text string (e.g. "ABCD"), but a complex pattern may be a large structure describing, for example, the complete grammar of a computer language. It is possible to implement a language interpreter in SNOBOL almost directly from a [[Backus–Naur form]] expression of it, with few changes. Creating a macro assembler and an interpreter for a completely theoretical piece of hardware could take as little as a few hundred lines, with a new instruction being added with a single line. Complex SNOBOL patterns can do things that would be impractical or impossible using the more primitive regular expressions used in most other pattern-matching languages. Some of this power derives from the so-called "SPITBOL extensions" (which have since been incorporated in basically all modern implementations of the original SNOBOL 4 language too), although it is possible to achieve the same power without them. Part of this power comes from the side effects that it is possible to produce during the pattern matching operation, including saving numerous intermediate/tentative matching results and the ability to invoke user-written functions during the pattern match which can perform nearly any desired processing, and then influence the ongoing direction the interrupted pattern match takes, or even to indeed change the pattern itself during the matching operation. Patterns can be saved like any other first-class data item, and can be concatenated, used within other patterns, and used to create very complex and sophisticated pattern expressions. It is possible to write, for example, a SNOBOL4 pattern which matches "a complete name and international postal mailing address", which is well beyond anything that is practical to even attempt using regular expressions. SNOBOL4 pattern-matching uses a backtracking algorithm similar to that used in the [[logic programming]] language [[Prolog]], which provides pattern-like constructs via [[Definite clause grammar|DCG]]s. This algorithm makes it easier to use SNOBOL as a logic programming language than is the case for most languages. SNOBOL stores variables, strings and data structures in a single [[garbage collection (computer science)|garbage-collected]] heap.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
SNOBOL
(section)
Add topic