diff --git a/basis/bootstrap/image/download/download.factor b/basis/bootstrap/image/download/download.factor index 9ab7689eca..e2de621984 100644 --- a/basis/bootstrap/image/download/download.factor +++ b/basis/bootstrap/image/download/download.factor @@ -7,7 +7,7 @@ IN: bootstrap.image.download CONSTANT: url URL" http://factorcode.org/images/latest/" : download-checksums ( -- alist ) - url "checksums.txt" >url derive-url http-data + url "checksums.txt" >url derive-url http-get nip string-lines [ " " split1 ] { } map>assoc ; : need-new-image? ( image -- ? ) diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index 1a64ceb646..cd87701aa9 100644 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -170,18 +170,6 @@ M: timestamp easter ( timestamp -- timestamp ) : microseconds ( x -- duration ) 1000000 / seconds ; : nanoseconds ( x -- duration ) 1000000000 / seconds ; -GENERIC: year ( obj -- n ) -M: integer year ; -M: timestamp year year>> ; - -GENERIC: month ( obj -- n ) -M: integer month ; -M: timestamp month month>> ; - -GENERIC: day ( obj -- n ) -M: integer day ; -M: timestamp day day>> ; - GENERIC: leap-year? ( obj -- ? ) M: integer leap-year? ( year -- ? ) diff --git a/basis/calendar/format/format.factor b/basis/calendar/format/format.factor index 96d76d0ce8..35e364e6aa 100644 --- a/basis/calendar/format/format.factor +++ b/basis/calendar/format/format.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008, 2010 Slava Pestov, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: math math.order math.parser math.functions kernel -sequences io accessors arrays io.streams.string splitting -combinators calendar calendar.format.macros present ; +USING: accessors arrays calendar calendar.format.macros +combinators io io.streams.string kernel math math.functions +math.order math.parser present sequences typed ; IN: calendar.format : pad-00 ( n -- str ) number>string 2 CHAR: 0 pad-head ; @@ -272,16 +272,16 @@ ERROR: invalid-timestamp-format ; : (timestamp>ymd) ( timestamp -- ) { YYYY "-" MM "-" DD } formatted ; -: timestamp>ymd ( timestamp -- str ) +TYPED: timestamp>ymd ( timestamp: timestamp -- str ) [ (timestamp>ymd) ] with-string-writer ; : (timestamp>hms) ( timestamp -- ) { hh ":" mm ":" ss } formatted ; -: timestamp>hms ( timestamp -- str ) +TYPED: timestamp>hms ( timestamp: timestamp -- str ) [ (timestamp>hms) ] with-string-writer ; -: timestamp>ymdhms ( timestamp -- str ) +TYPED: timestamp>ymdhms ( timestamp: timestamp -- str ) [ >gmt { (timestamp>ymd) " " (timestamp>hms) } formatted diff --git a/basis/http/client/client-docs.factor b/basis/http/client/client-docs.factor index 0d0887d10d..04077fc2f7 100644 --- a/basis/http/client/client-docs.factor +++ b/basis/http/client/client-docs.factor @@ -35,11 +35,6 @@ HELP: http-get { $description "Downloads the contents of a URL." } { $errors "Throws an error if the HTTP request fails." } ; -HELP: http-data -{ $values { "url" "a " { $link url } " or " { $link string } } { "data" sequence } } -{ $description "Downloads the contents of a URL. To view the HTTP response, use " { $link http-get } "." } -{ $errors "Throws an error if the HTTP request fails." } ; - HELP: http-post { $values { "post-data" object } { "url" "a " { $link url } " or " { $link string } } { "response" response } { "data" sequence } } { $description "Submits an HTTP POST request." } @@ -66,7 +61,7 @@ HELP: with-http-request ARTICLE: "http.client.get" "GET requests with the HTTP client" "Basic usage involves passing a " { $link url } " and getting a " { $link response } " and data back:" -{ $subsections http-get http-data } +{ $subsections http-get } "Utilities to retrieve a " { $link url } " and save the contents to a file:" { $subsections download diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index 9e540f111f..482a23aeaa 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -157,9 +157,6 @@ ERROR: download-failed response ; : http-get ( url -- response data ) http-request ; -: http-data ( url -- data ) - http-get nip ; - : with-http-get ( url quot -- response ) [ ] dip with-http-request ; inline diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index 62936af7ff..35d01c1014 100644 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -226,14 +226,14 @@ test-db [ [ t ] [ "vocab:http/test/foo.html" ascii file-contents - "http://localhost/nested/foo.html" add-port http-data = + "http://localhost/nested/foo.html" add-port http-get nip = ] unit-test -[ "http://localhost/redirect-loop" add-port http-data ] +[ "http://localhost/redirect-loop" add-port http-get nip ] [ too-many-redirects? ] must-fail-with [ "Goodbye" ] [ - "http://localhost/quit" add-port http-data + "http://localhost/quit" add-port http-get nip ] unit-test ! HTTP client redirect bug @@ -247,7 +247,7 @@ test-db [ ] unit-test [ "Goodbye" ] [ - "http://localhost/redirect" add-port http-data + "http://localhost/redirect" add-port http-get nip ] unit-test @@ -274,12 +274,12 @@ test-db [ : 404? ( response -- ? ) [ download-failed? ] [ response>> code>> 404 = ] bi and ; ! This should give a 404 not an infinite redirect loop -[ "http://localhost/d/blah" add-port http-data ] [ 404? ] must-fail-with +[ "http://localhost/d/blah" add-port http-get nip ] [ 404? ] must-fail-with ! This should give a 404 not an infinite redirect loop -[ "http://localhost/blah/" add-port http-data ] [ 404? ] must-fail-with +[ "http://localhost/blah/" add-port http-get nip ] [ 404? ] must-fail-with -[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test [ ] [ @@ -293,9 +293,9 @@ test-db [ test-httpd ] unit-test -[ "Hi" ] [ "http://localhost/" add-port http-data ] unit-test +[ "Hi" ] [ "http://localhost/" add-port http-get nip ] unit-test -[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test USING: html.components html.forms xml xml.traversal validators @@ -353,7 +353,7 @@ SYMBOL: a [ 4 ] [ a get-global ] unit-test -[ "Goodbye" ] [ "http://localhost/quit" add-port http-data ] unit-test +[ "Goodbye" ] [ "http://localhost/quit" add-port http-get nip ] unit-test ! Test cloning [ f ] [ <404> dup clone "b" "a" set-header drop "a" header ] unit-test @@ -371,7 +371,7 @@ SYMBOL: a ] unit-test [ t ] [ - "http://localhost/" add-port http-data + "http://localhost/" add-port http-get nip "vocab:http/test/foo.html" ascii file-contents = ] unit-test diff --git a/basis/syndication/syndication.factor b/basis/syndication/syndication.factor index edfbebeeab..fe31a49265 100644 --- a/basis/syndication/syndication.factor +++ b/basis/syndication/syndication.factor @@ -115,7 +115,7 @@ M: byte-array parse-feed [ bytes>xml xml>feed ] with-html-entities ; : download-feed ( url -- feed ) #! Retrieve an news syndication file, return as a feed tuple. - http-data parse-feed ; + http-get nip parse-feed ; ! Atom generation diff --git a/extra/calendar/holidays/us/us.factor b/extra/calendar/holidays/us/us.factor index a4fb19c597..538836952f 100644 --- a/extra/calendar/holidays/us/us.factor +++ b/extra/calendar/holidays/us/us.factor @@ -33,7 +33,7 @@ HOLIDAY-NAME: new-years-day us-federal "New Year's Day" HOLIDAY: martin-luther-king-day january 3 monday-of-month ; HOLIDAY-NAME: martin-luther-king-day us-federal "Martin Luther King Day" -HOLIDAY: inauguration-day year dup 4 neg rem + january 20 >>day ; +HOLIDAY: inauguration-day january 20 >>day [ dup 4 neg rem + ] change-year ; HOLIDAY-NAME: inauguration-day us "Inauguration Day" HOLIDAY: washingtons-birthday february 3 monday-of-month ; diff --git a/extra/images/http/http.factor b/extra/images/http/http.factor index d3cff18afb..620ab6f73b 100644 --- a/extra/images/http/http.factor +++ b/extra/images/http/http.factor @@ -5,7 +5,7 @@ images.viewer ; IN: images.http : load-http-image ( path -- image ) - [ http-data ] [ image-class ] bi load-image* ; + [ http-get nip ] [ image-class ] bi load-image* ; : http-image. ( path -- ) load-http-image image. ; diff --git a/extra/slots/syntax/syntax-docs.factor b/extra/slots/syntax/syntax-docs.factor index b79916f91b..84e6e89dac 100755 --- a/extra/slots/syntax/syntax-docs.factor +++ b/extra/slots/syntax/syntax-docs.factor @@ -3,6 +3,16 @@ USING: help.markup help.syntax ; IN: slots.syntax +HELP: slots[ +{ $description "Outputs several slot values to the stack." } +{ $example "USING: kernel prettyprint slots.syntax ;" + "IN: slots.syntax.example" + "TUPLE: rectangle width height ;" + "T{ rectangle { width 3 } { height 5 } } slots[ width height ] [ . ] bi@" + """3 +5""" +} ; + HELP: slots{ { $description "Outputs an array of slot values from a tuple." } { $example "USING: prettyprint slots.syntax ;" @@ -14,6 +24,8 @@ HELP: slots{ ARTICLE: "slots.syntax" "Slots syntax sugar" "The " { $vocab-link "slots.syntax" } " vocabulary provides an alternative syntax for taking a sequence of slots from a tuple." $nl +"Syntax sugar for cleaving slots to the stack:" +{ $subsections POSTPONE: slots[ } "Syntax sugar for cleaving slots to an array:" { $subsections POSTPONE: slots{ } ; diff --git a/extra/slots/syntax/syntax-tests.factor b/extra/slots/syntax/syntax-tests.factor index 689ccb48eb..e4dac6e4a4 100755 --- a/extra/slots/syntax/syntax-tests.factor +++ b/extra/slots/syntax/syntax-tests.factor @@ -5,6 +5,10 @@ IN: slots.syntax.tests TUPLE: slot-test a b c ; +[ 1 2 3 ] [ T{ slot-test f 1 2 3 } slots[ a b c ] ] unit-test +[ 3 ] [ T{ slot-test f 1 2 3 } slots[ c ] ] unit-test +[ ] [ T{ slot-test f 1 2 3 } slots[ ] ] unit-test + [ { 1 2 3 } ] [ T{ slot-test f 1 2 3 } slots{ a b c } ] unit-test [ { 3 } ] [ T{ slot-test f 1 2 3 } slots{ c } ] unit-test -[ { } ] [ T{ slot-test f 1 2 3 } slots{ } ] unit-test \ No newline at end of file +[ { } ] [ T{ slot-test f 1 2 3 } slots{ } ] unit-test diff --git a/extra/slots/syntax/syntax.factor b/extra/slots/syntax/syntax.factor index 95207a0de9..7bfe238fa8 100755 --- a/extra/slots/syntax/syntax.factor +++ b/extra/slots/syntax/syntax.factor @@ -4,6 +4,10 @@ USING: combinators combinators.smart fry lexer quotations sequences slots ; IN: slots.syntax +SYNTAX: slots[ + "]" [ reader-word 1quotation ] map-tokens + '[ _ cleave ] append! ; + SYNTAX: slots{ "}" [ reader-word 1quotation ] map-tokens '[ [ _ cleave ] output>array ] append! ; diff --git a/extra/webapps/fjsc/fjsc.factor b/extra/webapps/fjsc/fjsc.factor index 4dec258083..01d6935bee 100644 --- a/extra/webapps/fjsc/fjsc.factor +++ b/extra/webapps/fjsc/fjsc.factor @@ -35,7 +35,7 @@ TUPLE: fjsc < dispatcher ; : do-compile-url ( url -- response ) [ - absolute-url http-data 'expression' parse fjsc-compile write "();" write + absolute-url http-get nip 'expression' parse fjsc-compile write "();" write ] with-string-writer "application/javascript" ; diff --git a/extra/yahoo/yahoo.factor b/extra/yahoo/yahoo.factor index 2a8469c328..5e0c08b430 100644 --- a/extra/yahoo/yahoo.factor +++ b/extra/yahoo/yahoo.factor @@ -57,4 +57,4 @@ CONSTANT: factor-id "fRrVAKzV34GDyeRw6bUHDhEWHRedwfOC7e61wwXZLgGF80E67spxdQXuugB swap >>query ; : search-yahoo ( search -- seq ) - query http-data string>xml parse-yahoo ; + query http-get nip string>xml parse-yahoo ;