Hi Björn,
This is great!
Some comments:
In your "random-ascii" word, you can use "" replicate-as instead of
replicate >string.
I believe vprintf and vsprintf are now available in formatting vocabulary,
so you wouldn't need to duplicate that functionality if a user has a recent
developer version of Factor. The original "macro" version of printf is
still useful because it can expands the format string at parse time.
For simple text data, you can use strings.tables to format it
(automatically makes the columns as wide as necessary for the data), or if
you want to apply styles (colors, fonts etc) to the text you can use
tabular-output or stream-write-table. Your version with fixed-width
columns and table headers for strings might be a nice addition to
strings.tables if you want to factor it out.
I'm not sure it is good practice to shadow a core word such as "read",
although one could argue that it makes your interface simpler and a user
would be unlikely to confuse the two. But maybe "10 post" would be a
better name to get them and "10 post." would be a better name to get and
print (using our "dot" convention for words that write/print text).
I sometimes find vertical whitespace nice in words that construct objects
with each "setter" on a different line, for example, doing something like
this for "recent":
: recent ( -- )
[
<query>
T{ mail } get-group >>group >>tuple
"date desc" >>order
get-pagesize >>limit
select-tuples
] with-mydb mail-format print-table ;
Similarly, in your random-mail word, it might be more clear to do something
like this which is a bit more verbose, but more clear on what you are
setting:
: random-mail ( -- mail )
mail new
5000 random >>mid
10 random-ascii >>group
now 1000 random 500 - days time+ >>date
15 random-ascii >>sender
30 random-ascii >>subject
80 random-ascii >>body ;
Your adstrip/clean-group word would probably be more clear if you factored
out the filtering of your line frequencies into a separate word like
"remove-bad-lines" or something.
I noticed you don't have a "gmane" vocabulary, you might find exposing a
simple public interface to your library there would be nice.
Are you interested in contributing this to the main repository? It's a
pretty neat vocabulary and a great example / tutorial for our users.
Thanks again!
John.
On Sun, Jun 23, 2013 at 4:20 PM, Björn Lindqvist <bjou...@gmail.com> wrote:
> Hello all Factorians!
>
> I've written a tutorial about Factor which you can find here:
>
> https://github.com/bjourne/playground-factor/wiki/Parsing-gmane-with-Factor
>
> It's aimed at coders who already know some FP and want to try Factor.
> Also, I'm new to Factor and have probably made many mistakes but "the best
> way to learn something is to try and teach it." :) Feedback and comments
> are very welcome.
>
>
> --
> mvh/best regards Björn Lindqvist
> http://www.bjornlindqvist.se/
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk