On Fri, Sep 18, 2009 at 9:20 PM, Hugh Aguilar <[email protected]> wrote:
> In Forth we have abort" that terminates execution with an error message.

Look at the 'throw' word:

dup 0 < [ "Invalid input" throw ] when

See http://docs.factorcode.org/content/article-errors.html for details.

> Can this be wrapped in conditional-compilation code
> so that compilation of all these tests can be turned off after the program
> is debugged and running?

CONSTANT: enable-tests t

: if-testing ( quot -- ) enable-tests swap when ; inline

[ ... ] if-testing

Then change the constant to 'f' later.

> How do I coerce numbers into a floats (in case they are integers or
> rationals or whatever)? Right now I am just multiplying by 1.0. Is there a
> more elegant way?

Look at >float. Note that if you're doing '/ >float' you should use /f
instead, its more efficient since it avoids constructing the
intermediate rational number.

Slava

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to