A data type is, just as the name suggests, what kind of data something is.
Each programming language provides some primitive (built in) data types. The primitive types in Snap! are number, text string, Boolean, list, command, reporter, and predicate (but we haven't used the last three as data types yet). You can get a reminder of Snap!'s primitive types from the pull-down menu of the is () a ()?
block (shown right).
Abstract data types (or ADTs) such as "noun phrase" are custom data types that exist only in the mind of the programmer. For example:
noun phrase
(in Lab 1) constructs a data type that joins three text strings from various lists.prepositional phrase
constructs a data type made out of a preposition and a noun phrase.student
constructor.contact
data type.point
constructor to simplify your Draw Shape project.item of
blocks get confusing with lists inside lists.Point
does the same thing as list
!point
abstract data type because it constructs (and reports) the list of assigned inputs (in this case, the x and y coordinates for a point).X coordinate
and Y coordinate
blocks so that the drawing script would have things like point
abstract data type because they each select one component of a point.Make a general block that draws any shape based on a list of coordinates using the constructor and selectors designed by Gamal and Betsy, respectively.
draw shape ()
block works with this new list.draw message ()
block that takes a list of letters as input and uses draw shape ()
several times to draw a message.