indexing
	description: "[
		Objects representing delayed calls to a function,
		with some arguments possibly still open.
	]"
	note: "[
		Features are the same as those of ROUTINE,
		with `apply' made effective, and the addition
		of `last_result' and `item'.
	]"
	status: "See notice at end of class"
	date: "$Date$"
	revision: "$Revision$"

class interface
	FUNCTION [BASE_TYPE, OPEN_ARGS -> TUPLE, RESULT_TYPE]

feature -- Initialization

	adapt (other: ROUTINE [ANY, OPEN_ARGS])
			-- Initialize from other.
			-- Useful in descendants.
			-- (from ROUTINE)
		require -- from ROUTINE
			other_exists: other /= void
			conforming: conforms_to (other)
		ensure -- from ROUTINE
			same_call_status: other.callable implies callable
	
feature -- Access

	hash_code: INTEGER
			-- Hash code value.
			-- (from ROUTINE)
		ensure -- from HASHABLE
			good_hash_value: Result >= 0

	item (args: OPEN_ARGS): RESULT_TYPE
			-- Result of calling function with args as operands.
		require
			valid_operands: valid_operands (args)
			callable: callable

	last_result: RESULT_TYPE
			-- Result of last call, if any.

	open_operand_type (i: INTEGER): INTEGER
			-- Type of ith open operand.
			-- (from ROUTINE)
		require -- from ROUTINE
			positive: i >= 1
			within_bounds: i <= open_count

	operands: OPEN_ARGS
			-- Open operands.
			-- (from ROUTINE)

	postcondition (args: like operands): BOOLEAN
			-- Does current state satisfy routine's
			-- postcondition for args?
			-- (from ROUTINE)

	precondition (args: like operands): BOOLEAN
			-- Do args satisfy routine's precondition
			-- in current state?
			-- (from ROUTINE)

	target: ANY
			-- Target of call.
			-- (from ROUTINE)
	
feature -- Measurement

	open_count: INTEGER
			-- Number of open operands.
			-- (from ROUTINE)
	
feature -- Comparison

	is_equal (other: like Current): BOOLEAN
			-- Is associated function the same as the one
			-- associated with other?
		require -- from ANY
			other_not_void: other /= void
		ensure -- from ANY
			symmetric: Result implies other.is_equal (Current)
			consistent: standard_is_equal (other) implies Result
	
feature -- Status report

	callable: BOOLEAN
			-- Can routine be called on current object?
			-- (from ROUTINE)

	is_hashable: BOOLEAN
			-- May current object be hashed?
			-- (True if it is not its type's default.)
			-- (from HASHABLE)
		ensure -- from HASHABLE
			ok_if_not_default: Result implies (Current /= default)

	valid_operands (args: OPEN_ARGS): BOOLEAN
			-- Are args valid operands for this routine?
			-- (from ROUTINE)
	
feature -- Element change

	set_operands (args: OPEN_ARGS)
			-- Use args as operands for next call.
			-- (from ROUTINE)
		require -- from ROUTINE
			valid_operands: valid_operands (args)
	
feature -- Duplication

	copy (other: like Current)
			-- Use same function as other.
		require -- from ANY
			other_not_void: other /= void
			type_identity: same_type (other)
		ensure -- from ANY
			is_equal: is_equal (other)
		ensure then -- from ROUTINE
			same_call_status: other.callable implies callable
	
feature -- Basic operations

	apply
			-- Call function with operands as last set.
		require -- from ROUTINE
			valid_operands: valid_operands (operands)
			callable: callable

	call (args: OPEN_ARGS)
			-- Call routine with operands args.
			-- (from ROUTINE)
		require -- from ROUTINE
			valid_operands: valid_operands (args)
			callable: callable
	
invariant

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

indexing
	library: "[
			EiffelBase: Library of reusable components for Eiffel.
	]"
	status: "[
			Copyright 1986-2001 Interactive Software Engineering (ISE).
			For ISE customers the original versions are an ISE product
			covered by the ISE Eiffel license and support agreements.
	]"
	license: "[
			EiffelBase may now be used by anyone as FREE SOFTWARE to
			develop any product, public-domain or commercial, without
			payment to ISE, under the terms of the ISE Free Eiffel Library
			License (IFELL) at http://eiffel.com/products/base/license.html.
	]"
	source: "[
			Interactive Software Engineering Inc.
			ISE Building
			360 Storke Road, Goleta, CA 93117 USA
			Telephone 805-685-1006, Fax 805-685-6869
			Electronic mail <info@eiffel.com>
			Customer support http://support.eiffel.com
	]"
	info: "[
			For latest info see award-winning pages: http://eiffel.com
	]"

end -- class FUNCTION