example: update and fix the extern_methods example
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 28 Nov 2013 20:17:58 +0000 (15:17 -0500)
committerJean Privat <jean@pryen.org>
Mon, 24 Feb 2014 21:13:20 +0000 (16:13 -0500)
The implementation of the method foo wrongfully called its C self.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

examples/extern_methods.nit

index 5941358..00c6b68 100644 (file)
@@ -21,11 +21,11 @@ module extern_methods
 redef enum Int
        # Returns self'th fibonnaci number
        # implemented here in C for optimization purposes
-       fun fib : Int `{
+       fun fib : Int import fib `{
                if ( recv < 2 )
                        return recv;
                else
-                       return Int_fib___impl( recv-1 ) + Int_fib___impl( recv-2 );
+                       return Int_fib( recv-1 ) + Int_fib( recv-2 );
        `}
 
        # System call to sleep for "self" seconds
@@ -43,8 +43,8 @@ redef enum Int
        # * the local fib method
        # * the + operator, a method of Int
        # * to_s, a method of all objects
-       # * String::to_cstring, a method of String to return an equivalent char*
-       fun foo import fib, +, to_s, String::to_cstring `{
+       # * String.to_cstring, a method of String to return an equivalent char*
+       fun foo import fib, +, to_s, String.to_cstring `{
                long recv_fib = Int_fib( recv );
                long recv_plus_fib = Int__plus( recv, recv_fib );