English subtitles

← 05-36 Greetings Solution

dummy description

Get Embed Code
3 Languages

Showing Revision 1 created 05/13/2012 by Amara Bot.

  1. One way to think about this is to remember the rules for function calls.
  2. You take the function body and you evaluate it in the new argument.
  3. So the body of sayhello is print greeting + " " person,
  4. and we already know from seeing it in the interpreter what it's going to print out.
  5. It's going to print out "hello from u.p." "gracie".
  6. Currently I don't see gracie anywhere in this environment.
  7. That suggests that we're definitely going to need to add it.
  8. Another way to get to that is to remember the other rules for constructing environments.
  9. We definitely want to make space for the formal parameters, person,
  10. and put in the value of the actual argument, "gracie".
  11. So now when we go to evaluate greeting, we don't see it here
  12. but we'll go one up and get "hello from u.p."
  13. and we'll try to find person. We see it right here. We get "gracie".
  14. We'll compose them together and print out exactly the same behavior
  15. we saw on the interpreter. This quiz was pretty tricky.
  16. This notion of nested procedures does not come up very often in Python.
  17. But if we want a complete interpreter, one that understands all the nuances of a language,
  18. then we have to handle this.
  19. It's kind of like the subjunctive in a lot of romance languages.
  20. It doesn't come up very often in English; may come up more often than you'd think in other places.