 			}
 		}
 		
-		/**
-		 * @param operatorName
-		 * @param compiledParams
-		 * @return 
-		 */
 		private function compileOperator(operatorName:String, compiledParams:Array):CompiledFunctionCall
 		{
-			// special case for inline functions
-			if (operatorName == FUNCTION || operatorName == '=>')
-			{
-				// compiledParams should have two parameters: argument list and function body
-				var args:CompiledFunctionCall = compiledParams[0] as CompiledFunctionCall;
-				var body:ICompiledObject = compiledParams[1] as ICompiledObject;
-				if (compiledParams.length != 2 || !args || !body)
-					throwInvalidSyntax(operatorName);
-				
-				// if there is only a single variable name, wrap it in an operator ',' call
-				if (!args.compiledParams)
-					args = compileOperator(',', [args]);
-				
-				if (args.evaluatedMethod != operators[','])
-					throwInvalidSyntax(operatorName);
-				
-				// verify that each parameter inside operator ',' is a variable name or a local assignment to a constant.
-				var variableNames:Array = [];
-				var variableValues:Array = [];
-				for each (var token:Object in args.compiledParams)
-				{
-					var variable:CompiledFunctionCall = token as CompiledFunctionCall;
-					if (!variable)
-						throwInvalidSyntax(operatorName);
-					
-					if (!variable.compiledParams)
-					{
-						// local variable
-						variableNames.push(variable.evaluatedMethod);
-						variableValues.push(undefined);
-					}
-					else if (variable.evaluatedMethod == operators['='] && variable.compiledParams.length == 2 && variable.compiledParams[1] is CompiledConstant)
-					{
-						// local variable assignment
-						variableNames.push(variable.evaluatedParams[0]);
-						variableValues.push(variable.evaluatedParams[1]);
-					}
-					else
-						throwInvalidSyntax(operatorName);
-				}
-				var functionParams:Object = {};
-				functionParams[FUNCTION_PARAM_NAMES] = variableNames;
-				functionParams[FUNCTION_PARAM_VALUES] = variableValues;
-				functionParams[FUNCTION_CODE] = finalize(body);
-				
-				compiledParams = [new CompiledConstant(null, functionParams)];
-			}
-			
 			operatorName = OPERATOR_ESCAPE + operatorName;
 			return new CompiledFunctionCall(new CompiledConstant(operatorName, constants[operatorName]), compiledParams);
+		}
+		
+		private function compileFunctionHeader(functionOperator:String, paramsToken:Object):ICompiledObject
+		{
+			if (functionOperator != FUNCTION && functionOperator != '=>')
+				throw new Error("compileFunctionHeader called with unsupported operator: " + functionOperator);
+			
+			// when compiling a function operator, only the argument list should be provided
+			var args:CompiledFunctionCall = paramsToken as CompiledFunctionCall;
+			if (!args)
+				throwInvalidSyntax(functionOperator);
+			
+			// if there is only a single variable name, wrap it in an operator ',' call
+			if (!args.compiledParams)
+				args = compileOperator(',', [args]);
+			
+			if (args.evaluatedMethod != operators[','])
+				throwInvalidSyntax(functionOperator);
+			
+			// verify that each parameter inside operator ',' is a variable name or a local assignment to a constant.
+			var variableNames:Array = [];
+			var variableValues:Array = [];
+			for each (var token:Object in args.compiledParams)
+			{
+				var variable:CompiledFunctionCall = token as CompiledFunctionCall;
+				if (!variable)
+					throwInvalidSyntax(functionOperator);
+				
+				if (!variable.compiledParams)
+				{
+					// local variable
+					variableNames.push(variable.evaluatedMethod);
+					variableValues.push(undefined);
+				}
+				else if (variable.evaluatedMethod == operators['='] && variable.compiledParams.length == 2 && variable.compiledParams[1] is CompiledConstant)
+				{
+					// local variable assignment
+					variableNames.push(variable.evaluatedParams[0]);
+					variableValues.push(variable.evaluatedParams[1]);
+				}
+				else
+					throwInvalidSyntax(functionOperator);
+			}
+			var functionParams:Object = {};
+			functionParams[FUNCTION_PARAM_NAMES] = variableNames;
+			functionParams[FUNCTION_PARAM_VALUES] = variableValues;
+			
+			return compileOperator(functionOperator, [new CompiledConstant(null, functionParams)]);
+		}
+		
+		private function compileFunctionDefinition(functionHeader:CompiledFunctionCall, body:ICompiledObject):ICompiledObject
+		{
+			if (!body)
+				throwInvalidSyntax((functionHeader.compiledMethod as CompiledConstant).name.substr(OPERATOR_ESCAPE.length));
+			var cc:CompiledConstant = functionHeader.compiledParams[0];
+			if (cc.value[FUNCTION_CODE] != null)
+				throw new Error("Unexpected error: attempting to overwrite function body");
+			cc.value[FUNCTION_CODE] = finalize(body);
+			functionHeader.evaluateConstants();
+			return functionHeader;
 		}
 		
 		private function compileVariableAssignment(variableToken:*, assignmentOperator:String, valueToken:*):CompiledFunctionCall

			if (Math.max(tokens.indexOf('?')) >= 0)
				throw new Error('Invalid conditional branch');
			
			// next step: inline functions, right to left
			i = tokens.length;
			while (i--)
			{
				if (tokens[i] == FUNCTION)
					tokens.splice(i, 3, compileOperator(FUNCTION, [tokens[i + 1], tokens[i + 2]]));
				if (tokens[i] == '=>')
					tokens.splice(i - 1, 3, compileOperator('=>', [tokens[i - 1], tokens[i + 1]]));
			}
			
			// next step: function applications

			return cfc && !cfc.compiledParams;
		}
		
		private function isFunctionHeader(token:Object):Boolean
		{
			var cfc:CompiledFunctionCall = token as CompiledFunctionCall;
			return cfc && (cfc.evaluatedMethod == operators[FUNCTION] || cfc.evaluatedMethod == operators['=>'])
				&& cfc.evaluatedParams[0][FUNCTION_CODE] === undefined;
		}
		
		/**
		 * This will check if the compiled object is a function definition.
		 * @param compiledObject A compiled object returned by compileToObject().
