From bfd2fcf750f68e96af2522584674f7a40d23878d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 16 Jan 2009 14:12:10 -0600 Subject: [PATCH] help-lint doesn't check on value-words, this allows values to be documented. Also, make 'see' work with value words --- basis/help/lint/lint.factor | 18 ++++++++++++++---- basis/values/values.factor | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/basis/help/lint/lint.factor b/basis/help/lint/lint.factor index 9d4de09a87..831a6e5509 100644 --- a/basis/help/lint/lint.factor +++ b/basis/help/lint/lint.factor @@ -6,7 +6,7 @@ io io.streams.string prettyprint definitions arrays vectors combinators combinators.short-circuit splitting debugger hashtables sorting effects vocabs vocabs.loader assocs editors continuations classes.predicate macros math sets eval -vocabs.parser words.symbol ; +vocabs.parser words.symbol values ; IN: help.lint : check-example ( element -- ) @@ -42,12 +42,22 @@ IN: help.lint $error-description } swap '[ _ elements empty? not ] contains? ; +: don't-check-word? ( word -- ? ) + { + [ macro? ] + [ symbol? ] + [ value-word? ] + [ parsing-word? ] + [ "declared-effect" word-prop not ] + } 1|| ; + : check-values ( word element -- ) { - [ drop { [ symbol? ] [ macro? ] [ parsing-word? ] } 1|| ] - [ drop "declared-effect" word-prop not ] - [ nip contains-funky-elements? ] [ + [ don't-check-word? ] + [ contains-funky-elements? ] + bi* or + ] [ [ effect-values >array ] [ extract-values >array ] bi* = diff --git a/basis/values/values.factor b/basis/values/values.factor index 0dd1058370..75a37339b1 100644 --- a/basis/values/values.factor +++ b/basis/values/values.factor @@ -1,6 +1,7 @@ -! Copyright (C) 2008 Daniel Ehrenberg. +! Copyright (C) 2008, 2009 Daniel Ehrenberg, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel parser words sequences quotations ; +USING: accessors kernel parser words sequences quotations +combinators.short-circuit definitions ; IN: values ! Mutating literals in word definitions is not really allowed, @@ -22,12 +23,23 @@ TUPLE: value-holder < identity-tuple obj ; PRIVATE> +PREDICATE: value-word < word + def>> { + [ length 2 = ] + [ first value-holder? ] + [ second \ obj>> = ] + } 1&& ; + : VALUE: CREATE-WORD dup t "no-def-strip" set-word-prop T{ value-holder } clone [ obj>> ] curry (( -- value )) define-declared ; parsing +M: value-word definer drop \ VALUE: f ; + +M: value-word definition drop f ; + : set-value ( value word -- ) def>> first (>>obj) ;