]> gitweb.factorcode.org Git - factor.git/commitdiff
possibly controversial: removed destructive list manipulation; other cleanups before-gc-trigger-changes
authorSlava Pestov <slava@factorcode.org>
Tue, 12 Oct 2004 05:11:35 +0000 (05:11 +0000)
committerSlava Pestov <slava@factorcode.org>
Tue, 12 Oct 2004 05:11:35 +0000 (05:11 +0000)
34 files changed:
library/compiler/compile-all.factor
library/cross-compiler.factor
library/httpd/html-tags.factor
library/interpreter.factor
library/list-namespaces.factor
library/lists.factor
library/namespaces.factor
library/platform/jvm/cons.factor
library/platform/jvm/namespaces.factor
library/platform/native/boot-stage2.factor
library/platform/native/errors.factor
library/platform/native/init-stage2.factor
library/platform/native/kernel.factor
library/platform/native/namespaces.factor
library/platform/native/parse-stream.factor
library/platform/native/parse-syntax.factor
library/platform/native/parser.factor
library/platform/native/primitives.factor
library/platform/native/strings.factor
library/prettyprint.factor
library/styles.factor
library/test/jvm-compiler/miscellaneous.factor
library/test/jvm-compiler/primitives.factor
library/test/lists/cons.factor
library/test/lists/destructive.factor [deleted file]
library/test/lists/java.factor
library/test/lists/lists.factor
library/test/lists/namespaces.factor
library/test/test.factor
library/vocabulary-style.factor
native/cons.c
native/cons.h
native/primitives.c
native/primitives.h

index 68b83c50d045166934183f4a23518c79977dfc22..5cd79b1ba388d31fb464845c3ef77be9d66cebe1 100644 (file)
@@ -110,7 +110,11 @@ SYMBOL: compilable-word-list
     [, [ dup can-compile? [ , ] [ drop ] ifte ] each-word ,] ;
 
 : cannot-compile ( word -- )
-    "verbose-compile" get [ "Cannot compile " write . ] when ;
+    "verbose-compile" get [
+        "Cannot compile " write .
+    ] [
+        drop
+    ] ifte ;
 
 : init-compiler ( -- )
     #! Compile all words.
index 02985a45213f1f610e9a7bde183d955148983ad3..dcf2e14d2be715da8ad49d1a371b4275a321d14f 100644 (file)
@@ -198,8 +198,6 @@ IN: image
         cons
         car
         cdr
-        set-car
-        set-cdr
         <vector>
         vector-length
         set-vector-length
index 6d668d2f8ea0e7d78893ed5f1adcd1b4266a4c9d..f9f28e2ebda30e330dfb76f023ac57103d644159 100644 (file)
@@ -78,7 +78,7 @@ USE: logic
 : attrs>string ( alist -- string )
     #! Convert the attrs alist to a string
     #! suitable for embedding in an html tag.
-    nreverse <% [ dup car % "='" % cdr % "'" % ] each %> ;
+    reverse <% [ dup car % "='" % cdr % "'" % ] each %> ;
 
 : write-attributes ( n: namespace -- )    
     #! With the attribute namespace on the stack, get the attributes
index 6980053c9ab2542ee86eb1caffa83b6cc0f71e30..567b36f7074b2e34699d42aba01c5234c1a06d1d 100644 (file)
@@ -81,7 +81,7 @@ USE: vectors
 
 : print-prompt ( -- )
     <% "  ( " % history# unparse % " )" % %>
-    [ "prompt" ] get-style write-attr
+    "prompt" get-style write-attr
     ! Print the space without a style, to workaround a bug in
     ! the GUI listener where the style from the prompt carries
     ! over to the input
index 78bb33c2d472292c006ab920c8ec2dd3ed06d2f5..c8b1bd371a86b67873705e0d4e84660f21d05980 100644 (file)
@@ -31,17 +31,6 @@ USE: kernel
 USE: namespaces
 USE: stack
 
-: append@ ( [ list ] var -- )
-    #! Append a proper list stored in a variable with another
-    #! list, storing the result back in the variable.
-    #! given variable using 'append'.
-    tuck get swap append put ;
-
-: add@ ( elem var -- )
-    #! Add an element at the end of a proper list stored in a
-    #! variable, storing the result back in the variable.
-    tuck get swap add put ;
-
 : cons@ ( x var -- )
     #! Prepend x to the list stored in var.
     tuck get cons put ;
@@ -78,10 +67,6 @@ USE: stack
     #! if the object does not already occur in the list.
     "list-buffer" unique@ ;
 
-: list, ( list -- )
-    #! Append each element to the currently constructing list.
-    [ , ] each ;
-
 : ,] ( -- list )
     #! Finish constructing a list and push it on the stack.
