From 584cd44856bb42e5dd81ddd0041eaa16a43e2ca9 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 10 Oct 2009 14:02:35 -0500 Subject: [PATCH 1/2] fix the tuple subclassing example docs --- core/classes/tuple/tuple-docs.factor | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/classes/tuple/tuple-docs.factor b/core/classes/tuple/tuple-docs.factor index daa275e2a7..cc67075168 100644 --- a/core/classes/tuple/tuple-docs.factor +++ b/core/classes/tuple/tuple-docs.factor @@ -129,17 +129,18 @@ ARTICLE: "tuple-inheritance-example" "Tuple subclassing example" } "Rectangles and parallelograms use the same algorithm for computing the area, whereas they use different algorithms for computing perimiter. Also, rectangles and parallelograms both have " { $snippet "width" } " and " { $snippet "height" } " slots. We can exploit this with subclassing:" { $code + "USING: math.constants math.functions ;" "GENERIC: area ( shape -- n )" "GENERIC: perimiter ( shape -- n )" "" "TUPLE: shape ;" "" "TUPLE: circle < shape radius ;" - "M: area circle radius>> sq pi * ;" - "M: perimiter circle radius>> 2 * pi * ;" + "M: circle area radius>> sq pi * ;" + "M: circle perimiter radius>> 2 * pi * ;" "" - "TUPLE: quad < shape width height" - "M: area quad [ width>> ] [ height>> ] bi * ;" + "TUPLE: quad < shape width height ;" + "M: quad area [ width>> ] [ height>> ] bi * ;" "" "TUPLE: rectangle < quad ;" "M: rectangle perimiter [ width>> 2 * ] [ height>> 2 * ] bi + ;" From 50d4eb27bf2e4132952f8c1e0d4a50c59d51c156 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 10 Oct 2009 14:04:22 -0500 Subject: [PATCH 2/2] add missing usings --- core/classes/tuple/tuple-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/classes/tuple/tuple-docs.factor b/core/classes/tuple/tuple-docs.factor index cc67075168..45d3931448 100644 --- a/core/classes/tuple/tuple-docs.factor +++ b/core/classes/tuple/tuple-docs.factor @@ -129,7 +129,7 @@ ARTICLE: "tuple-inheritance-example" "Tuple subclassing example" } "Rectangles and parallelograms use the same algorithm for computing the area, whereas they use different algorithms for computing perimiter. Also, rectangles and parallelograms both have " { $snippet "width" } " and " { $snippet "height" } " slots. We can exploit this with subclassing:" { $code - "USING: math.constants math.functions ;" + "USING: accessors kernel math math.constants math.functions ;" "GENERIC: area ( shape -- n )" "GENERIC: perimiter ( shape -- n )" ""