From 955938d09d21464125061d3751e721f4b9822ce8 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 18 Nov 2020 20:41:34 -0800 Subject: [PATCH] core: using fry in a few places to see how it works. --- core/bootstrap/stage1.factor | 8 +------- core/continuations/continuations.factor | 10 ++++------ core/generic/single/single.factor | 11 ++++++----- core/hash-sets/hash-sets.factor | 19 +++++++++---------- core/sets/sets.factor | 8 ++++---- 5 files changed, 24 insertions(+), 32 deletions(-) diff --git a/core/bootstrap/stage1.factor b/core/bootstrap/stage1.factor index 9151aae855..df26a6cb55 100644 --- a/core/bootstrap/stage1.factor +++ b/core/bootstrap/stage1.factor @@ -2,8 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: assocs bootstrap.image.private hash-sets hashtables init io io.files kernel kernel.private make memory namespaces parser -parser.notes sequences system vocabs vocabs.hierarchy -vocabs.loader ; +parser.notes sequences system vocabs vocabs.loader ; IN: bootstrap.stage1 "Bootstrap stage 1..." print flush @@ -39,11 +38,6 @@ load-help? off "locals.fry" require "locals.macros" require -! "resource:core" disk-vocabs-in-root -! [ vocab-prefix? ] reject -! [ vocab-name "test" swap subseq? ] reject -! require-all - "vocab:bootstrap/layouts.factor" parse-file % [ diff --git a/core/continuations/continuations.factor b/core/continuations/continuations.factor index 577ae71aaf..12bb976a0a 100644 --- a/core/continuations/continuations.factor +++ b/core/continuations/continuations.factor @@ -151,15 +151,13 @@ callback-error-hook [ [ die rethrow ] ] initialize [ drop ] recover ; inline : ignore-error ( quot check: ( error -- ? ) -- ) - [ dup ] prepose [ [ drop ] [ rethrow ] if ] compose - recover ; inline + '[ dup @ [ drop ] [ rethrow ] if ] recover ; inline : ignore-error/f ( quot check: ( error -- ? ) -- ) - [ dup ] prepose [ [ drop f ] [ rethrow ] if ] compose - recover ; inline + '[ dup @ [ drop f ] [ rethrow ] if ] recover ; inline : cleanup ( try cleanup-always cleanup-error -- ) - [ compose [ dip rethrow ] curry recover ] [ drop ] 2bi call ; inline + [ '[ [ @ @ ] dip rethrow ] recover ] [ drop ] 2bi call ; inline : finally ( try cleanup-always -- ) [ ] cleanup ; inline @@ -171,7 +169,7 @@ ERROR: attempt-all-error ; attempt-all-error ] [ [ - [ [ , f ] compose [ , drop t ] recover ] curry all? + '[ [ @ , f ] [ , drop t ] recover ] all? ] { } make last swap [ rethrow ] when ] if ; inline diff --git a/core/generic/single/single.factor b/core/generic/single/single.factor index 4dec5b9d83..7d38b2c603 100644 --- a/core/generic/single/single.factor +++ b/core/generic/single/single.factor @@ -41,14 +41,15 @@ HOOK: picker combination ( -- quot ) M: single-combination next-method-quot* [ - 2dup next-method dup [ + 2dup next-method [ [ - pick predicate-def % + [ picker % ] 3dip + [ dup predicate-def % ] 2dip 1quotation , [ inconsistent-next-method ] 2curry , \ if , - ] [ ] make picker prepend - ] [ 3drop f ] if + ] [ ] make + ] [ 2drop f ] if* ] with-combination ; : method-for-object ( obj word -- method ) @@ -59,7 +60,7 @@ M: single-combination next-method-quot* bi or ; M: single-combination make-default-method - [ [ picker ] dip [ no-method ] curry append ] with-combination ; + [ [ picker ] dip '[ @ _ no-method ] ] with-combination ; ! ! ! Build an engine ! ! ! diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index aec8aa77f1..00b72ff75f 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -74,14 +74,14 @@ TUPLE: hash-set ] if ; inline : (rehash) ( seq hash -- ) - [ (adjoin) drop ] curry each ; inline + '[ _ (adjoin) drop ] each ; inline : hash-large? ( hash -- ? ) [ count>> 1 fixnum+fast 3 fixnum*fast ] [ array>> length>> 1 fixnum-shift-fast ] bi fixnum>= ; inline : each-member ( ... array quot: ( ... elt -- ... ) -- ... ) - [ if ] curry [ dup tombstone? [ drop ] ] prepose each ; inline + '[ dup tombstone? [ drop ] _ if ] each ; inline : grow-hash ( hash -- ) { hash-set } declare [ @@ -147,18 +147,17 @@ INSTANCE: hash-set set > ] dip [ in? ] curry ; inline + [ array>> ] dip '[ _ in? ] ; inline : filter-members ( hash-set array quot: ( elt -- ? ) -- accum ) - [ dup ] prepose rot cardinality [ - [ push-unsafe ] curry [ [ drop ] if ] curry - compose each + rot cardinality [ + '[ dup @ [ _ push-unsafe ] [ drop ] if ] each ] keep ; inline PRIVATE> @@ -213,7 +212,7 @@ M: f fast-set drop 0 ; M: sequence fast-set >hash-set ; M: sequence duplicates - dup length [ ?adjoin ] curry reject ; + dup length '[ _ ?adjoin ] reject ; M: sequence all-unique? - dup length [ ?adjoin ] curry all? ; + dup length '[ _ ?adjoin ] all? ; diff --git a/core/sets/sets.factor b/core/sets/sets.factor index 990b33d6f8..a42cf6dfd8 100644 --- a/core/sets/sets.factor +++ b/core/sets/sets.factor @@ -163,9 +163,9 @@ M: sequence clear-set ?members over adjoin-all ; : diff! ( set1 set2 -- set1 ) - dupd sequence/tester [ dup ] prepose pick - [ delete ] curry [ [ drop ] if ] curry compose each ; + dupd sequence/tester pick + '[ dup @ [ _ delete ] [ drop ] if ] each ; : intersect! ( set1 set2 -- set1 ) - dupd sequence/tester [ dup ] prepose [ not ] compose pick - [ delete ] curry [ [ drop ] if ] curry compose each ; + dupd sequence/tester pick + '[ dup @ [ drop ] [ _ delete ] if ] each ; -- 2.34.1