# Overload Syntax

**URL:** <https://discourse.ats-lang.org/t/overload-syntax/322>\
**Category:** Google Group\
**Created:** [December 9, 2013, 2:16am UTC](https://discourse.ats-lang.org/t/overload-syntax/322 "2013-12-09T02:16:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Blair](https://avatars.discourse-cdn.com/v4/letter/w/c68b51/32.png) [@William\_Blair](https://discourse.ats-lang.org/u/William_Blair)\
**Post date:** [December 9, 2013, 2:16am UTC](https://discourse.ats-lang.org/t/overload-syntax/322/1 "2013-12-09T02:16:09Z")

</div>

When I overload an operator with a function, I can use the following syntax

```
symintr .bar

fun foo_get_bar (foo): bar

overload .bar with foo_get_bar of 10

```

What does the “of x” part of the declaration stand for?

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [August 12, 2014, 12:16am UTC](https://discourse.ats-lang.org/t/overload-syntax/322/2 "2014-08-12T00:16:49Z")

</div>

It isn’t urgent but I guess I’m not clear on what the above (old comment)  
means " the dot notation overloading only when the type ‘foo’ is  
non-linear", since an arrayptr is linear (and it sill works).

Brandon Barker  
brandon…@gmail.comOn Mon, Aug 11, 2014 at 8:07 PM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:

> The former is a variant of the latter.
> 
> On Monday, August 11, 2014 1:51:52 PM UTC-4, Brandon Barker wrote:
> 
> > I’ve noticed that the linear analogue of " . " seems to be " → ". Is  
> > this just convention though? For instance, if ‘a’ is an arrayptr, both of  
> > these seem to typecheck:
> > 
> > val tmp = a-\>[0]
> > 
> > val tmp = (!a).[0]
> > 
> > On Sunday, December 8, 2013 11:02:25 PM UTC-5, gmhwxi wrote:
> > 
> > > By the way, the dot notation overloading only when the type ‘foo’ is  
> > > non-linear.
> > > 
> > > On Sunday, December 8, 2013 9:16:09 PM UTC-5, William Blair wrote:
> > > 
> > > > When I overload an operator with a function, I can use the following  
> > > > syntax
> > > > 
> > > > ```
> > > > symintr .bar
> > > > 
> > > > fun foo_get_bar (foo): bar
> > > > 
> > > > overload .bar with foo_get_bar of 10
> > > > 
> > > > ```
> > > > 
> > > > What does the “of x” part of the declaration stand for?
> > > 
> > > –  
> > > You received this message because you are subscribed to the Google Groups  
> > > “ats-lang-users” group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > email to [ats-lang-user...@googlegroups.com](mailto:ats-lang-user...@googlegroups.com).  
> > > To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> > > Visit this group at [http://groups.google.com/group/ats-lang-users](http://groups.google.com/group/ats-lang-users).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [August 12, 2014, 12:39am UTC](https://discourse.ats-lang.org/t/overload-syntax/322/3 "2014-08-12T00:39:44Z")

</div>

Ah, I think the “dot notation” I was thinking of is different since it is  
not overloaded in the way you have described (only is overloaded not  
“.”).

Brandon Barker  
brandon…@gmail.comOn Mon, Aug 11, 2014 at 8:27 PM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:

> In A.[i], the notation .[i] is considered a label.
> 
> Dot notation overloading means to use dot notation to refer to a function  
> call:
> 
> For instance, list\_head is a function. If one wants to write xs.head for  
> list\_head(xs),  
> then the following code is needed first:
> 
> overload .head with list\_head
> 
> Dot notation does not work if the argument of the involved function is  
> linear.
> 
> On Monday, August 11, 2014 8:17:11 PM UTC-4, Brandon Barker wrote:
> 
> > It isn’t urgent but I guess I’m not clear on what the above (old comment)  
> > means " the dot notation overloading only when the type ‘foo’ is  
> > non-linear", since an arrayptr is linear (and it sill works).
> > 
> > Brandon Barker  
> > [brand...@gmail.com](mailto:brand...@gmail.com)
> > 
> > On Mon, Aug 11, 2014 at 8:07 PM, gmhwxi [gmh...@gmail.com](mailto:gmh...@gmail.com) wrote:
> > 
> > > The former is a variant of the latter.
> > > 
> > > On Monday, August 11, 2014 1:51:52 PM UTC-4, Brandon Barker wrote:
> > > 
> > > > I’ve noticed that the linear analogue of " . " seems to be " → ". Is  
> > > > this just convention though? For instance, if ‘a’ is an arrayptr, both of  
> > > > these seem to typecheck:
> > > > 
> > > > val tmp = a-\>[0]
> > > > 
> > > > val tmp = (!a).[0]
> > > > 
> > > > On Sunday, December 8, 2013 11:02:25 PM UTC-5, gmhwxi wrote:
> > > > 
> > > > > By the way, the dot notation overloading only when the type ‘foo’ is  
> > > > > non-linear.
> > > > > 
> > > > > On Sunday, December 8, 2013 9:16:09 PM UTC-5, William Blair wrote:
> > > > > 
> > > > > > When I overload an operator with a function, I can use the following  
> > > > > > syntax
> > > > > > 
> > > > > > ```
> > > > > > symintr .bar
> > > > > > 
> > > > > > fun foo_get_bar (foo): bar
> > > > > > 
> > > > > > overload .bar with foo_get_bar of 10
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > What does the “of x” part of the declaration stand for?
> > > > > 
> > > > > –  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups “ats-lang-users” group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to [ats-lang...@googlegroups.com](mailto:ats-lang...@googlegroups.com).  
> > > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com).
> > > 
> > > Visit this group at [http://groups.google.com/group/ats-lang-users](http://groups.google.com/group/ats-lang-users).  
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%  
> > > [40googlegroups.com](http://40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > –  
> > You received this message because you are subscribed to the Google Groups  
> > “ats-lang-users” group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [ats-lang-user...@googlegroups.com](mailto:ats-lang-user...@googlegroups.com).  
> > To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> > Visit this group at [http://groups.google.com/group/ats-lang-users](http://groups.google.com/group/ats-lang-users).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/ats-lang-users/593e4031-31fb-4ff3-a130-b94321436c2a%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/593e4031-31fb-4ff3-a130-b94321436c2a%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/ats-lang-users/593e4031-31fb-4ff3-a130-b94321436c2a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/593e4031-31fb-4ff3-a130-b94321436c2a%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [December 9, 2013, 4:02am UTC](https://discourse.ats-lang.org/t/overload-syntax/322/4 "2013-12-09T04:02:25Z")

</div>

By the way, the dot notation overloading only when the type ‘foo’ is  
non-linear.On Sunday, December 8, 2013 9:16:09 PM UTC-5, William Blair wrote:

> When I overload an operator with a function, I can use the following syntax
> 
> ```
> symintr .bar
> 
> fun foo_get_bar (foo): bar
> 
> overload .bar with foo_get_bar of 10
> 
> ```
> 
> What does the “of x” part of the declaration stand for?

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [August 11, 2014, 5:51pm UTC](https://discourse.ats-lang.org/t/overload-syntax/322/5 "2014-08-11T17:51:52Z")

</div>

I’ve noticed that the linear analogue of " . " seems to be " → ". Is this  
just convention though? For instance, if ‘a’ is an arrayptr, both of these  
seem to typecheck:

val tmp = a-\>[0]

val tmp = (!a).[0]On Sunday, December 8, 2013 11:02:25 PM UTC-5, gmhwxi wrote:

> By the way, the dot notation overloading only when the type ‘foo’ is  
> non-linear.
> 
> On Sunday, December 8, 2013 9:16:09 PM UTC-5, William Blair wrote:
> 
> > When I overload an operator with a function, I can use the following  
> > syntax
> > 
> > ```
> > symintr .bar
> > 
> > fun foo_get_bar (foo): bar
> > 
> > overload .bar with foo_get_bar of 10
> > 
> > ```
> > 
> > What does the “of x” part of the declaration stand for?

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [May 19, 2015, 8:15pm UTC](https://discourse.ats-lang.org/t/overload-syntax/322/6 "2015-05-19T20:15:53Z")

</div>

Related, not about syntax, but about when overload is needed.

If I have a praxi with an argument then next after, a fun of the same name  
without an argument, if I refer to the praxi with an argument, ATS  
complains about an arity miss‑match. I can solve it either using different  
name for both, optionally introducing a symbol and overloading it, if I  
really want to use the same name for both in practice.

I though is was OK to expect the arity is enough to disambiguate, but it  
seems not and explicit overloading is necessary.Le lundi 9 décembre 2013 03:16:09 UTC+1, William Blair a écrit :

> When I overload an operator with a function, I can use the following syntax
> 
> ```
> symintr .bar
> 
> fun foo_get_bar (foo): bar
> 
> overload .bar with foo_get_bar of 10
> 
> ```
> 
> What does the “of x” part of the declaration stand for?

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [August 12, 2014, 12:27am UTC](https://discourse.ats-lang.org/t/overload-syntax/322/7 "2014-08-12T00:27:48Z")

</div>

In A.[i], the notation .[i] is considered a label.

Dot notation overloading means to use dot notation to refer to a function  
call:

For instance, list\_head is a function. If one wants to write xs.head for  
list\_head(xs),  
then the following code is needed first:

overload .head with list\_head

Dot notation does not work if the argument of the involved function is  
linear.On Monday, August 11, 2014 8:17:11 PM UTC-4, Brandon Barker wrote:

> It isn’t urgent but I guess I’m not clear on what the above (old comment)  
> means " the dot notation overloading only when the type ‘foo’ is  
> non-linear", since an arrayptr is linear (and it sill works).
> 
> Brandon Barker  
> [brand...@gmail.com](mailto:brand...@gmail.com) \<javascript:\>
> 
> On Mon, Aug 11, 2014 at 8:07 PM, gmhwxi \<[gmh...@gmail.com](mailto:gmh...@gmail.com) \<javascript:\>\> wrote:
> 
> > The former is a variant of the latter.
> > 
> > On Monday, August 11, 2014 1:51:52 PM UTC-4, Brandon Barker wrote:
> > 
> > > I’ve noticed that the linear analogue of " . " seems to be " → ". Is  
> > > this just convention though? For instance, if ‘a’ is an arrayptr, both of  
> > > these seem to typecheck:
> > > 
> > > val tmp = a-\>[0]
> > > 
> > > val tmp = (!a).[0]
> > > 
> > > On Sunday, December 8, 2013 11:02:25 PM UTC-5, gmhwxi wrote:
> > > 
> > > > By the way, the dot notation overloading only when the type ‘foo’ is  
> > > > non-linear.
> > > > 
> > > > On Sunday, December 8, 2013 9:16:09 PM UTC-5, William Blair wrote:
> > > > 
> > > > > When I overload an operator with a function, I can use the following  
> > > > > syntax
> > > > > 
> > > > > ```
> > > > > symintr .bar
> > > > > 
> > > > > fun foo_get_bar (foo): bar
> > > > > 
> > > > > overload .bar with foo_get_bar of 10
> > > > > 
> > > > > ```
> > > > > 
> > > > > What does the “of x” part of the declaration stand for?
> > > > 
> > > > –  
> > > > You received this message because you are subscribed to the Google Groups  
> > > > “ats-lang-users” group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > > email to [ats-lang...@googlegroups.com](mailto:ats-lang...@googlegroups.com) \<javascript:\>.  
> > > > To post to this group, send email to [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com)  
> > > > \<javascript:\>.  
> > > > Visit this group at [http://groups.google.com/group/ats-lang-users](http://groups.google.com/group/ats-lang-users).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/6028e39e-9ecf-4d40-97f0-066d3b315312%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [August 12, 2014, 12:07am UTC](https://discourse.ats-lang.org/t/overload-syntax/322/8 "2014-08-12T00:07:32Z")

</div>

The former is a variant of the latter.On Monday, August 11, 2014 1:51:52 PM UTC-4, Brandon Barker wrote:

> I’ve noticed that the linear analogue of " . " seems to be " → ". Is this  
> just convention though? For instance, if ‘a’ is an arrayptr, both of these  
> seem to typecheck:
> 
> val tmp = a-\>[0]
> 
> val tmp = (!a).[0]
> 
> On Sunday, December 8, 2013 11:02:25 PM UTC-5, gmhwxi wrote:
> 
> > By the way, the dot notation overloading only when the type ‘foo’ is  
> > non-linear.
> > 
> > On Sunday, December 8, 2013 9:16:09 PM UTC-5, William Blair wrote:
> > 
> > > When I overload an operator with a function, I can use the following  
> > > syntax
> > > 
> > > ```
> > > symintr .bar
> > > 
> > > fun foo_get_bar (foo): bar
> > > 
> > > overload .bar with foo_get_bar of 10
> > > 
> > > ```
> > > 
> > > What does the “of x” part of the declaration stand for?

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [December 9, 2013, 3:36am UTC](https://discourse.ats-lang.org/t/overload-syntax/322/9 "2013-12-09T03:36:41Z")

</div>

It is the priority/precedence of this instance of overload.

Say you have

overload .bar with foo1\_get\_bar (\* of 0 \*)  
overload .bar with foo2\_get\_bar of 10

In case where a tie needs to be broken between these two, foo2\_get\_bar  
is picked over foo1\_get\_bar.On Sunday, December 8, 2013 9:16:09 PM UTC-5, William Blair wrote:

> When I overload an operator with a function, I can use the following syntax
> 
> ```
> symintr .bar
> 
> fun foo_get_bar (foo): bar
> 
> overload .bar with foo_get_bar of 10
> 
> ```
> 
> What does the “of x” part of the declaration stand for?
