The other day Slava brought up an interesting point regarding internal words. 
He pointed out that top level words are so easy to test interactively. How do 
you interactively test internal words?

Doing so is possible, but making it easy would be something that a workspace 
tool could offer. Here I'll demonstrate that it's possible to do manually.

Let's suppose we have a (silly) word which uses an internal word:

:: a ( X Y -- a )

  [wlet | b [ ( i -- b ) Y + ] |

    X b ] ;

To debug 'b' at the listener, you transform 'a' such that it returns the body 
of 'b':

:: a ( X Y -- a )

  [ ( i -- b ) Y + ] ;

Note that it's perfectly fine that the internal body closes over 'Y'.

Then to test 'b', we call 'a' with some values:

    1 2 a

    --- Data stack:
    [ 2 1 load-locals 1 get-local 1 drop-locals + ]

And we've got a quot we can call.

To get really fancy, you can name it 'b':

   "b" in get create swap [ define ] with-compilation-unit

A development tool would make this easier by letting you select which internal 
word you want to test, asking for some values for the enclosing environment 
(X and Y in this example), and then giving you back a word that you can try 
out.

Ed

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to