-    "list-buffer" get nreverse n> drop ;
+    "list-buffer" get reverse n> drop ;
index 9f7dd2650097fad3952575b3a32d007ed1d9f6fd..5db76e1e4874d20df2575a5962cfc1d194b469dc 100644 (file)
@@ -41,45 +41,9 @@ USE: vectors
     #! Construct a proper list of 3 elements.
     2list cons ;
 
-: 2rlist ( a b -- [ b a ] )
-    #! Construct a proper list of 2 elements in reverse stack order.
-    swap unit cons ;
-
-: copy-cons ( accum cons -- accum cdr )
-    uncons >r unit dup rot set-cdr r> ;
-
-: (clone-list) ( accum list -- last )
-    dup cons? [ copy-cons (clone-list) ] [ over set-cdr ] ifte ;
-
-: clone-list* ( list -- list last )
-    #! Push the cloned list, and the last cons cell of the
-    #! cloned list.
-    uncons >r unit dup r> (clone-list) ;
-
-: clone-list ( list -- list )
-    #! Push a shallow copy of a list.
-    dup [ clone-list* drop ] when ;
-
 : append ( [ list1 ] [ list2 ] -- [ list1 list2 ] )
-    #! Append two lists. A new list is constructed by copying
-    #! the first list and setting its tail to the second.
-    over [ >r clone-list* r> swap set-cdr ] [ nip ] ifte ;
-
-: add ( [ list1 ] elem -- [ list1 elem ] )
-    #! Push a new proper list with an element added to the end.
-    unit append ;
-
-: caar ( list -- caar )
-    car car ; inline
-
-: cdar ( list -- cadr )
-    cdr car ; inline
-
-: cadr ( list -- cdar )
-    car cdr ; inline
-
-: cddr ( list -- cddr )
-    cdr cdr ; inline
+    #! Append two lists.
+    over [ >r uncons r> append cons ] [ nip ] ifte ;
 
 : contains? ( element list -- remainder )
     #! If the proper list contains the element, push the
@@ -115,48 +79,7 @@ USE: vectors
 : list? ( list -- boolean )
     #! Proper list test. A proper list is either f, or a cons
     #! cell whose cdr is a proper list.
-    dup [
-        dup cons? [
-            cdr list?
-        ] [
-            drop f
-        ] ifte
-    ] [
-        drop t
-    ] ifte ;
-
-: nappend ( [ list1 ] [ list2 ] -- [ list1 list2 ] )
-    #! DESTRUCTIVE. Append two lists. The last node of the first
-    #! list is destructively modified to point to the second
-    #! list, unless the first list is f, in which case the
-    #! second list is returned.
-    over [ over last* set-cdr ] [ nip ] ifte ;
-
-: first ( list -- obj )
-    #! Push the head of the list, or f if the list is empty.
-    dup [ car ] when ;
-
-: next ( obj list -- obj )
-    #! Push the next object in the list after an object. Wraps
-    #! around to beginning of list if object is at the end.
-    tuck contains? dup [
-        ! Is there another entry in the list?
-        cdr dup [
-            nip car
-        ] [
-            ! No. Pick first
-            drop first
-        ] ifte
-    ] [
-        drop first
-    ] ifte ;
-
-: nreverse-iter ( list cons -- list cons )
-    [ dup dup cdr 2swap set-cdr nreverse-iter ] when* ;
-
-: nreverse ( list -- list )
-    #! DESTRUCTIVE. Reverse the given list, without consing.
-    f swap nreverse-iter ;
+    [ dup cons? [ cdr list? ] [ drop f ] ifte ] [ t ] ifte* ;
 
 : partition-add ( obj ? ret1 ret2 -- ret1 ret2 )
     >r >r [ r> cons r> ] [ r> r> swapd cons ] ifte ; inline
@@ -196,7 +119,7 @@ USE: vectors
         ! Recurse
         tuck sort >r sort r>
         ! Combine
-        swapd cons nappend
+        swapd cons append
     ] [
         drop
     ] ifte ; inline interpret-only
@@ -209,11 +132,7 @@ USE: vectors
 DEFER: tree-contains?
 
 : =-or-contains? ( element obj -- ? )
-    dup cons? [
-        tree-contains?
-    ] [
-        =
-    ] ifte ;
+    dup cons? [ tree-contains? ] [ = ] ifte ;
 
 : tree-contains? ( element tree -- ? )
     dup [
@@ -254,7 +173,7 @@ DEFER: tree-contains?
     f transp [
         ! accum code elem -- accum code
         transp over >r >r call r> cons r>
-    ] each drop nreverse ; inline interpret-only
+    ] each drop reverse ; inline interpret-only
 
 : 2uncons ( list1 list2 -- car1 car2 cdr1 cdr2 )
     uncons >r >r uncons r> swap r> ;
