Welcome!

> I would be glad if someone could look at the source and tell me what
> beginner mistakes I made.
>
> https://github.com/tohava/cpuguard/blob/master/cpuguard.factor
>

You might find your code looks nicer if you use wrap text at 72-80
character lines, for long words you can put the contents of the word on the
line following its stack effect.  This is a convention that the factor
codebase uses generally.

Some feedback:

1) Since objects that are not "f" are considered "true", you don't need to
use ">boolean" in your "numeric?" word.

2) In "tokens", the code ``[ "" = not ] filter`` is pretty much the same as
"harvest".

3) In the stack effect for "if*-empty", you might use "true" and "false"
for the quotation names instead of "quott" and "quotf" (or perhaps
"true-quot", "false-quot").

4) Generally, the factor convention prefers dashes to underscores (e.g.,
"pid-file" instead of "pid_file").

5) In "limits_with_pids", you can use "sift" instead of ``[ ] filter``.

6) Sometimes there are simpler stack shuffling you can do, instead of this:

    [ arr1>> ] [ arr2>> ] bi pick swap [ nth ] 2bi@

    You might try this:

    [ arr1>> over ] [ arr2>> ] bi [ nth ] 2bi@

    Or even this:

    [ arr1>> nth ] [ arr2>> nth ] bi-curry bi

7) You can use the "private namespace" to keep words that you are only used
by your vocabulary and not anticipated to be used by anyone else.  Surround
the words that are private with "<PRIVATE"  and "PRIVATE>".  See this for
more information:

    http://docs.factorcode.org/content/article-word-search-private.html

8) Using "fry" and some combinators can simplify words, for example:

    : update_arr2 ( arr2 pids -- ) [ dup pid_and_total_time swap
string>number pick set-nth ] each drop ;

    Could become this:

    : update-arr2 ( arr2 pids -- )
        '[ [ pid-and-total-time ] [ string>number ] bi _ set-nth ] each ;

    Alternatively, if you keep pids as a sequence of numbers instead of
strings, it's even simpler:

    : update-arr2 ( arr2 pids -- )
        '[ [ pid-and-total-time ] keep _ set-nth ] each ;


> p.s. where is there info about how to run this program as an
> executable instead of from the factor IDE
>

You should read through these pages:

    http://docs.factorcode.org/content/article-tools.deploy.html

If this is the first time you are deploying a vocabulary as a binary, you
can choose deploy options using:

    "cpuguard" deploy-tool

Alternatively, you can just do "cpuguard" deploy which uses either defaults
or your previously saved deploy settings.

Best,
John.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to