310 likes | 489 Views
four. simple expressions in meta. Data objects. Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures (images) Points (positions within an image) Procedures (programs) Take a set of objects as inputs (arguments)
E N D
four simple expressions in meta
Data objects • Pieces of data in a computer are called objects • Today, we’ll talk about four kinds of objects • Numbers • Pictures (images) • Points (positions within an image) • Procedures (programs) • Take a set of objects as inputs (arguments) • Return another object as a result • Procedures are the most important kind of data in computer science
Referring expressions in English • Phrases that refer to an object or objects • “Robin” • “Rob” • “The TA of this class” • “the grad students of Ian” • “the people in 324” • “France” • “capitalism” • “The sum of 2 and 3” • “The mother of the TA of this class” • We’ll focus on two kinds • Names (“Robin”, “Rob”, “France”, “capitalism”) • Functional expressions (the X of Y)
A deeply nested referring expression • “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” • [the mother of [the mother of [the grandfather of [the father of [the nation of [the mother of [the TA of [this class]]]]]]]] Please forgive the sexist expression “father of the nation”
Meaning follows form • “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” • [the mother of [the mother of [the grandfather of [the father of [the nation of [the mother of [the TA of [this class]]]]]]]] Please forgive the sexist expression “father of the nation”
Meaning follows form • “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” • [the mother of [the mother of [the grandfather of [the father of [the nation of [the mother of [the TA of [this class]]]]]]]] cs 395 Please forgive the sexist expression “father of the nation”
Meaning follows form • “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” • [the mother of [the mother of [the grandfather of [the father of [the nation of [the mother of [the TA of Robin [this class]]]]]]]] cs 395 Please forgive the sexist expression “father of the nation”
Meaning follows form • “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” • [the mother of [the mother of [the grandfather of [the father of [the nation of [the mother of Robin’s mom [the TA of Robin [this class]]]]]]]] cs 395 Please forgive the sexist expression “father of the nation”
Meaning follows form • “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” • [the mother of [the mother of [the grandfather of [the father of [the nation of The United States [the mother of Robin’s mom [the TA of Robin [this class]]]]]]]] cs 395 Please forgive the sexist expression “father of the nation”
Meaning follows form • “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” • [the mother of [the mother of [the grandfather of [the father of George Washington [the nation of The United States [the mother of Robin’s mom [the TA of Robin [this class]]]]]]]] cs 395 Please forgive the sexist expression “father of the nation”
Meaning follows form • “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” • [the mother of [the mother of [the grandfather of George’s grandpa [the father of George Washington [the nation of The United States [the mother of Robin’s mom [the TA of Robin [this class]]]]]]]] cs 395 Please forgive the sexist expression “father of the nation”
Meaning follows form • “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” • [the mother of [the mother of George’s great grandma [the grandfather of George’s grandpa [the father of George Washington [the nation of The United States [the mother of Robin’s mom [the TA of Robin [this class]]]]]]]] cs 395 Please forgive the sexist expression “father of the nation”
Meaning follows form • “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” • [the mother of George’s great great grandma [the mother of George’s great grandma [the grandfather of George’s grandpa [the father of George Washington [the nation of The United States [the mother of Robin’s mom [the TA of Robin [this class]]]]]]]] cs 395
Names(‘robin’, ‘rob’, ‘+’, ‘point’) Aka “variables” Refer directly to objects Constants (fixed names) Numbers Refer to fixed objects(the numbers) Strings “Arbitrary text enclosed in double-quotes” Also refer to fixed objects (the text) Functional expressions Sequences of expressions Separated by spaces (or line breaks) Enclosed in square brackets First expression has to refer to a procedure Example: [point 100 100] Referring expressions in meta
Some functional expressions • [box width height] • A picture of a box with the specified width and height (which must be numbers) • [ellipse width height] • Same, but gives you a curved object instead of a box • [line point point] • A line with the specified endpoints • [point number number] • A point with the specified coordinates
[box width height] Creates a rectangle Centered at (0,0) Width is width Height is height Default coloring Unfilled (interior is left alone) Border drawn in black (which shows up very poorly in these slides) ► [box 200 100] ► Rectangles
hey stupid don’t you think it’s time you did an example?
[ellipse width height] Same, but curved If width and height are the same, you get a circle Otherwise, an ellipse ► [ellipse 200 100] ► [ellipse 100 100] Circles and ellipses
[line start end] Makes a linefrom start to end Start and end are point objects Created using[point x y] Note that: Default is black line 1 pixel wide ► [line [point 0 0] [point 100 100]] ► Lines
Coordinate system (0,0) • Positions on the screen described by (x, y) coordinates • X: number of pixels to the right of the “origin” • Y: number of pixels downfrom the “origin” • Coordinates can be negative (system just shifts the image to make them visible) (100, 33) (33, 100)
[group object object …] Make a composite picture from multiple picture objects Objects can be shapes or other groups ► [group [box 100 100] [box 200 200] [box 300 300] [ellipse 100 100]] ► Groups
hey how about another example?
[translate pointobject object …] Shifts objects so that their (0,0) is now at point Shifting by [point 10 20] moves everything Right 10 pixels Down 20 pixels Also acts like a group, so you can include multiple objects and they’re all shifted ► [group [box 200 200] [translate [point 50 0] [box 100 100]]] ► Translate
hey show them how to handle errors
that’s everything you need to know for the assignment but here’s some other stuff you might have fun with
[scale scale-factorobject object …] Make a composite object from multiple picture objects Also acts like a group, so you can include multiple objects and they’re all scaled ► [box 100 100] ► [scale 2 [box 100 100] [box 10 10]] ► Scaling
[rotate angleobject object …] Rotates contents clockwise angledegrees about the point (0,0) Also acts like a group, so you can include multiple objects and they’re all rotated around (0,0) ► [rotate 45 [box 100 100]] ► Rotate
[paint color objects …] Fills interiors of objects with color, which can be A color object made with [color red green blue] A string (magic color name) A symbol (magic color name) The word: null (no quotes)Turns off filling Also acts like a group, so you can include multiple objects ► [group [box 200 200] [paint “black” [box 100 100]]] ► Paint
[ink pen objects …] [pen color width] Draws the outline of objects with specified pen Pen specifies color and width of line Pen objects can be created with the pen procedure … or you can just specify a color in lieu of a pen Also acts like a group, so you can include multiple objects ► [group [box 200 200] [ink [pen “black” 10] [box 100 100]]] ► Ink
Objects are like web pages Pages can contain links to other pages Different from containing the pages themselves But I can in some sense pass you a whole set of pages by passing you a link to a single page that has links to the others Forming a group is like making a new web page with links to the component objects You can think of the components as “in” the group Or just as “available to” the group Peeking inside the data group box box box ellipse
When we group objects inside groups inside other groups We get a tree-structured hierarchy Kind of like outlines And kind of like code note: translate doesn’t actually change its arguments – it makes a translate object Data as hierarchy group box translate group box translate group box translate