@@ -283,31 +202,9 @@ DEFER: tree-contains?
     #! two lists in turn, collecting the return value into a
     #! new list. The quotation must have stack effect
     #! ( x y -- z ).
-    <2map [ pick >r 2map-step r> ] 2each drop nreverse ;
+    <2map [ pick >r 2map-step r> ] 2each drop reverse ;
     inline interpret-only
 
-: substitute ( new old list -- list )
-    [ 2dup = [ drop over ] when ] map nip nip ;
-
-: (head) ( accum list n -- last list )
-    dup 1 = [ drop ] [ pred >r copy-cons r> (head) ] ifte ;
-
-: head* ( n list -- head last rest )
-    #! Push the head of the list, the last cons cell of the
-    #! head, and the rest of the list.
-    uncons >r unit tuck r> rot (head) ;
-
-: head ( n list -- head )
-    #! Push a new list containing the first n elements.
-    over 0 = [ 2drop f ] [ head* 2drop ] ifte ;
-
-: set-nth ( value index list -- list )
-    over 0 = [
-        nip cdr cons
-    ] [
-        rot >r head* cdr r> swons swap set-cdr
-    ] ifte ;
-
 : subset-add ( car pred accum -- accum )
     >r over >r call r> r> rot [ cons ] [ nip ] ifte ;
 
@@ -326,24 +223,16 @@ DEFER: tree-contains?
     #!
     #! In order to compile, the quotation must consume as many
     #! values as it produces.
-    f -rot subset-iter nreverse ; inline interpret-only
+    f -rot subset-iter reverse ; inline interpret-only
 
 : remove ( obj list -- list )
     #! Remove all occurrences of the object from the list.
     [ dupd = not ] subset nip ;
 
-: remove-nth ( n list -- list )
-    #! Push a new list with the nth element removed.
-    over 0 = [ nip cdr ] [ head* cdr swap set-cdr ] ifte ;
-
 : length ( list -- length )
     #! Pushes the length of the given proper list.
     0 swap [ drop succ ] each ;
 
-: leaves ( list -- length )
-    #! Like length, but counts each sub-list recursively.
-    0 swap [ dup list? [ leaves + ] [ drop succ ] ifte ] each ;
-
 : reverse ( list -- list )
     #! Push a new list that is the reverse of a proper list.
     [ ] swap [ swons ] each ;
@@ -401,4 +290,4 @@ DEFER: tree-contains?
     [ ] swap [ swons ] vector-each ;
 
 : vector>list ( vector -- list )
-    stack>list nreverse ;
+    stack>list reverse ;
index 6d5c996c4b36d70c627457d0ec685ecba807b48d..23b3df9b459391a4bb0d0b5d81b7b74f561daf93 100644 (file)
@@ -53,17 +53,6 @@ USE: vectors
 ! bind ( namespace quot -- ) executes a quotation with a
 ! namespace pushed on the namespace stack.
 
-: namestack ( -- stack )
-    #! Push a copy of the namespace stack; same naming
-    #! convention as the primitives datastack and callstack.
-    namestack* clone ; inline
-
-: set-namestack ( stack -- )
-    #! Set the namespace stack to a copy of another stack; same
-    #! naming convention as the primitives datastack and
-    #! callstack.
-    clone set-namestack* ; inline
-
 : >n ( namespace -- n:namespace )
     #! Push a namespace on the namespace stack.
     namestack* vector-push ; inline
@@ -98,14 +87,6 @@ USE: vectors
     #! result of evaluating [ a ].
     over get [ drop get ] [ swap >r call dup r> set ] ifte ;
 
-: alist> ( alist namespace -- )
-    #! Set each key in the alist to its value in the
-    #! namespace.
-    [ [ unswons set ] each ] bind ;
-
-: alist>namespace ( alist -- namespace )
-    <namespace> tuck alist> ;
-
 : traverse-path ( name object -- object )
     dup has-namespace? [ get* ] [ 2drop f ] ifte ;
 
index 1ecdd083f82ca533a9d2d3e0878453605e93ccea..aae8c9c15b1de44252fb55afe7a0af4b7702b0b5 100644 (file)
@@ -51,14 +51,3 @@ IN: lists USE: kernel USE: stack
 : cons? ( list -- boolean )
     #! Test for cons cell type.
     "factor.Cons" is ; inline
-
-: deep-clone ( cons -- cons )
-    [ "factor.Cons" ] "factor.Cons" "deepClone" jinvoke-static ;
-
-: set-car ( A [ B | C ] -- )
-    #! DESTRUCTIVE. Replace the head of a list.
-    "factor.Cons" "car" jvar-set ; inline
-
-: set-cdr ( A [ B | C ] -- )
-    #! DESTRUCTIVE. Replace the tail of a list.
-    "factor.Cons" "cdr" jvar-set ; inline
index f393931264a5acdc0ff117883ba2aac301c8bb33..eaa0c1b3f6cdabd12e4f11aeb88ff932be8a5fda 100644 (file)
@@ -45,6 +45,12 @@ DEFER: namespace
     interpreter
     "factor.FactorInterpreter" "namestack" jvar-set ; inline
 
