diff --git a/basis/call/call-tests.factor b/basis/call/call-tests.factor new file mode 100644 index 0000000000..4a59a6d2fb --- /dev/null +++ b/basis/call/call-tests.factor @@ -0,0 +1,10 @@ +! Copyright (C) 2009 Daniel Ehrenberg. +! See http://factorcode.org/license.txt for BSD license. +USING: math tools.test call kernel ; +IN: call.tests + +[ 3 ] [ 1 2 [ + ] call( x y -- z ) ] unit-test +[ 1 2 [ + ] call( -- z ) ] must-fail +[ 1 2 [ + ] call( x y -- z a ) ] must-fail +[ 1 2 3 { 4 } ] [ 1 2 3 4 [ datastack nip ] call( x -- y ) ] unit-test +[ [ + ] call( x y -- z ) ] must-infer diff --git a/basis/call/call.factor b/basis/call/call.factor new file mode 100644 index 0000000000..363b024dff --- /dev/null +++ b/basis/call/call.factor @@ -0,0 +1,24 @@ +! Copyright (C) 2009 Daniel Ehrenberg. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel macros fry summary sequences generalizations accessors +continuations effects.parser parser ; +IN: call + +ERROR: wrong-values values quot length-required ; + +M: wrong-values summary + drop "Wrong number of values returned from quotation" ; + + + +MACRO: call-effect ( effect -- quot ) + [ in>> length ] [ out>> length ] bi + '[ [ _ narray ] dip [ with-datastack ] keep _ firstn-safe ] ; + +: call( + ")" parse-effect parsed \ call-effect parsed ; parsing