bramstein/junify — Issue #1: Function Unification
Author: dfreeman
Created: 2012-02-13 03:34:48+00:00
State: open

> Functions are not considered atoms, nor can they be unified.

This is likely not so much an 'issue' as me simply displaying ignorance, but I'm curious: why aren't functions considered atoms?

I realize functions can only be characterized by their behavior, so true comparison is equivalent to solving the halting problem, etc, etc, but referential equality seems to me like a reasonable metric for unification.

For instance, the following seems completely reasonable to me:

```javascript
var x = function() { return 0; }
var y = function() { return 0; }

unify(x, y) // false
unify(x, x) // {}
```

I was actually fairly surprised to see unification succeed in a situation like the following. Even if the two 'methods' were behaviorally identical, having different identities it seems they should not unify.

```javascript
var x = {
field1: 0
field2: function(z) { return this.field1 + z }
};

var y = {
field1: 0
field2: function(z) { return this.field1 * z }
};

unify(x, y) // {}
```

I imagine there's an obvious use case here for which your decision makes sense, but I'm not coming up with it off the top of my head. Could you enlighten me?

Thanks!