+: namestack ( -- stack )
+    namestack* clone ; inline
+
+: set-namestack ( stack -- )
+    clone set-namestack* ; inline
+
 : global ( -- namespace )
     interpreter "factor.FactorInterpreter" "global" jvar-get ;
 
index c6dd71fbe3963486197a79fdb63906d375ae3379..758ead07f92e70627335a6ca608ac09338f0ca28 100644 (file)
@@ -179,7 +179,14 @@ IN: compiler
 DEFER: compilable-words
 DEFER: compilable-word-list
 
-[ warm-boot ] set-boot
+IN: init
+DEFER: init-interpreter
+
+[
+    warm-boot
+    "interactive" get [ init-interpreter ] when
+    0 exit*
+] set-boot
 
 compilable-words compilable-word-list set
 
index 1531c5e0c7c21d1e34ac4d84a5eb1ee67fbac851..1f1811984bff613c48279010cbb0794b65ee754c 100644 (file)
@@ -32,6 +32,6 @@ USE: vectors
 ! This is a very lightweight exception handling system.
 
 : catchstack* ( -- cs ) 6 getenv ;
-: catchstack ( -- cs ) catchstack* clone ;
+: catchstack ( -- cs ) catchstack* vector-clone ;
 : set-catchstack* ( cs -- ) 6 setenv ;
-: set-catchstack ( cs -- ) clone set-catchstack* ;
+: set-catchstack ( cs -- ) vector-clone set-catchstack* ;
index b66579516b9dda625d6c3f872b1fca2f1491b37a..cb9b882e7b62b61ab1f03066b4ed2b25dd60d297 100644 (file)
@@ -64,14 +64,11 @@ USE: words
     t "ansi" set
     t "compile" set
 
+    "ansi" get [ "stdio" get <ansi-stream> "stdio" set ] when
+
     ! The first CLI arg is the image name.
     cli-args uncons parse-command-line "image" set
 
     "compile" get [ init-compiler ] when
 
-    run-user-init
-
-    "ansi" get [ "stdio" get <ansi-stream> "stdio" set ] when
-    "interactive" get [ init-interpreter ] when
-
-    0 exit* ;
+    run-user-init ;
index 9ccdb9645c59088eb112ef43f36b8bf8919f9622..1667726cee59d98c616123d1741ac77392eb9ade 100644 (file)
@@ -114,7 +114,6 @@ IN: kernel
 
 : clone ( obj -- obj )
     [
-        [ cons? ] [ clone-list ]
         [ vector? ] [ vector-clone ]
         [ sbuf? ] [ sbuf-clone ]
         [ drop t ] [ ( return the object ) ]
@@ -130,11 +129,3 @@ IN: kernel
 ! No compiler...
 : inline ;
 : interpret-only ;
-
-! HACKS
-
-IN: strings
-: char? drop f ;
-: >char ;
-: >upper ;
-: >lower ;
index 4cf2d890256cdfff8ff1f9f3839f477e320a664f..09d33b1592af0d02be6cc86e3a6aa4cab3ff5685 100644 (file)
@@ -41,6 +41,9 @@ DEFER: >n
 : namestack* ( -- ns ) 3 getenv ;
 : set-namestack* ( ns -- ) 3 setenv ;
 
+: namestack ( -- stack ) namestack* vector-clone ;
+: set-namestack ( stack -- ) vector-clone set-namestack* ;
+
 : global ( -- g ) 4 getenv ;
 : set-global ( g -- ) 4 setenv ;
 
index 63acdef74e7bbc237f00a18f23150baae7add1fd..dd751286e142443c29e39b06b52665d563985778 100644 (file)
@@ -69,7 +69,7 @@ USE: strings
 : (parse-stream) ( name stream -- quot )
     #! Uses the current namespace for temporary variables.
     >r "file" set f r>
-    [ (parse) ] read-lines nreverse
+    [ (parse) ] read-lines reverse
     "file" off
     "line-number" off ;
 
index 16bb1ac94d257c4c936e5fad774c60469a3e075b..dae895b62a19cc187341c87c3479e92cb76a95ce 100644 (file)
@@ -124,7 +124,7 @@ IN: syntax
 
 ! Lists
 : [ [ ] ; parsing
-: ] nreverse parsed ; parsing
+: ] reverse parsed ; parsing
 
 : | ( syntax: | cdr ] )
     #! See the word 'parsed'. We push a special sentinel, and
