From a78ae458c2ddc79d3dc3260536de8c93aba33e72 Mon Sep 17 00:00:00 2001 From: Marion Date: Fri, 20 Sep 2013 15:36:50 +0000 Subject: format documentation about type system --- 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? ------------------------------------- -- cgit v0.9.1