diff options
author | Marion <marion.zepf@gmail.com> | 2013-09-20 15:36:50 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-09-20 15:36:50 (GMT) |
commit | a78ae458c2ddc79d3dc3260536de8c93aba33e72 (patch) | |
tree | 74d7e008dd1de39e958ae80a7d2d97baf6fd142a /doc | |
parent | 54a7b3a8bbd72bb44a95a2517b179076a4712580 (diff) |
format documentation about type system
Diffstat (limited to 'doc')
-rw-r--r-- | doc/type-system.md | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/doc/type-system.md b/doc/type-system.md index 9b4a2ed..4615dd1 100644 --- a/doc/type-system.md +++ b/doc/type-system.md @@ -8,19 +8,22 @@ The purpose of the type system is to have a consistent and standardized way of type-checking and type-converting the arguments of blocks. For example, the 'minus' block takes two arguments of type TYPE_NUMBER. But that doesn't mean that only -number blocks can be attached to its argument docks. In fact, colors, -single characters, and numeric strings (like `"-5.2"`) can easily be converted -to numbers. The type system takes care of this. When e.g., a color is attached -to the argument dock of the 'minus' block, the type system tries to find a -converter from the type TYPE_COLOR (the type of the color block) to the type -TYPE_NUMBER. If it finds one (and in this case it does), then the converter is -applied to the argument. A converter is simply a callable (usually a function) -and applying it simply means calling it and passing it the value of the -argument block as a parameter. The converter returns the number that -corresponds to the color, and the number is passed on to the 'minus' block. -This way, the 'minus' block does not have to know about colors, characters, or -numeric strings. Likewise, the color block also does not have to care about -how its value can be converted to a number. +number blocks can be attached to its argument docks. In fact, +colors, single characters, and numeric strings (like `"-5.2"`) +can easily be converted to numbers. The type system takes care +of this. When e.g., a color is attached to the argument dock of +the 'minus' block, the type system tries to find a converter +from the type TYPE_COLOR (the type of the color block) to the +type TYPE_NUMBER. If it finds one (and in this case it does), +then the converter is applied to the argument. A converter is +simply a callable (usually a function) and applying it simply +means calling it and passing it the value of the argument block +as a parameter. The converter returns the number that cor- +responds to the color, and the number is passed on to the +'minus' block. This way, the 'minus' block does not have to know +about colors, characters, or numeric strings. Likewise, the +color block also does not have to care about how its value can +be converted to a number. Why do some Blocks Need Return Types? ------------------------------------- |