@@ -133,7 +133,7 @@ IN: syntax
 
 ! Vectors
 : { f ; parsing
-: } nreverse list>vector parsed ; parsing
+: } reverse list>vector parsed ; parsing
 
 ! Do not execute parsing word
 : POSTPONE: ( -- ) scan-word parsed ; parsing
@@ -149,7 +149,7 @@ IN: syntax
 : ;
     #! End a word definition.
     "in-definition" off
-    nreverse
+    reverse
     ;-hook ; parsing
 
 ! Symbols
index 01f07436e14eb1608bacc66e6272e9a2202b95cb..383faa1b51c0a68bb0738571bebd128eb6fea47a 100644 (file)
@@ -135,9 +135,9 @@ USE: unparser
         ] ifte
     ] when ;
 
-: parsed| ( obj -- )
+: parsed| ( parsed parsed obj -- parsed )
     #! Some ugly ugly code to handle [ a | b ] expressions.
-    >r nreverse dup last* r> swap set-cdr swons ;
+    >r unswons r> cons swap [ swons ] each swons ;
 
 : expect ( word -- )
     dup scan = not [
@@ -158,7 +158,7 @@ USE: unparser
 
 : parse ( str -- code )
     #! Parse the string into a parse tree that can be executed.
-    f swap (parse) nreverse ;
+    f swap (parse) reverse ;
 
 : eval ( "X" -- X )
     parse call ;
index 56864b9b93e97634e99e5fd5e44cd36fc20c9a8f..a554da62554fda30b5152be97da4aa4d7b01409d 100644 (file)
@@ -51,8 +51,6 @@ USE: words
     [ cons                   | " car cdr -- [ car | cdr ] " ]
     [ car                    | " [ car | cdr ] -- car " ]
     [ cdr                    | " [ car | cdr ] -- cdr " ]
-    [ set-car                | " car cons -- " ]
-    [ set-cdr                | " cdr cons -- " ]
     [ <vector>               | " capacity -- vector" ]
     [ vector-length          | " vector -- n " ]
     [ set-vector-length      | " n vector -- " ]
index 5e512e25574a66777f017229d65d4b76694491bf..681c6a44fb1601d587697397fdf338efac8db3b6 100644 (file)
@@ -37,3 +37,9 @@ USE: stack
     dup >r sbuf-append r>
     dup >r sbuf-append r>
     sbuf>str ;
+
+! HACKS
+: char? drop f ;
+: >char ;
+: >upper ;
+: >lower ;
index ef46dba23250a44591c4ccf2bf0206c652b1fe62..b45256ced4f52c4e70cf5617eac03298df8a13dd 100644 (file)
@@ -141,7 +141,7 @@ DEFER: prettyprint*
     dup ends-with-newline? dup [ nip ] [ drop ] ifte ;
 
 : prettyprint-comment ( comment -- )
-    trim-newline [ "comments" ] get-style write-attr ;
+    trim-newline "comments" get-style write-attr ;
 
 : word-link ( word -- link )
     <%
index b32a3a504700bdd1a1075ebef51cd6cb913535e9..539c5c4650477e1a72bffc2f5ac5ef4decac9580 100644 (file)
@@ -36,32 +36,11 @@ USE: stack
 ! significance to the 'fwrite-attr' word when applied to a
 ! stream that supports attributed string output.
 
-: default-style ( -- style )
-    #! Push the default style object.
-    "styles" get [ "default" get ] bind ;
-
-: paragraph ( -- style )
-    #! Push the paragraph break meta-style.
-    "styles" get [ "paragraph" get ] bind ;
-
-: <style> ( alist -- )
-    #! Create a new style object, cloned from the default
-    #! style.
-    default-style clone tuck alist> ;
-
-: get-style ( obj-path -- style )
-    #! Push a style named by an object path, for example
-    #! [ "prompt" ] or [ "vocabularies" "math" ].
-    dup [
-        "styles" get [ object-path ] bind
-        [ default-style ] unless*
-    ] [
-        drop default-style
-    ] ifte ;
-
-: set-style ( style name -- )
-    ! XXX: use object path...
-    "styles" get [ set ] bind ;
+: (get-style) ( name -- style ) "styles" get get* ;
+: default-style ( -- style ) "default" (get-style) ;
+: get-style ( name -- style )
+    (get-style) [ default-style ] unless* ;
+: set-style ( style name -- ) "styles" get set* ;
 
 <namespace> "styles" set
 
index 6ecce2f2f21f1febe6b5d3443b31ed8e60057375..1865674d2406bd8c1d560acffa5cecda4e646004 100644 (file)
@@ -90,8 +90,4 @@ test-word
 
 [ [ 1 1 0 0 ] ] [ [ system-property ] ] [ balance>list ] test-word
 
-! Make sure callstack only clones callframes, and not
-! everything on the callstack.
-[ ] [ ] [ f unit dup dup set-cdr >r callstack r> 2drop ] test-word
-
 [ t ] [ "ifte" intern dup worddef word-of-worddef = ] unit-test
index c1569b6da71668f9293c49ed91c7b534ca0e9ccb..6f3ee1ec900cbdd0220fdcba6d2e2d34fb070827 100644 (file)
@@ -7,9 +7,6 @@ USE: test
 ! jvar-get
 "car" must-compile
 
-! jvar-set
-"set-car" must-compile
-
 ! jvar-get-static
 "version" must-compile
 
index 1249bac4b15b07cf7134f911a63aa1d9b710803c..9d82af3315d883c4234e2224ee5dad886a330b5a 100644 (file)
@@ -25,4 +25,3 @@ USE: test
 
 [ [ 1 2 ]   ] [ 1 2   2list  ] unit-test
 [ [ 1 2 3 ] ] [ 1 2 3 3list  ] unit-test
-[ [ 2 1 ]   ] [ 1 2   2rlist ] unit-test
diff --git a/library/test/lists/destructive.factor b/library/test/lists/destructive.factor
deleted file mode 100644 (file)
index 6dc8bd8..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-IN: scratchpad
-USE: lists
-USE: namespaces
-USE: stack
-USE: test
-
-[ "a" | "b" ] clone-list "x" set
-[ [ 1 | "b" ] ] [ 1 "x" get set-car "x" get ] unit-test
-
-[ "a" | "b" ] clone-list "x" set
-[ [ "a" | 2 ] ] [ 2 "x" get set-cdr "x" get ] unit-test
-
-: clone-and-nappend ( list list -- list )
-    swap clone-list swap clone-list nappend ;
-
-[ [ ]         ] [ [ ]   [ ]       clone-and-nappend ] unit-test
-[ [ 1 ]       ] [ [ 1 ] [ ]       clone-and-nappend ] unit-test
-[ [ 2 ]       ] [ [ ] [ 2 ]       clone-and-nappend ] unit-test
-[ [ 1 2 3 4 ] ] [ [ 1 2 3 ] [ 4 ] clone-and-nappend ] unit-test
-
-: clone-and-nreverse ( list -- list )
-    clone-list nreverse ;
-
-[ [ ]       ] [ [ ]       clone-and-nreverse ] unit-test
-[ [ 1 ]     ] [ [ 1 ]     clone-and-nreverse ] unit-test
-[ [ 3 2 1 ] ] [ [ 1 2 3 ] clone-and-nreverse ] unit-test
-
-[ 1 2 3 ] clone-list "x" set [ 4 5 6 ] clone-list "y" set
-
-[ [ 4 5 6 ] ] [ "x" get "y" get nappend drop "y" get ] unit-test
-
-[ 1 2 3 ] clone-list "x" set [ 4 5 6 ] clone-list "y" set
-
-[ [ 1 2 3 4 5 6 ] ] [ "x" get "y" get ] [ nappend drop "x" get ] test-word
index 6d59a15afe88630244a4a0f35d1ad33d5d919760..3ef6163ce7cb9f9c66925c0b4b817679a6bc6562 100644 (file)
@@ -7,14 +7,11 @@ USE: test
 
 [ [ 2 1 0 0 ] ] [ [ 2list ] ] [ balance>list ] test-word
 [ [ 3 1 0 0 ] ] [ [ 3list ] ] [ balance>list ] test-word
-[ [ 2 1 0 0 ] ] [ [ 2rlist ] ] [ balance>list ] test-word
 [ [ 2 1 0 0 ] ] [ [ append ] ] [ balance>list ] test-word
-[ [ 2 0 0 0 ] ] [ [ append@ ] ] [ balance>list ] test-word
 [ [ 1 1 0 0 ] ] [ [ array>list ] ] [ balance>list ] test-word
 [ [ 2 0 0 0 ] ] [ [ add@ ] ] [ balance>list ] test-word
 [ [ 1 1 0 0 ] ] [ [ car ] ] [ balance>list ] test-word
 [ [ 1 1 0 0 ] ] [ [ cdr ] ] [ balance>list ] test-word
-[ [ 1 1 0 0 ] ] [ [ clone-list ] ] [ balance>list ] test-word
 [ [ 2 1 0 0 ] ] [ [ cons ] ] [ balance>list ] test-word
 [ [ 2 1 0 0 ] ] [ [ contains? ] ] [ balance>list ] test-word
 [ [ 2 0 0 0 ] ] [ [ cons@ ] ] [ balance>list ] test-word
@@ -25,12 +22,9 @@ USE: test
 [ [ 1 1 0 0 ] ] [ [ length ] ] [ balance>list ] test-word
 [ [ 1 1 0 0 ] ] [ [ list? ] ] [ balance>list ] test-word
 [ [ 1 1 0 0 ] ] [ [ nreverse ] ] [ balance>list ] test-word
-[ [ 2 1 0 0 ] ] [ [ nappend ] ] [ balance>list ] test-word
 [ [ 1 1 0 0 ] ] [ [ cons? ] ] [ balance>list ] test-word
 [ [ 2 1 0 0 ] ] [ [ remove ] ] [ balance>list ] test-word
 [ [ 1 1 0 0 ] ] [ [ reverse ] ] [ balance>list ] test-word
-[ [ 2 0 0 0 ] ] [ [ set-car ] ] [ balance>list ] test-word
-[ [ 2 0 0 0 ] ] [ [ set-cdr ] ] [ balance>list ] test-word
 [ [ 2 2 0 0 ] ] [ [ [ < ] partition ] ] [ balance>list ] test-word
 [ [ 2 2 0 0 ] ] [ [ [ nip string? ] partition ] ] [ balance>list ] test-word
 [ [ 1 1 0 0 ] ] [ [ num-sort ] ] [ balance>list ] test-word
@@ -41,7 +35,6 @@ USE: test
 [ [ 2 1 0 0 ] ] [ [ unique ] ] [ balance>list ] test-word
 [ [ 1 1 0 0 ] ] [ [ unit ] ] [ balance>list ] test-word
 [ [ 1 2 0 0 ] ] [ [ unswons ] ] [ balance>list ] test-word
-[ [ 1 1 0 0 ] ] [ [ deep-clone ] ] [ balance>list ] test-word
 
 [ [ ]       ] [ [ ]       ] [ array>list ] test-word
 [ [ 1 2 3 ] ] [ [ 1 2 3 ] ] [ array>list ] test-word
index a6f07b89df040968a3e0dff0035f3b51ebf3dcc3..6fdfb074931c471606528faeaba4520713a31e15 100644 (file)
@@ -13,16 +13,6 @@ USE: test
 [ [ 1 2 3 4 ]   ] [ [ 1 2 3 ] [ 4 ] append ] unit-test
 [ [ 1 2 3 | 4 ] ] [ [ 1 2 3 ] 4     append ] unit-test
 
-[ [ ]         ] [ [ ]         clone-list ] unit-test
-[ [ 1 2 | 3 ] ] [ [ 1 2 | 3 ] clone-list ] unit-test
-[ [ 1 2 3 4 ] ] [ [ 1 2 3 4 ] clone-list ] unit-test
-
-: clone-list-actually-clones? ( list1 list2 -- )
-    >r clone-list ! we don't want to mutate literals
-    dup clone-list r> nappend = not ;
-
-[ t ] [ [ 1 2 ] [ 3 4 ] clone-list-actually-clones? ] unit-test
-
 [ f         ] [ 3 [ ]     contains? ] unit-test
 [ f         ] [ 3 [ 1 2 ] contains? ] unit-test
 [ [ 1 2 ]   ] [ 1 [ 1 2 ] contains? ] unit-test
@@ -48,10 +38,6 @@ USE: test
 [ t ] [ [ 1 2 ]   list? ] unit-test
 [ f ] [ [ 1 | 2 ] list? ] unit-test
 
-[ 2 ] [ 1 [ 1 2 3 ] next ] unit-test
-[ 1 ] [ 3 [ 1 2 3 ] next ] unit-test
-[ 1 ] [ 4 [ 1 2 3 ] next ] unit-test
-
 [ [ ]       ] [ 1 [ ]           remove ] unit-test
 [ [ ]       ] [ 1 [ 1 ]         remove ] unit-test
 [ [ 3 1 1 ] ] [ 2 [ 3 2 1 2 1 ] remove ] unit-test
@@ -75,13 +61,3 @@ USE: test
 [ [ 0 1 2 3 ] ] [ 4   count ] unit-test
 
 [ [ 1 2 3 ] ] [ [ 1 4 2 5 3 6 ] [ 4 < ] subset ] unit-test
-
-[ [ t f t f ] ] [ f 1 [ t 1 t 1 ] substitute ] unit-test
-
-[ [ 0 1 2 4 5 6 7 8 9 ] ] [ 3 10 count remove-nth ] unit-test
-[ [ 1 2 3 4 5 6 7 8 9 ] ] [ 0 10 count remove-nth ] unit-test
-[ [ 0 1 2 3 4 5 6 7 8 ] ] [ 9 10 count remove-nth ] unit-test
-
-[ [ 1 2 3 ] ] [ 2 1 [ 1 3 3 ] set-nth ] unit-test
-[ [ 1 2 3 ] ] [ 1 0 [ 2 2 3 ] set-nth ] unit-test
-[ [ 1 2 3 ] ] [ 3 2 [ 1 2 2 ] set-nth ] unit-test
index 40bbba01ea250761a4a46f2a46fd03dd9d060d72..2bca360fa548eb06e7196d45de1da9802bde45b1 100644 (file)
@@ -3,10 +3,6 @@ USE: lists
 USE: namespaces
 USE: test
 
-[ [ 1 2 3 4 ] ] [ [ 3 4 ] [ 1 2 ] ] [ "x" set "x" append@ "x" get ] test-word
-
-[ [ 1 2 3 4 ] ] [ 4 [ 1 2 3 ] ] [ "x" set "x" add@ "x" get ] test-word
-
 [ [ 1 ] ] [ 1 f ] [ "x" set "x" cons@ "x" get ] test-word
 [ [ 1 | 2 ] ] [ 1 2 ] [ "x" set "x" cons@ "x" get ] test-word
 [ [ 1 2 ] ] [ 1 [ 2 ] ] [ "x" set "x" cons@ "x" get ] test-word
@@ -42,5 +38,3 @@ USE: test
     1/5 , 1/5 unique,
     [, { } unique, ,] , ,]
 ] unit-test
