# Question about LHS in some val assignments

**URL:** <https://discourse.ats-lang.org/t/question-about-lhs-in-some-val-assignments/726>\
**Category:** Google Group\
**Created:** [January 13, 2014, 1:52am UTC](https://discourse.ats-lang.org/t/question-about-lhs-in-some-val-assignments/726 "2014-01-13T01:52:32Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [January 13, 2014, 1:52am UTC](https://discourse.ats-lang.org/t/question-about-lhs-in-some-val-assignments/726/1 "2014-01-13T01:52:32Z")

</div>

I’m curious what is happening in e.g. left of the “=”:

val _0_ = linset\_insert\_ngc (xs, nx)  
val-(9) = mynode\_getfree\_elt (nx2)

---

<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:** [January 13, 2014, 1:58am UTC](https://discourse.ats-lang.org/t/question-about-lhs-in-some-val-assignments/726/2 "2014-01-13T01:58:45Z")

</div>

_0_ is just a variable name.

'val-(9) is the same as val- 9;  
so ‘val-(9) = …’ expects the right-hand side to return 9;  
if not, a run-time matching failure aborts the execution.On Sunday, January 12, 2014 8:52:32 PM UTC-5, Brandon Barker wrote:

> I’m curious what is happening in e.g. left of the “=”:
> 
> val _0_ = linset\_insert\_ngc (xs, nx)  
> val-(9) = mynode\_getfree\_elt (nx2)

---

<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:** [January 13, 2014, 2:01am UTC](https://discourse.ats-lang.org/t/question-about-lhs-in-some-val-assignments/726/3 "2014-01-13T02:01:20Z")

</div>

For instance:

val-(9) = 3 \* 3 // okay  
val-(9) = 3 + 7 // run-time failure

Give it a try and you will see what happens.On Sunday, January 12, 2014 8:58:45 PM UTC-5, gmhwxi wrote:

> _0_ is just a variable name.
> 
> 'val-(9) is the same as val- 9;  
> so ‘val-(9) = …’ expects the right-hand side to return 9;  
> if not, a run-time matching failure aborts the execution.
> 
> On Sunday, January 12, 2014 8:52:32 PM UTC-5, Brandon Barker wrote:
> 
> > I’m curious what is happening in e.g. left of the “=”:
> > 
> > val _0_ = linset\_insert\_ngc (xs, nx)  
> > val-(9) = mynode\_getfree\_elt (nx2)

---

<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:** [January 13, 2014, 3:09am UTC](https://discourse.ats-lang.org/t/question-about-lhs-in-some-val-assignments/726/4 "2014-01-13T03:09:37Z")

</div>

This seems to be a convenient notation for assertloc, except that in  
addition to what assertloc will do, it also prints this message:  
exit(ATS): unmatched value at run-time:On Sunday, January 12, 2014 9:01:20 PM UTC-5, gmhwxi wrote:

> For instance:
> 
> val-(9) = 3 \* 3 // okay  
> val-(9) = 3 + 7 // run-time failure
> 
> Give it a try and you will see what happens.
> 
> On Sunday, January 12, 2014 8:58:45 PM UTC-5, gmhwxi wrote:
> 
> > _0_ is just a variable name.
> > 
> > 'val-(9) is the same as val- 9;  
> > so ‘val-(9) = …’ expects the right-hand side to return 9;  
> > if not, a run-time matching failure aborts the execution.
> > 
> > On Sunday, January 12, 2014 8:52:32 PM UTC-5, Brandon Barker wrote:
> > 
> > > I’m curious what is happening in e.g. left of the “=”:
> > > 
> > > val _0_ = linset\_insert\_ngc (xs, nx)  
> > > val-(9) = mynode\_getfree\_elt (nx2)
