Paste: Teapot

Author: littledan
Mode: factor
Date: Wed, 11 Mar 2009 00:53:41
Plain Text |
! Copyright (C) 2009 Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: stack-checker.transforms kernel fry words call
stack-checker continuations parser ;
IN: teapot

! I couldn't think of a name, and a teapot was the first thing
! I saw when I looked around the room

: infer? ( word quot -- ? )
    ! This is terrible
    [ [ "declared-effect" word-prop ] [ infer ] bi* = ]
    [ 3drop f ] recover ;

: call-transform ( word quot -- )
    over "declared-effect" word-prop
    '[ _ _ call-effect ] 0 define-transform ;

: define-teapot ( word definition -- )
    [ define ] [ 2dup infer? [ 2drop ] [ call-transform ] if ] 2bi ;

: TEAPOT: (:) define-teapot ; parsing

New Annotation

Summary:
Author:
Mode:
Body: