|
|
|
|
|
by brudgers
4101 days ago
|
|
Anybody who knows C should read this thread People who know C are not the primary audience for Learn C the Hard Way. Every programming tutorial aimed at beginning students puts the student on a tricycle, points them toward a cliff, and tells them to peddle as hard as they can. Norvig points out the cliff is always there.[1] Zed Shaw starts 50 lessons away from the edge. How to Design Programs puts the student at a different distance. Instruction for advanced students [working programmers] expects the student to know they are headed for a cliff.[2] The last compound type that we shall consider in this
section is the record type. Records are quite similar to
Pascal records and to C structures (and to
similar features in other programming languages). A
record consists of a finite set of labelled fields, each
with a value of any type (as with tuples, different
fields may have different types). Record values are
written by giving a set of equations of the form l = e,
where l is a label and e is an expression, enclosed
in curly braces. The equation l = e sets the value of
the field labelled l to the value of e. The type of such
a value is a set of pairs of the form l : t where
l is a label and t is a type, also enclosed in curly
braces. The order of the equations and typings is
completely immaterial | components of a record are
identified by their label, rather than their position.
Equality is component-wise: two records are equal if
their corresponding fields (determined by label)
are equal. -- Introduction to Standard ML
[1]: http://norvig.com/21-days.html[2]: http://www-plan.cs.colorado.edu/diwan/class-papers/ML-doc.pd... |
|