Lecture overview -- Keyboard shortcut: 'u'  Previous page: Optional parameters of Scheme functions (1) -- Keyboard shortcut: 'p'  Next page: Closures -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 2 - Page 41 : 46
Functional Programming in Scheme
Expressions, Types, and Functions
Optional parameters of Scheme functions (2)

  • Observations about optional parameters:

    • The function optional-parameter is a LAML function from the general library

    • The optional parameter idea works well if there is a natural ordering of the relevance of the parameters

      • If parameter n is passed, it is also natural to pass parameter 1 to n-1

    • The idea does not work well if we need to pass optional parameter number n, but not number 1 .. n-1

Keyword parameters is a good alternative to optional parameter lists in case many, 'unordered' parameters need to passed to a function
We have demonstrated how we simulate optional parameter via the 'rest parameter list' mechanism in Scheme. It is also possible to simulate a keyword parameter mechanism. In a LAML context, this is done with respect to the passing of attributes to the HTML mirror functions.