Chapter 15 Flashcards
On what is the imperative language’s design based?
On the von Neumann architecture (efficiency)
On what is functional languages based?
Mathematical functions
What is a functional side effect?
When a function changes a parameter or global variable
What is the problem with functional side effects?
Unknown execution
How do we solve functional side effects?
1: Disallow functional side effect ( no global references in functions. No 2-way parameters)
2: Demand fixed operand evaluation order (Operands are evaluated left to right)
What is the good and bad about disallowing functional side effects (no non-local references)
Good:….. it works
Bad: Inflexible
Bad about a fixed operand evaluation order?
Not so good compiler optimizations
What is referential transparency?
2 expressions are the same and can be substituted without affecting the program
What causes 2 expressions to not be referentially transparent?
Functional side effects occur during evaluation
What is good about referential transparency?
Program semantics are much easier to understand (the program is more predictable)
What is the effects of a language having no variables? ( pure functional languages ) ( only constants)
No global variables
No variables as parameters ( only constants )
What is an advantage of pure functional languages?
They are 100% referentially transparent
What is the problem with imperative languages with regards to purely functional languages?
Variable management is a big concern + complexity ( in imperative languages as purely functional languages only have constants )
What are the Data object categories in LISP?
Only has atoms and lists
What are the 2 types of atoms in LISP?
Symbols + Numeric
What is a List made up of in LISP?
Sequence of atoms and/or sublists
How is Lists stored in LISP?
Single-linked list
How does the syntax of a lambda expression look like?
(lambda (arg1 … argn) expression)
How do you bind a name to a lambda expression in LISP
(funcName ( lambda (arg1 …. argn) expression ))
What type of scoping does scheme have?
Static
Re the any operators or control structures in scheme?
No
What is interactive mode in Scheme?
Code line by line via a interface rather than in a editor
How are Function evaluated in scheme?
parameters = in no particular order ( unless they are functions )
Values of parameters are substituted into the body
Body is evaluated
Last expression evaluated is the value that the function defines
Which primitive numeric functions in scheme can accept multiple parameters?
abs, sqrt and remainder