-
-[ [ 1 2 3 4 ] ] [ [, 1 , [ 2 3 ] list, 4 , ,] ] unit-test
index 0d6a6ad0b43057ab2073ba3ad671069912537e8c..def16ace6e72d80fa296e82596298c5616a3cf11 100644 (file)
@@ -70,7 +70,6 @@ USE: unparser
         "lists/cons"
         "lists/lists"
         "lists/assoc"
-        "lists/destructive"
         "lists/namespaces"
         "combinators"
         "continuations"
index c118e88c0164519cf5da58f36ba5fe2765c440c0..1ab7dc392bc3626c9d1e41bc9f389871ecc30781 100644 (file)
@@ -33,23 +33,18 @@ USE: namespaces
 USE: stack
 USE: styles
 
-: get-vocab-style ( vocab -- style )
+: vocab-style ( vocab -- style )
     #! Each vocab has a style object specifying how words are
     #! to be printed.
-    "vocabularies" 2rlist get-style ;
+    "vocabularies" get-style get* ;
 
 : set-vocab-style ( style vocab -- )
-    swap default-style append swap
-    [ "styles" "vocabularies" ] object-path set* ;
+    >r default-style append r> "vocabularies" get-style set* ;
 
 : word-style ( word -- style )
-    word-vocabulary dup [
-        get-vocab-style
-    ] [
-        drop default-style
-    ] ifte ;
+    word-vocabulary [ vocab-style ] [ default-style ] ifte* ;
 
