What's amazing about Scheme is that it's small and easy to learn, but still amazingly powerful. Scheme's code-is-data philosophy allows you to invent your own language features. And it's functional.
We'll start with an overview of the language and how code is represented, tinker with some self-modifying code, invent a few of our own language constructs, then show off a few brain-warping control structures.
45. Pwoblem!
(quote (* 7 9))
• Read an expression
• Evaluate the elements
• Invoke the function, replace with result
Friday, January 25, 13
46. Pwoblem!
( λ (* 7 9))
• Read an expression
• Evaluate the elements
• Invoke the function, replace with result
Friday, January 25, 13
47. Pwoblem!
( λ 63)
• Read an expression
• Evaluate the elements
• Invoke the function, replace with result
Friday, January 25, 13
48. Pwoblem!
( λ 63) (* 7 9)
• Read an expression
• Evaluate the elements
• Invoke the function, replace with result
Friday, January 25, 13
49. Macros
• Macros transform expressions
• Given unevaluated arguments
• Return code which replaces the macro
Friday, January 25, 13
50. Macros
(quote (* 7 9))
• Read an expression
• Evaluate the elements
• Invoke the function, replace with result
Friday, January 25, 13
51. Macros
( λ (* 7 9))
• Read an expression
• Evaluate the elements
• Invoke the function, replace with result
Friday, January 25, 13
52. Macros
( λ (* 7 9))
• Read an expression
• Evaluate the elements, but not for macros
• Invoke the function, replace with result
Friday, January 25, 13
53. Macros
?? (* 7 9)
• Read an expression
• Evaluate the elements, but not for macros
• Invoke the macro, and evaluate its result
Friday, January 25, 13