Introduction to Macros

Introduction to Macros - CS1102: Introduction to Macros...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS1102: Introduction to Macros Kathi Fisler, WPI September 21, 2007 1 The Need to Improve Our Slideshow Language Last we looked at our slideshow package, we were left with an unsettled feeling that we hadnt really created a language. We created a collection of data definitions for programs and an interpreter to process those definitions, but the structures didnt give us something that looked like a conventional programming language. Recall that at the end of the last lecture I explained that we actually HAVE created a language (the hard part, that is), we just hadnt put the cleaner notation on top of it. Today, we want to see what we need to do to handle this final step. As a starting point, lets recall what our current talk programs look like: ( define talk1 ( let ([ intro-slide ( lambda () ( make-slide ...))] [ arith-eg-slide ( lambda () ( make-slide ( format Example a example-index ) ( make-pointlist ( list ( + ( * 2 3) 6) ( + 6 6) 12 ) false )))] [ func-eg-slide ( lambda () ( make-slide ...))] [ summary-slide ( lambda () ( make-slide ...))]) ( make-talk ( list ( make-display intro-slide ) ( make-timecond ( lambda ( time ) ( > 10 time )) ( list ( make-display arith-eg-slide )) empty ) ( make-display func-eg-slide ) ( make-display summary-slide ))) If we wanted to clean up this syntax, what might we want to do? 1. We probably want to get rid of parts of the code that are too Scheme-specific ( lambda , make- from define- structs , etc). 2. We want to get rid of details that the implementation needs, but that dont contribute information about the computation that the programmer wants to perform. For example: The ( lambda () ...) around each slide is annoying. The lambda is definitely Scheme-specific. Furthermore, someone who is writing talks shouldnt have to remember to wrap a lambda around every slide. All of the list commands are annoying. We have to write them even if we have only one item to put in the list. Also, these expose the language implementation to the programmer. The program really isnt self-contained. We use Scheme let to specify the slides, then use the slide names in the actual body of the talk. This isnt a big deal, but it is something we would ideally like to address. 1 Having to write true and false in each pointlist isnt as annoying as the other issues, but it is error-prone and mildly irksome. If someone is writing a program in this language, they have to keep recalling whether true yields a numbered or a bulleted list. In general, details that are extraneous to the program someone wants to write are problematic for two reasons: The programmer might forget to write them down, leading to program errors....
View Full Document

This note was uploaded on 02/06/2008 for the course CS 1102 taught by Professor Fisler during the Fall '07 term at WPI.

Page1 / 7

Introduction to Macros - CS1102: Introduction to Macros...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online