Lecture 17 – October 24th
Please download xlisp onto your machine from https://users.cs.jmu.edu/adamses/public
when you come into class on Thursday.
10.24.06
CS 430 Notes
Alan Crouch
TEST POSTPONED TILL
TUESDAY OCTOBER, 31st (HALLOWEEN!!!)
EXAM FOR BOTH CLASSES WILL BE IN HHS
1203
Keep up the good work on the discussion board!
Using SPAN and BREAK can be extremely helping in figuring out how to filter and pattern match strings.
SNOBOL doesn’t allow you to go over the amount of characters per line.
SOME THINGS TO KNOW FOR THE TEST
In SNOBOL if you make an assignment and it fails, it won’t tell you unless you ask.
Data Types
Dr.
Adams, Seth and Magnotti get a gold Star
Bobby Clayton
Concatenation has lowest precedence in Snobol.
Snobol hates missing or extra blanks in its statements.
Prolog and Lisp still to be covered.
Exam on Tuesday now.
Snobol value determines data types. The data type chagnes with the value assigned.
Arrays in Snobol are not homogeneous (data types).
wordlist = Array('20') doesn't have any idea what type of data will be stored here, nor does it care.
Pascal indexes (arrays) start wherever they are specified to.
myArray = array[a..n] of integer;
(*is an anonymous array, cannot be passed as a parameter*)
Snobol returns values from a function just like Fortran, by having a value assigned to the function name.
Snobol has no if statements per se. It uses GoTo's based on built-in, (comparison) functions.
Snobol statements end at the end of the line.
Reasons for studying programming languages:
Most important criteria for a language:
Readibility
Simplicity
Orthogonality ~ Hard to grasp.
Control statements
Selection
Iteration
Subprograms
Syntax
Reserved words (none in Fortran, lots in Pascal)
Keywords (lots in Snobol)
Close second: Writability
Third place
(but still dang important) Reliability
Exception Handling
Type checking
Aliasing
Fourth (minor detail here) Cost
Compilation and Interpretation Difference?
Compilation interprets once and can be run many times afterwards.
Interpretation translates every time code is needed to run.
Take a look at the slides for Lecture 2 from the book! It'll be on the exam! (Chapters 1, 3, 5, 6) Grammars, Bindings...
Ran the code below (on left) to see what FORTRAN does when you exceed array bounds
Output is shown (on right)
|
DIMENSION N(5) DO 20 I = 1, 10 N(I) = 27 20 CONTINUE DO 30 I = 1, 12 WRITE (6, 35) N(I) 30 CONTINUE 35 FORMAT (1X, I15) STOP END |
27 27 27 27 27 27 27 27 27 27 2147348480 52558296 |
|
|
Ran this to see what Snobol does when you exceed array bounds
The next box (below) shows the output…
|
wordlist = array(5) wordlist<1> = 'cat' wordlist<2> = 'cat' wordlist<3> = 'cat' wordlist<4> = 'cat' wordlist<5> = 'cat' wordlist<6> = 'cat' :f(haha) wordlist<7> = 'cat' i = 1 again output = wordlist<i> :f(end) i = i + 1 :(again) haha output = ' storage failed ' end |
|
U:\Web\CS430\CODEEX~1\Snobol>snobol4 range.sno SNOBOL4+ Version 2.24. 8087 present. (c) Copyright 1984,1998 Catspaw, Inc., No errors storage failed U:\Web\CS430\CODEEX~1\Snobol> |