-"styles" get [ <namespace> "vocabularies" set ] bind
+<namespace> "vocabularies" set-style
 
 [
     [ "ansi-fg" | "1" ]
index 0a897090fce8938d37c464316261240a5a0a9a3e..1f97aa396361025ab8c89024ecf850f803160214 100644 (file)
@@ -24,17 +24,3 @@ void primitive_cdr(void)
 {
        drepl(cdr(dpeek()));
 }
-
-void primitive_set_car(void)
-{
-       CELL cons = dpop();
-       CELL car = dpop();
-       untag_cons(cons)->car = car;
-}
-
-void primitive_set_cdr(void)
-{
-       CELL cons = dpop();
-       CELL cdr = dpop();
-       untag_cons(cons)->cdr = cdr;
-}
index 2cab122e829b9c57b694f8ea7f1d5d79e74b3094..ee0028db05502bd70f777d14312934eeb7aafb5d 100644 (file)
@@ -29,5 +29,3 @@ INLINE CELL cdr(CELL cons)
 void primitive_cons(void);
 void primitive_car(void);
 void primitive_cdr(void);
-void primitive_set_car(void);
-void primitive_set_cdr(void);
index 554d145044a75fd60369654424667adeebfd318a..98a3147cedb0ba6ec8d2df2b589ff4457b1d7c2f 100644 (file)
@@ -10,8 +10,6 @@ XT primitives[] = {
        primitive_cons,
        primitive_car,
        primitive_cdr,
-       primitive_set_car,
-       primitive_set_cdr,
        primitive_vector,
        primitive_vector_length,
        primitive_set_vector_length,
index 430e5f8ec75aebffd97c2e771775dd1174c564aa..fcaddc66ee1bd273e0eb4fe84adede44e7612a65 100644 (file)
@@ -1,4 +1,4 @@
 extern XT primitives[];
-#define PRIMITIVE_COUNT 196
+#define PRIMITIVE_COUNT 194
 
 CELL primitive_to_xt(CELL primitive);