From 88ef60fe1d80c2c3fb227b8f8950d2cddd072498 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 12 Sep 2008 10:29:34 -0500 Subject: [PATCH 1/4] better smtp docs --- basis/smtp/smtp-docs.factor | 11 +++++++++++ basis/smtp/smtp.factor | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/basis/smtp/smtp-docs.factor b/basis/smtp/smtp-docs.factor index 435b04504d..e859e082ff 100644 --- a/basis/smtp/smtp-docs.factor +++ b/basis/smtp/smtp-docs.factor @@ -4,12 +4,18 @@ USING: accessors kernel quotations help.syntax help.markup io.sockets strings calendar ; IN: smtp +HELP: smtp-domain +{ $description "The name of the machine that is sending the email. This variable will be filled in by the " { $link host-name } " word if not set by the user." } ; + HELP: smtp-server { $description "Holds an " { $link inet } " object with the address of an SMTP server." } ; HELP: smtp-read-timeout { $description "Holds an " { $link duration } " object that specifies how long to wait for a response from the SMTP server." } ; +HELP: esmtp? +{ $description "Set true by default, determines whether the SMTP client is using the Extended SMTP protocol." } ; + HELP: with-smtp-connection { $values { "quot" quotation } } { $description "Connects to an SMTP server stored in " { $link smtp-server } " and calls the quotation." } ; @@ -36,5 +42,10 @@ HELP: send-email } ; ARTICLE: "smtp" "SMTP Client Library" +"Configuring SMTP:" +{ $subsection smtp-server } +{ $subsection smtp-read-timeout } +{ $subsection smtp-domain } +{ $subsection esmtp? } "Sending an email:" { $subsection send-email } ; diff --git a/basis/smtp/smtp.factor b/basis/smtp/smtp.factor index f95ecddc1e..26bfea9a13 100755 --- a/basis/smtp/smtp.factor +++ b/basis/smtp/smtp.factor @@ -10,7 +10,7 @@ IN: smtp SYMBOL: smtp-domain SYMBOL: smtp-server "localhost" "smtp" smtp-server set-global SYMBOL: smtp-read-timeout 1 minutes smtp-read-timeout set-global -SYMBOL: esmtp t esmtp set-global +SYMBOL: esmtp? t esmtp? set-global LOG: log-smtp-connection NOTICE ( addrspec -- ) @@ -39,7 +39,7 @@ TUPLE: email : command ( string -- ) write crlf flush ; : helo ( -- ) - esmtp get "EHLO " "HELO " ? host-name append command ; + esmtp? get "EHLO " "HELO " ? host-name append command ; ERROR: bad-email-address email ; From efeea9293560c3d5c79d8e679546face17d940a0 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 12 Sep 2008 10:36:00 -0500 Subject: [PATCH 2/4] make editors use make --- basis/editors/editpadpro/editpadpro.factor | 2 +- basis/editors/editplus/editplus.factor | 2 +- basis/editors/emacs/emacs.factor | 2 +- basis/editors/emeditor/emeditor.factor | 3 ++- basis/editors/gvim/gvim.factor | 2 +- basis/editors/notepadpp/notepadpp.factor | 2 +- basis/editors/scite/scite.factor | 2 +- basis/editors/ted-notepad/ted-notepad.factor | 2 +- basis/editors/textmate/textmate.factor | 2 +- basis/editors/textwrangler/textwrangler.factor | 2 +- basis/editors/ultraedit/ultraedit.factor | 2 +- basis/editors/vim/vim.factor | 3 ++- 12 files changed, 14 insertions(+), 12 deletions(-) diff --git a/basis/editors/editpadpro/editpadpro.factor b/basis/editors/editpadpro/editpadpro.factor index 9da57e16bf..09f59f0916 100755 --- a/basis/editors/editpadpro/editpadpro.factor +++ b/basis/editors/editpadpro/editpadpro.factor @@ -1,6 +1,6 @@ USING: definitions kernel parser words sequences math.parser namespaces editors io.launcher windows.shell32 io.files -io.paths strings unicode.case ; +io.paths strings unicode.case make ; IN: editors.editpadpro : editpadpro-path diff --git a/basis/editors/editplus/editplus.factor b/basis/editors/editplus/editplus.factor index 363d202f6c..8af036f290 100755 --- a/basis/editors/editplus/editplus.factor +++ b/basis/editors/editplus/editplus.factor @@ -1,5 +1,5 @@ USING: editors io.files io.launcher kernel math.parser -namespaces sequences windows.shell32 ; +namespaces sequences windows.shell32 make ; IN: editors.editplus : editplus-path ( -- path ) diff --git a/basis/editors/emacs/emacs.factor b/basis/editors/emacs/emacs.factor index 966c4f368e..1d9f72f8c3 100755 --- a/basis/editors/emacs/emacs.factor +++ b/basis/editors/emacs/emacs.factor @@ -1,5 +1,5 @@ USING: definitions io.launcher kernel parser words sequences math -math.parser namespaces editors ; +math.parser namespaces editors make ; IN: editors.emacs : emacsclient ( file line -- ) diff --git a/basis/editors/emeditor/emeditor.factor b/basis/editors/emeditor/emeditor.factor index 8aecb49ae5..9aec22eed1 100755 --- a/basis/editors/emeditor/emeditor.factor +++ b/basis/editors/emeditor/emeditor.factor @@ -1,5 +1,6 @@ USING: editors hardware-info.windows io.files io.launcher -kernel math.parser namespaces sequences windows.shell32 ; +kernel math.parser namespaces sequences windows.shell32 +make ; IN: editors.emeditor : emeditor-path ( -- path ) diff --git a/basis/editors/gvim/gvim.factor b/basis/editors/gvim/gvim.factor index 4cc9de17a1..ad6fb65cfb 100755 --- a/basis/editors/gvim/gvim.factor +++ b/basis/editors/gvim/gvim.factor @@ -1,6 +1,6 @@ USING: io.backend io.files kernel math math.parser namespaces sequences system combinators -editors.vim vocabs.loader ; +editors.vim vocabs.loader make ; IN: editors.gvim SINGLETON: gvim diff --git a/basis/editors/notepadpp/notepadpp.factor b/basis/editors/notepadpp/notepadpp.factor index 959e633cc3..540612aeec 100755 --- a/basis/editors/notepadpp/notepadpp.factor +++ b/basis/editors/notepadpp/notepadpp.factor @@ -1,5 +1,5 @@ USING: editors io.files io.launcher kernel math.parser -namespaces sequences windows.shell32 ; +namespaces sequences windows.shell32 make ; IN: editors.notepadpp : notepadpp-path diff --git a/basis/editors/scite/scite.factor b/basis/editors/scite/scite.factor index a0bacaabba..aa5c5ef2a1 100755 --- a/basis/editors/scite/scite.factor +++ b/basis/editors/scite/scite.factor @@ -9,7 +9,7 @@ ! if not on the path. ! USING: io.files io.launcher kernel namespaces math -math.parser editors sequences windows.shell32 ; +math.parser editors sequences windows.shell32 make ; IN: editors.scite : scite-path ( -- path ) diff --git a/basis/editors/ted-notepad/ted-notepad.factor b/basis/editors/ted-notepad/ted-notepad.factor index 9b341dd2a8..b4135c92a0 100755 --- a/basis/editors/ted-notepad/ted-notepad.factor +++ b/basis/editors/ted-notepad/ted-notepad.factor @@ -1,5 +1,5 @@ USING: editors io.files io.launcher kernel math.parser -namespaces sequences windows.shell32 ; +namespaces sequences windows.shell32 make ; IN: editors.ted-notepad : ted-notepad-path diff --git a/basis/editors/textmate/textmate.factor b/basis/editors/textmate/textmate.factor index 12d45aa192..8bea085c7f 100755 --- a/basis/editors/textmate/textmate.factor +++ b/basis/editors/textmate/textmate.factor @@ -1,5 +1,5 @@ USING: definitions io.launcher kernel math math.parser parser -namespaces prettyprint editors ; +namespaces prettyprint editors make ; IN: editors.textmate diff --git a/basis/editors/textwrangler/textwrangler.factor b/basis/editors/textwrangler/textwrangler.factor index e97dadcdcb..f5a33f044d 100644 --- a/basis/editors/textwrangler/textwrangler.factor +++ b/basis/editors/textwrangler/textwrangler.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Ben Schlingelhof. ! See http://factorcode.org/license.txt for BSD license. USING: definitions io.launcher kernel parser words sequences -math math.parser namespaces editors ; +math math.parser namespaces editors make ; IN: editors.textwrangler : tw ( file line -- ) diff --git a/basis/editors/ultraedit/ultraedit.factor b/basis/editors/ultraedit/ultraedit.factor index d0bb789c1b..7c9c41df7a 100755 --- a/basis/editors/ultraedit/ultraedit.factor +++ b/basis/editors/ultraedit/ultraedit.factor @@ -1,5 +1,5 @@ USING: editors io.files io.launcher kernel math.parser -namespaces sequences windows.shell32 ; +namespaces sequences windows.shell32 wne ; IN: editors.ultraedit : ultraedit-path ( -- path ) diff --git a/basis/editors/vim/vim.factor b/basis/editors/vim/vim.factor index bfbb8f15a5..f07f257888 100755 --- a/basis/editors/vim/vim.factor +++ b/basis/editors/vim/vim.factor @@ -1,5 +1,6 @@ USING: definitions io io.launcher kernel math math.parser -namespaces parser prettyprint sequences editors accessors ; +namespaces parser prettyprint sequences editors accessors +make ; IN: editors.vim SYMBOL: vim-path From f497c7e1519dad6624ac912600c95a2a6f6e1f25 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 12 Sep 2008 11:29:12 -0500 Subject: [PATCH 3/4] Move map-reduce combinator to core, re-implement norm-sq and v. for better performance --- basis/math/vectors/vectors-tests.factor | 4 ++++ basis/math/vectors/vectors.factor | 6 +++--- core/sequences/sequences.factor | 11 +++++++++++ extra/sequences/lib/lib-tests.factor | 3 --- extra/sequences/lib/lib.factor | 3 --- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/basis/math/vectors/vectors-tests.factor b/basis/math/vectors/vectors-tests.factor index 5c71e2374f..498bb81f62 100644 --- a/basis/math/vectors/vectors-tests.factor +++ b/basis/math/vectors/vectors-tests.factor @@ -5,3 +5,7 @@ USING: math.vectors tools.test ; [ { 1 2 3 } ] [ { 2 4 6 } 1/2 v*n ] unit-test [ { 1 2 3 } ] [ { 2 4 6 } 2 v/n ] unit-test [ { 1/1 1/2 1/3 } ] [ 1 { 1 2 3 } n/v ] unit-test + +[ 4 ] [ { 1 2 } norm-sq ] unit-test +[ 36 ] [ { 2 3 } norm-sq ] unit-test + diff --git a/basis/math/vectors/vectors.factor b/basis/math/vectors/vectors.factor index b6ac459123..5316720b2f 100755 --- a/basis/math/vectors/vectors.factor +++ b/basis/math/vectors/vectors.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2005, 2007 Slava Pestov. +! Copyright (C) 2005, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel sequences math math.functions hints math.order ; @@ -19,8 +19,8 @@ IN: math.vectors : vmax ( u v -- w ) [ max ] 2map ; : vmin ( u v -- w ) [ min ] 2map ; -: v. ( u v -- x ) 0 [ * + ] 2reduce ; -: norm-sq ( v -- x ) 0 [ absq + ] reduce ; +: v. ( u v -- x ) [ * ] [ + ] 2map-reduce ; +: norm-sq ( v -- x ) [ absq ] [ + ] map-reduce ; : norm ( v -- x ) norm-sq sqrt ; : normalize ( u -- v ) dup norm v/n ; diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 6f755e5cb5..ae895f4853 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -747,6 +747,17 @@ PRIVATE> : unclip-slice ( seq -- rest first ) [ rest-slice ] [ first ] bi ; inline +: map-reduce ( seq map-quot reduce-quot -- result ) + [ [ unclip-slice ] dip [ call ] keep ] dip + compose reduce ; inline + +: 2map-reduce ( seq1 seq2 map-quot reduce-quot -- result ) + [ [ 2unclip-slice ] dip [ call ] keep ] dip + compose 2reduce ; inline + +: 2unclip-slice ( seq1 seq2 -- seq1' seq2' elt1 elt2 ) + [ unclip-slice ] bi@ swapd ; inline + : unclip-last-slice ( seq -- butlast last ) [ but-last-slice ] [ peek ] bi ; inline diff --git a/extra/sequences/lib/lib-tests.factor b/extra/sequences/lib/lib-tests.factor index 12bdd45c46..18c9d7f735 100755 --- a/extra/sequences/lib/lib-tests.factor +++ b/extra/sequences/lib/lib-tests.factor @@ -10,9 +10,6 @@ IN: sequences.lib.tests { { 16 17 18 19 20 } } [ 1 2 3 4 { 6 7 8 9 10 } [ + + + + ] 4 map-withn ] unit-test [ { 910 911 912 } ] [ 10 900 3 [ + + ] map-with2 ] unit-test -[ 4 ] [ { 1 2 } [ sq ] [ * ] map-reduce ] unit-test -[ 36 ] [ { 2 3 } [ sq ] [ * ] map-reduce ] unit-test - [ 10 ] [ { 1 2 3 4 } [ + ] reduce* ] unit-test [ 24 ] [ { 1 2 3 4 } [ * ] reduce* ] unit-test diff --git a/extra/sequences/lib/lib.factor b/extra/sequences/lib/lib.factor index ba49b8ee9e..0ce4f56f7a 100755 --- a/extra/sequences/lib/lib.factor +++ b/extra/sequences/lib/lib.factor @@ -31,9 +31,6 @@ IN: sequences.lib ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: map-reduce ( seq map-quot reduce-quot -- result ) - >r [ unclip ] dip [ call ] keep r> compose reduce ; inline - : reduce* ( seq quot -- result ) [ ] swap map-reduce ; inline ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! From fdff43ee0023a21fee92222d2813c19a2837705f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 12 Sep 2008 11:32:40 -0500 Subject: [PATCH 4/4] Fix load problem --- core/sequences/sequences.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index ae895f4853..57dba9ed4e 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -747,6 +747,9 @@ PRIVATE> : unclip-slice ( seq -- rest first ) [ rest-slice ] [ first ] bi ; inline +: 2unclip-slice ( seq1 seq2 -- seq1' seq2' elt1 elt2 ) + [ unclip-slice ] bi@ swapd ; inline + : map-reduce ( seq map-quot reduce-quot -- result ) [ [ unclip-slice ] dip [ call ] keep ] dip compose reduce ; inline @@ -755,9 +758,6 @@ PRIVATE> [ [ 2unclip-slice ] dip [ call ] keep ] dip compose 2reduce ; inline -: 2unclip-slice ( seq1 seq2 -- seq1' seq2' elt1 elt2 ) - [ unclip-slice ] bi@ swapd ; inline - : unclip-last-slice ( seq -- butlast last ) [ but-last-slice ] [ peek ] bi ; inline