four

31
four simple expressions in meta

Upload: jermaine-alford

Post on 31-Dec-2015

24 views

Category:

Documents


0 download

DESCRIPTION

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) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: four

four

simple expressions in meta

Page 2: four

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

Page 3: four

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)

Page 4: four

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”

Page 5: four

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”

Page 6: four

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”

Page 7: four

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”

Page 8: four

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”

Page 9: four

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”

Page 10: four

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”

Page 11: four

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”

Page 12: four

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”

Page 13: four

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

Page 14: four

Referring expressions in meta

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]

Page 15: four

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

Page 16: four

Rectangles

[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]

Page 17: four

hey stupid

don’t you think it’s time you did an example?

Page 18: four

Circles and ellipses

[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]

Page 19: four

Lines

[line start end] Makes a line

from 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]]

Page 20: four

Coordinate system

Positions on the screen described by (x, y) coordinates X: number of pixels to

the right of the “origin” Y: number of pixels down from the “origin”

Coordinates can be negative (system just shifts the image to make them visible)

(0,0)

(100, 33)

(33, 100)

Page 21: four

Groups

[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]]

Page 22: four

hey

how about another example?

Page 23: four

Translate

[translate point object 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]]]

Page 24: four

hey

show them how to handle errors

Page 25: four

that’s everything you need to know for the assignment

but here’s some other stuff you might have fun with

Page 26: four

Scaling

[scale scale-factor object 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]]

Page 27: four

Rotate

[rotate angle object object …]

Rotates contents clockwise angle degrees 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]]

Page 28: four

Paint

[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]]]

Page 29: four

Ink

[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]]]

Page 30: four

Peeking inside the data

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

group

ellipsebox box box

Page 31: four

Data as hierarchy

When we group objects inside groups inside other groups We get a tree-

structured hierarchy Kind of like outlines

And kind of like code

group

translatebox

group

translatebox

group

translatebox

note: translate doesn’t actually

change its arguments – it makes a translate

object