]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'for-slava' of git://git.rfc1149.net/factor
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 28 Feb 2009 20:42:56 +0000 (14:42 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 28 Feb 2009 20:42:56 +0000 (14:42 -0600)
1  2 
basis/math/functions/functions.factor
basis/stack-checker/stack-checker-tests.factor
basis/threads/threads.factor
core/kernel/kernel-docs.factor
extra/irc/ui/ui.factor
extra/otug-talk/otug-talk.factor

index 7e2ac0884ca9edae5a042c7507544aa4df370e40,605744b65f249e6c251f9246c1f963966dfd5645..964074512a3bfe7b5dbccd96c47b0ed38bd6c1a7
@@@ -1,6 -1,6 +1,6 @@@
  ! Copyright (C) 2004, 2008 Slava Pestov.
  ! See http://factorcode.org/license.txt for BSD license.
 -USING: math kernel math.constants math.private
 +USING: math kernel math.constants math.private math.bits
  math.libm combinators math.order sequences ;
  IN: math.functions
  
@@@ -26,10 -26,20 +26,10 @@@ GENERIC: sqrt ( x -- y ) foldabl
  M: real sqrt
      >float dup 0.0 < [ neg fsqrt 0.0 swap rect> ] [ fsqrt ] if ;
  
 -: each-bit ( n quot: ( ? -- ) -- )
 -    over [ 0 = ] [ -1 = ] bi or [
 -        2drop
 -    ] [
 -        2dup { [ odd? ] [ call ] [ 2/ ] [ each-bit ] } spread
 -    ] if ; inline recursive
 -
 -: map-bits ( n quot: ( ? -- obj ) -- seq )
 -    accumulator [ each-bit ] dip ; inline
 -
  : factor-2s ( n -- r s )
      #! factor an integer into 2^r * s
      dup 0 = [ 1 ] [
-         0 swap [ dup even? ] [ [ 1+ ] [ 2/ ] bi* ] [ ] while
+         0 swap [ dup even? ] [ [ 1+ ] [ 2/ ] bi* ] while
      ] if ; inline
  
  <PRIVATE
@@@ -37,7 -47,7 +37,7 @@@
  GENERIC# ^n 1 ( z w -- z^w )
  
  : (^n) ( z w -- z^w )
 -    1 swap [ [ dupd * ] when [ sq ] dip ] each-bit nip ; inline
 +    make-bits 1 [ [ dupd * ] when [ sq ] dip ] reduce nip ; inline
  
  M: integer ^n
      [ factor-2s ] dip [ (^n) ] keep rot * shift ;
@@@ -84,9 -94,9 +84,9 @@@ PRIVATE
      dup zero? [ drop 0./0. ] [ 0 < 1./0. 0 ? ] if ; inline
  
  : (^mod) ( n x y -- z )
 -    1 swap [
 +    make-bits 1 [
          [ dupd * pick mod ] when [ sq over mod ] dip
 -    ] each-bit 2nip ; inline
 +    ] reduce 2nip ; inline
  
  : (gcd) ( b a x y -- a d )
      over zero? [
index fadfadd885e0b2a3c152563e1353edf7ad4faedc,d90db8ab897c55f462fb0783426158137cc57afb..4361052b63baf5648598abbeea2c3b515f780083
@@@ -6,8 -6,7 +6,8 @@@ quotations effects tools.test continuat
  sorting assocs definitions prettyprint io inspector
  classes.tuple classes.union classes.predicate debugger
  threads.private io.streams.string io.timeouts io.thread
 -sequences.private destructors combinators eval locals.backend ;
 +sequences.private destructors combinators eval locals.backend
 +system ;
  IN: stack-checker.tests
  
  \ infer. must-infer
@@@ -514,7 -513,7 +514,7 @@@ ERROR: custom-error 
  ! Corner case
  [ [ [ f dup ] [ dup ] [ ] produce ] infer ] must-fail
  
- [ [ [ f dup ] [ ] [ ] while ] infer ] must-fail
+ [ [ [ f dup ] [ ] while ] infer ] must-fail
  
  : erg's-inference-bug ( -- ) f dup [ erg's-inference-bug ] when ; inline
  
@@@ -582,6 -581,4 +582,6 @@@ DEFER: eee
  : debugging-curry-folding ( quot -- )
      [ debugging-curry-folding ] curry call ; inline recursive
  
 -[ [ ] debugging-curry-folding ] must-infer
 +[ [ ] debugging-curry-folding ] must-infer
 +
 +[ [ exit ] [ 1 2 3 ] if ] must-infer
index 8556167009db22850f4256da628c0a32ad40cc9f,e168653f1d447106af5632633fed2cc6fbef40f2..3f4267df15e7771614719d259e390d36a1ec737c
@@@ -115,10 -115,10 +115,10 @@@ DEFER: sto
      sleep-queue
      [ dup expire-sleep? ]
      [ dup heap-pop drop expire-sleep ]
-     [ ] while
+     while
      drop ;
  
 -: start ( namestack thread -- )
 +: start ( namestack thread -- )
      [
          set-self
          set-namestack
index 342376fb22a424c1e4959aeaa95a5724e4ad240e,fcc70cc8e56810c732205cc99b10ef3c78989f78..c2719c056a0c9b3d3f0a4143f50b416756d7d129
@@@ -57,7 -57,6 +57,7 @@@ HELP: clea
  { $description "Clears the data stack." } ;
  
  HELP: build
 +{ $values { "n" integer } }
  { $description "The current build number. Factor increments this number whenever a new boot image is created." } ;
  
  HELP: hashcode*
@@@ -638,15 -637,15 +638,15 @@@ HELP: 4di
  } ;
  
  HELP: while
- { $values { "pred" { $quotation "( -- ? )" } } { "body" "a quotation" } { "tail" "a quotation" } }
+ { $values { "pred" { $quotation "( -- ? )" } } { "body" "a quotation" } }
  { $description "Calls " { $snippet "body" } " until " { $snippet "pred" } " returns " { $link f } "." } ;
  
  HELP: until
- { $values { "pred" { $quotation "( -- ? )" } } { "body" "a quotation" } { "tail" "a quotation" } }
+ { $values { "pred" { $quotation "( -- ? )" } } { "body" "a quotation" } }
  { $description "Calls " { $snippet "body" } " until " { $snippet "pred" } " returns " { $link t } "." } ;
  
  HELP: do
- { $values { "pred" { $quotation "( -- ? )" } } { "body" "a quotation" } { "tail" "a quotation" } }
+ { $values { "pred" { $quotation "( -- ? )" } } { "body" "a quotation" } }
  { $description "Executes one iteration of a " { $link while } " or " { $link until } " loop." } ;
  
  HELP: loop
@@@ -667,12 -666,6 +667,6 @@@ ARTICLE: "looping-combinators" "Loopin
  "In most cases, loops should be written using high-level combinators (such as " { $link "sequences-combinators" } ") or tail recursion. However, sometimes, the best way to express intent is with a loop."
  { $subsection while }
  { $subsection until }
- "The above two combinators take a " { $snippet "tail" } " quotation. Strictly speaking, the " { $snippet "tail" } " is not necessary, since the following are equivalent:"
- { $code
-     "[ P ] [ Q ] [ T ] while"
-     "[ P ] [ Q ] [ ] while T"
- }
- "However, depending on the stack effects of " { $snippet "pred" } " and " { $snippet "quot" } ", the " { $snippet "tail" } " quotation might need to be non-empty in order to balance out the stack effect of branches for stack effect inference."
  $nl
  "To execute one iteration of a loop, use the following word:"
  { $subsection do }
diff --combined extra/irc/ui/ui.factor
index 791639d260f47eef55d33945281c6b903b996022,d788eb3c2c4f0a769cf9f74672ddde0f4bb45ae2..f360273fdabe9642b44fa0cb3ace35ca9d72edb7
@@@ -28,9 -28,9 +28,9 @@@ TUPLE: irc-tab < frame chat client wind
  \r
  : write-color ( str color -- )\r
      foreground associate format ;\r
 -: dark-red T{ rgba f 0.5 0.0 0.0 1 } ;\r
 -: dark-green T{ rgba f 0.0 0.5 0.0 1 } ;\r
 -: dark-blue T{ rgba f 0.0 0.0 0.5 1 } ;\r
 +CONSTANT: dark-red T{ rgba f 0.5 0.0 0.0 1 }\r
 +CONSTANT: dark-green T{ rgba f 0.0 0.5 0.0 1 }\r
 +CONSTANT: dark-blue T{ rgba f 0.0 0.0 0.5 1 }\r
  \r
  : dot-or-parens ( string -- string )\r
      [ "." ]\r
@@@ -152,7 -152,7 +152,7 @@@ M: object handle-inbo
  : display ( stream tab -- )\r
      '[ _ [ [ t ]\r
             [ _ dup chat>> hear handle-inbox ]\r
-            [  ] while ] with-output-stream ] "ircv" spawn drop ;\r
+            while ] with-output-stream ] "ircv" spawn drop ;\r
  \r
  : <irc-pane> ( tab -- tab pane )\r
      <scrolling-pane>\r
index ef5782dda731394c400ebec28c5d750e576d560b,716afc0dc25535983cc16eeb13070b0ee67f574e..16ee2b740b0cb764d42026013e0db3e7d5cbd18e
@@@ -39,7 -39,7 +39,7 @@@ M: png-gadget ungraft* ( gadget -- 
  : $tetris ( element -- )
      drop [ <default-tetris> <tetris-gadget> gadget. ] ($block) ;
  
 -: otug-slides
 +CONSTANT: otug-slides
  {
      { $slide "Factor!"
          { $url "http://factorcode.org" }
      }
      { $slide "Modifiers"
          { $code ": bank ( n -- n )" "    readln string>number +" "    dup \"Balance: $\" write . ;" }
-         { $code "0 [ dup 0 > ] [ bank ] [ ] while" }
+         { $code "0 [ dup 0 > ] [ bank ] while" }
      }
      { $slide "Modifiers"
          { $code "0 [ dup 0 > ] [ bank ] [ ] do while" }
@@@ -361,7 -361,7 +361,7 @@@ var price = (order == null ? null : ord
          "Factor has many cool things that I didn't talk about"
          "Questions?"
      }
 -} ;
 +}
  
  : otug-talk ( -- ) otug-slides slides-window ;