Re: [Factor-talk] A Factor tutorial

2013-07-09 Thread Björn Lindqvist
Hi John,

Thanks for the great feedback!

2013/6/24 John Benediktsson mrj...@gmail.com
 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.

Oh, I didn't know that. Does the Windows prebuilt development releases
include those features? They are dated April 26 and April 24, so I
assume they aren't. But it would be very nice if they where updated. :)
It is so difficult to compile source on Windows so you can't expect most
users to be able to do it, like you can on Linux.

 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 tried format-table in strings.tables first, but quickly discarded the
idea because it left-aligns all columns. Numeric cell data should almost
always be right-aligned even if the header looks best when centered or
left-aligned. I think it would be hard to integrate what I've written
with what exists there but I can try.

 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 didn't know that was a convention! Is there any page in the manual for
special characters? ? obviously indicates a boolean predicate but
what about the other characters? Would word be a setter for example?

For example, I've tried implementing state using the namespaces vocab
(which I'm not at all sure is right) and setter and getter words named
set-pagesize and get-pagesize. But I thought long and hard whether
set-pagesize should be called pagesize and get-pagesize
pagesize instead.

 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! I'll do that when I consider the code done - it's definitely a
work in progress still.


--
mvh Björn Lindqvist
--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] A Factor tutorial

2013-07-09 Thread Joe Groff
On Tue, Jul 9, 2013 at 4:35 AM, Björn Lindqvist bjou...@gmail.com wrote:

 I didn't know that was a convention! Is there any page in the manual for
 special characters? ? obviously indicates a boolean predicate but
 what about the other characters? Would word be a setter for example?

 For example, I've tried implementing state using the namespaces vocab
 (which I'm not at all sure is right) and setter and getter words named
 set-pagesize and get-pagesize. But I thought long and hard whether
 set-pagesize should be called pagesize and get-pagesize
 pagesize instead.


Some naming conventions are documented under the Word naming conventions
section of this page:

http://docs.factorcode.org/content/article-conventions.html

-Joe
--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] A Factor tutorial

2013-06-24 Thread Alexander Mueller
words that look clumsy to me:
clean-group in adstrip.factor,
random-mail in db.factor and
tag-vectorstring in scraper.factor

also, imho the hardest part about getting into factor is getting
your head around the stack. the FP stuff is already more or less mainstream
(haskell, erlang, lisp, ...) esp. when you're from a academics background.

all in all it looks great and is nicely documented (the lack of silly cat
pictures
though is disappointing :D)



On Mon, Jun 24, 2013 at 1:20 AM, 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


Re: [Factor-talk] A Factor tutorial

2013-06-24 Thread John Benediktsson
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


[Factor-talk] A Factor tutorial

2013-06-23 Thread Björn Lindqvist
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