# operation keyword

3 replies [Last post]
stokemasterjack
Offline
Joined: 2006-05-04

Why did they get rid of operation?

stokemasterjack
Offline
Joined: 2006-05-04

I prefer the function / operation terms myself. The terms were consistent. A function (in math) *returns* something. It's a named expression. Has no side effects. An operation *does* something. Made since to me.

Anyway, I would rather see "bindable" instead of "bound".

"bindable" is more accurate. "bindable" is used (similarly) in other languages.

michael_heinrichs
Offline
Joined: 2007-11-15

Actually you are proving the point, because the return type has (almost) nothing to do with the distinction between a function and a bound function. It is about how a function behaves, when bound to something.

Look at this example:

[code]
var a: Integer;
var b: Integer;

function foo (x: Integer): Integer { return x + b; }
bound function moo (x: Integer): Integer { return x + b; }

var i = bind foo(a);
var j = bind moo(a);
[/code]

In the above example i and j will change, if a changes. But in a bound function, the function-body is taken into account when calculating the result. The variable j will also change, when b changes, because moo is aware of the fact that its result depends on b.

Another difference:

[code]
function expCalc(x: Integer): Integer { // some really expensive calculations }

function foo (x: Integer, y: Integer): Integer { return expCalc(x) + expCalc(y); }
bound function moo (x: Integer, y: Integer): Integer { return expCalc(x) + expCalc(y); }

var a: Integer;
var b: Integer;

var i = bind foo(a, b);
var j = bind moo(a, b);
[/code]

If the variable a changes, foo will recalculate expCalc(a) and expCalc(b). The function moo is aware of the fact that b did not change and it will just calculate expCalc(a) and add it to the cached result of expCalc(b).

The keyword bindable was rejected, because one might think, that only "bindable functions" can be used in binds, which is not true (see examples above).

michael_heinrichs
Offline
Joined: 2007-11-15

Because the distinction between "operation" and "function" was not clear and caused a lot of confusion. While I don't think the current distinction between "function" and "bound function" is perfect, most people agreed that it is a lot better.

If you have better suggestions, feel free to provide them. The current solution is not necessarily final.