functions are invoked like this: • add(1,2) • add(1,multiply(2,3)) • In Lisp, functions are invoked using prefix notation, like this: • (add 1 (multiply 2 3))
identifiers in other languages, except more liberal: not limited to alphanumeric + underscore • Examples: • + • = • hello-world • * • currentCity • You can assign symbols to any data type
integer, string, or symbol • Doesn’t have the notion of a name, like in other languages • You give a function a name by assigning it to a symbol, just like an integer or string • There is a special function for building functions. It is appropriately called fn.
treated as a function • the rest of the elements are treated as parameters • If one of the elements is another list, it is executed in exactly the same manner and the result is passed to the original function • That’s it.
generate code (using list abstraction) • We could create macros to-do and item that replace our data with whatever code we like • for instance, code that displays the item to the user • The benefit: we don’t have to walk the list! • The compiler will do it for us, invoking the appropriate macros. • All we need to do is create the macros that convert the data to appropriate code