# Defining functions: types and names

**URL:** <https://alloytools.discourse.group/t/defining-functions-types-and-names/118>\
**Category:** Questions\
**Created:** [October 2, 2020, 9:45am UTC](https://alloytools.discourse.group/t/defining-functions-types-and-names/118 "2020-10-02T09:45:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![keithb\_b](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/keithb_b/32/7_2.png) [@keithb\_b](https://alloytools.discourse.group/u/keithb_b)\
**Post date:** [October 2, 2020, 9:45am UTC](https://alloytools.discourse.group/t/defining-functions-types-and-names/118/1 "2020-10-02T09:45:18Z")

</div>

Given

```
let multiplication_table =
      0 -> 0 -> 0
    + 0 -> 1 -> 0
    + 1 -> 0 -> 0
    + 1 -> 1 -> 1
    + 0 -> 2 -> 0
    + 2 -> 0 -> 0
    + 2 -> 1 -> 2
    + 1 -> 2 -> 2
    + 2 -> 2 -> 4

```

then these two `fun`s

```
fun mul_product_style: Int -> Int -> Int {
    multiplication_table
}

fun mul_dereference_style[x, y: Int]: Int{
    y::(x::(multiplication_table))
}

```

work exactly the same way at the call site,

```
run {
    all x, y: {i: Int | 0 <= i && i < 2} | {
             mul_product_style[x,y] = mul_dereference_style[x,y]
             mul_product_style[x][y] = mul_dereference_style[x][y]
          x::mul_product_style[y] = x::mul_dereference_style[y]
      y::(x::mul_product_style) = y::(x::mul_dereference_style)
        y.(x.mul_product_style) = y.(x.mul_dereference_style) 
    }
}

```

which suggests that they are the same relation. Questions:

1. Why does `mul_dereference_style` not create a relation that may be interrogated in the evaluator when `mul_product_style` does?
2. Why does not `mul_product_style = mul_dereference_style` compile?  
2.1 The error suggests that mul\_dereference\_style can _only_ be applied and not used as a name, as `mul_product_style` apparently can be, why this difference?
3. `fun mul_product_style: Int -> Int -> Int {multiplication_table}` does compile but `fun mul_dereference_style[x, y: Int]: Int{ multiplication_table}` does not. It seems that the two functions in fact of dissimilar types, even though they work identically in the `run` paragraph. Why so?
