CS99 Lecture 3 - week of 9/4 Intro - computer languages all have a philosophy - MATLAB (arrays), Java (objects), Maple (symbolics) - knowing philosophy means knowing how to make most of the language Languages - written vs spoken - written has syntax (grammar) and semantics (meaning) - writing an instruction is like writing a sentence Langauge-Elements for Maple - characters (0123456789abcdefg etc) - tokens (things built from characters (think "words")) - token separators (blank spaces) - escape character (characters that don't really form "sentences" -- they issue commands) (? "escapes" to help) Tokens in Maple - used to build command you enter into Maple - things like equations - types: operator name reserved word integer (yes, Maple has no real floats! -- floats are built from integers -- students probably won't care about this for now) punctuation string - separate tokens with token separators (see above) Why bother? - look at many of these elements - also in many other languages - how they work in Maple is very sim to other languages Looking at Operators... - Arithmetic +*-/^ - (skip functional syntax) - precedence (* before +) - associativity (/ before -) - need parentheses! Looking at Names... - purpose: need something to store values usually called variables, but formal name is...err...name - symbols rules: letters, numbers, underscore, not start with number - name = symbol with property of indexing (what's indexing? hmmm...save for later) - protected names -- Maple predefines some names to be used for "popular" things like functions (sin, cos, tan, sqrt, and more) - backquote -- beasatly things can form weird looking names with backquotes (``) not to be confused with forward quotes ('') Looking at Reserved Words... - also called keywords - most languages have them - things that are intrinsic to the language - cannot change meaning because language needs it! (imagine chaos if we really changed the definition of "is") Looking at strings and integers.... - well, not really -- saving that for chapter 4 Statements - each line of code of Maple is like a sentence - Maple "sentences" called statements - end sentences with periods - Maple's statements end with semicolon and colon (semicolon - show output, colon - suppress output) (hard to demonstrate this until lab)