seven name and scope. names in english nouns that refer to specific objects jane spot george w. bush...
TRANSCRIPT
![Page 1: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/1.jpg)
seven
name and scope
![Page 2: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/2.jpg)
Names in English
Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus
![Page 3: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/3.jpg)
Names in Meta
Denote specific objects Constants (numbers, text strings, …)
1.5 “this is a text string” -7
Variables (words) point box ellipse translate rotate
![Page 4: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/4.jpg)
Defining new names in Meta
[define name value]
Tells Meta that name now refers to value Name must be a single word But value can be an arbitrary expression
Has to be executed to take effect If name already has been defined, redefines it to mean
value
Naming is the most basic abstraction mechanism
![Page 5: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/5.jpg)
A box figure
► [group [box 400 400]
[translate [point 100 100]
[box 70 70]]
[translate [point 100 −100]
[box 70 70]]
[translate [point −100 −100]
[box 70 70]]
[translate [point −100 100]
[box 70 70]]]
![Page 6: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/6.jpg)
Simplifying with names
► [define frame [box 400 400]]
► [define little [box 70 70]]
► [group frame
[translate [point 100 100]
little]
[translate [point 100 −100]
little]
[translate [point −100 −100]
little]
[translate [point −100 100]
little]]
![Page 7: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/7.jpg)
Naming the whole thing
► [define frame [box 400 400]]
► [define little [box 70 70]]
► [define figure [group frame
[translate [point 100 100]
little]
[translate [point 100 −100]
little]
[translate [point −100 −100]
little]
[translate [point −100 100]
little]]
![Page 8: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/8.jpg)
A fancier figure
► [define half-figure [scale 0.5 figure]]
► [define fancy-figure [group frame
[translate [point 100 100]
half-figure]
[translate [point 100 −100]
half-figure]
[translate [point −100 −100]
half-figure]
[translate [point −100 100]
half-figure]]
![Page 9: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/9.jpg)
Going overboard
► [define half-fancy [scale 0.5 fancy-figure]]
► [define really-fancy-figure [group frame
[translate [point 100 100]
half-fancy]
[translate [point 100 −100]
half-fancy]
[translate [point −100 −100]
half-fancy]
[translate [point −100 100]
half-fancy]]
![Page 10: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/10.jpg)
The CS mantra
good software design is enlightened laziness
![Page 11: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/11.jpg)
A bad idea
► [define group [scale 0.5 fancy-figure]]
► [define really-fancy-figure [group frame
[translate [point 100 100]
group]
[translate [point 100 −100]
group]
[translate [point −100 −100]
group]
[translate [point −100 100]
group]]
Error: Attempt to call something that wasn't a procedure
►
Now you’re in trouble You have no way of making
new groups!
Names just refer to objects Procedures are objects Redefining a name that had
referred to a procedure Doesn’t destroy the procedure But it can make it
inaccessible Because you have no way to
tell Meta you want to use it
![Page 12: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/12.jpg)
Cerebus the Aardvark (Sim, 1977-2004)
The greatest swordsman in the world is an aardvark. The greatest swordsman in the world is Prime Minister. Give the greatest swordsman in the world all of your gold.
![Page 13: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/13.jpg)
Sentences are shorter with names
Cerebus is the greatest swordsman in the world. Cerebus is Prime Minister. Give Cerebus all your gold.
![Page 14: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/14.jpg)
![Page 15: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/15.jpg)
![Page 16: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/16.jpg)
Or later on in the saga …
Most Holy is the greatest swordsman in the world. Most Holy is Pope. Most Holy will make your nose hairs catch fire if you don’t give Most Holy all your gold. Give Most Holy all your gold.
![Page 17: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/17.jpg)
![Page 18: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/18.jpg)
![Page 19: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/19.jpg)
![Page 20: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/20.jpg)
Cerebus don’t talk too good
Cerebus has learned the value of names
However, he has not learned the value of pronouns
This is how we can tell he’s an rotten, smelly, barbarian
![Page 21: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/21.jpg)
Pronouns are your friend
The aardvark drank too much and threw up on the aardvark
The aardvark drank too much and threw up on himself
Expressions that act as names Limited scope
Only meaning for within a single sentence or a few sentences Can be rebound to have other meanings in other sentences
![Page 22: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/22.jpg)
Local names in Meta
[with name1 = value1
name2 = value2
…
namen = valuen
expression]
Sort of like pronouns in English Name objects, but only inside the expression
that defines them
![Page 23: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/23.jpg)
The fancy figure with local names
► [with frame = [box 400 400] b = [box 70 70] [with g = [group frame [translate [point 100 100] b] [translate [point 100 −100] b] [translate [point −100 −100] b] [translate [point −100 100] b]] [with half = [scale 0.5 figure] [group frame [translate [point 100 100] half] [translate [point 100 −100] half] [translate [point −100 −100] half] [translate [point −100 100] half]]]]]
![Page 24: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/24.jpg)
Local names are your friends
Names are your friends But it’s easy to have two different pieces of code try to use the same
name Group example earlier
Local names Let you control the scope of a name
Reducing the chance of collisions Ensure the definition of the name is near its uses
And so easier to find Allow you to use shorter variable names without getting confused
Less typing Easier to read
![Page 25: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/25.jpg)
Fine points of scoping
[with name1 = value1
name2 = value2 …
namen = valuenexpression]
You can’t use any of the names inside of the values Because they haven’t been defined yet when the values are
computed If there is already a variable with one of the names,
It’s overridden (“shadowed”) by the new name when computing expression
After expression is computed, the old names are reinstated
![Page 26: Seven name and scope. Names in English Nouns that refer to specific objects Jane Spot George W. Bush Exxon Iceland The Unicorn Café Ben and Jerry’s Zeus](https://reader036.vdocuments.net/reader036/viewer/2022062320/56649c945503460f94950bde/html5/thumbnails/26.jpg)
An intentionally confusing example
[+ 1 [with + = ×
[+ 3 2]]
The names +, −, ×, /, etc. are pre-bound to procedures for addition, subtraction, etc.
But you can always override those by redefine’ing them or by shadowing them with new, local names
So the value of the expression above is 7 I.e. 1+3×2, not 1+(3+2)