help-lint doesn't check on value-words, this allows values to be documented. Also, make 'see' work with value words

db4
Slava Pestov 2009-01-16 14:12:10 -06:00
parent af998eb073
commit bfd2fcf750
2 changed files with 28 additions and 6 deletions
basis

View File

@ -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* =

View File

@ -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) ;