Here is a function that I wrote:

: ?sgn ( value negative-combinator zero-combinator positive-combinator -- )
    roll                                        ! -- neg zer pos value
    dup 0 > [ drop  2nip  call ] [
        nip                                     ! -- neg zer value
        0 = [ nip ] [ drop ] if  call
    ] if ;

My question is, why does the <=> function return the values: +lt+, +eq+ and 
+gt+? Wouldn't it make more sense for it to return 1-, 0 and 1? This is what 
the COMPARE function does in ANS-Forth. This results in a kind of 
polymorphism because a function such as my ?sgn will work whether it follows 
an integer subtraction or a call to COMPARE, or what not. In Factor I would 
have to write another version of ?sgn specific to <=>. This is like how C 
function names often have the type prefixed onto them, and there are 
multiple versions of the same function for the various data types. That is 
one of the many reasons why C is difficult to program in. Note that I'm not 
criticizing Factor; I'm just trying to learn Factor's philosophy. I've long 
noted many problems with ANS-Forth and have been looking for something 
better --- which might be Factor.

One other quick question: Does Factor have something like the EXIT function 
of ANS-Forth?

Also, I am translating a symbol-table program into Factor (originally 
written in IBM370 assembly-language and later upgraded to ANS-Forth). How do 
I go about making this available to the Factor community? This uses an 
algorithm that I invented myself, which provides faster execution speed than 
hash-tables IMHO.


------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to