Paste: idea for -unsafe words/validators
Author: | erg |
Mode: | factor |
Date: | Tue, 13 Sep 2011 18:20:53 |
Plain Text |
HOOK: (send) io-backend
M: unix (send)
[ make-sockaddr/size ] [ [ handle>> ] keep ] bi* do-send ;
ERROR: invalid-port object ;
: check-port
2dup addr>> [ class ] bi@ assert=
pick class byte-array assert= ;
: check-connectionless-port
dup { [ datagram-port? ] [ raw-port? ] } 1|| [ invalid-port ] unless ;
: check-send
check-connectionless-port dup check-disposed check-port ;
: send check-send (send) ;
---------------------
V: send
check-connectionless-port dup check-disposed check-port ;
: send (send) ;
or
V: send check-connectionless-port ;
V: send dup check-disposed ;
V: send check-port ;
: send (send) ;
Calling send would call all of the V: validators as before-methods (in random order). Calling send-unsafe would call (send) directly.
V: could require leaving all the arguments on the stack or dropping them.
You could also do more things with static type declarations and multimethods.
New Annotation