# Consuming var views?

**URL:** https://discourse.ats-lang.org/t/consuming-var-views/511
**Category:** Google Group
**Created:** [September 8, 2014, 2:34am UTC](https://discourse.ats-lang.org/t/consuming-var-views/511 "2014-09-08T02:34:29Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Shea\_Levy](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Shea\_Levy](https://discourse.ats-lang.org/u/Shea_Levy)
#### Post date: [September 8, 2014, 2:34am UTC](https://discourse.ats-lang.org/t/consuming-var-views/511/1 "2014-09-08T02:34:29Z")

</div>

Hi all,

I have a function where I create an instance of a dataview from an  
@-view of a var, and after the function I then break the dataview back  
down into the component @-view. The compiler then complains that the  
component @-view is not consumed, how can I consume it?

~Shea

---

<div class="post-metadata">

### Author: ![Shea\_Levy](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Shea\_Levy](https://discourse.ats-lang.org/u/Shea_Levy)
#### Post date: [September 8, 2014, 2:47am UTC](https://discourse.ats-lang.org/t/consuming-var-views/511/2 "2014-09-08T02:47:15Z")

</div>

Simple reproduction:

> implement main() = let  
> var x = 1 : int  
> prval some = Some\_v(view@(x))  
> prval Some\_v y = some  
> in 0 end

gives me two errors:

> the linear dynamic variable [y$65(-1)] needs to be consumed but it is preserved with the type [S2EVar(0)] instead.  
> the linear dynamic variable [x$view$66(-1)] is preserved but with an incompatible type.

Which make sense to me but I’m not sure how to fix it.On Sun, Sep 07, 2014 at 10:40:37PM -0400, Hongwei Xi wrote:

> Code?
> 
> On Sun, Sep 7, 2014 at 10:34 PM, Shea Levy [sh...@shealevy.com](mailto:sh...@shealevy.com) wrote:
> 
> > Hi all,
> > 
> > I have a function where I create an instance of a dataview from an  
> > @-view of a var, and after the function I then break the dataview back  
> > down into the component @-view. The compiler then complains that the  
> > component @-view is not consumed, how can I consume it?
> > 
> > ~Shea
> > 
> > –  
> > 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/20140908023429.GC2286%40nixos.hsd1.nh.comcast.net](https://groups.google.com/d/msgid/ats-lang-users/20140908023429.GC2286%40nixos.hsd1.nh.comcast.net)  
> > .
> 
> –  
> 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/CAPPSPLqDYjgz5JoL\_rpmW%3Dxedzj%2BOFdiuvZPLrA2oRkh-7QK\_A%40mail.gmail.com](https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLqDYjgz5JoL_rpmW%3Dxedzj%2BOFdiuvZPLrA2oRkh-7QK_A%40mail.gmail.com).

---

<div class="post-metadata">

### Author: ![Zhiqiang\_Ren](https://avatars.discourse-cdn.com/v4/letter/z/9fc29f/32.png) [@Zhiqiang\_Ren](https://discourse.ats-lang.org/u/Zhiqiang_Ren)
#### Post date: [September 8, 2014, 8:30pm UTC](https://discourse.ats-lang.org/t/consuming-var-views/511/3 "2014-09-08T20:30:01Z")

</div>

prval some = Some\_v{int@x}(view@x)

Am I understanding correct that the static term {int@x} references a  
dynamic expression “x”? Thanks.On Sunday, September 7, 2014 10:34:32 PM UTC-4, Shea Levy wrote:

> Hi all,
> 
> I have a function where I create an instance of a dataview from an  
> @-view of a var, and after the function I then break the dataview back  
> down into the component @-view. The compiler then complains that the  
> component @-view is not consumed, how can I consume it?
> 
> ~Shea

---

<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: [September 8, 2014, 3:32am UTC](https://discourse.ats-lang.org/t/consuming-var-views/511/4 "2014-09-08T03:32:53Z")

</div>

implement main() = let  
var x = 1 : int  
prval some = Some\_v{int@x}(view@x)  
prval Some\_v y = some  
prval () = view@(x) := y  
in 0 endOn Sunday, September 7, 2014 10:47:18 PM UTC-4, Shea Levy wrote:

> Simple reproduction:
> 
> > implement main() = let  
> > var x = 1 : int  
> > prval some = Some\_v(view@(x))  
> > prval Some\_v y = some  
> > in 0 end
> 
> gives me two errors:
> 
> > the linear dynamic variable [y$65(-1)] needs to be consumed but it is  
> > preserved with the type [S2EVar(0)] instead.  
> > the linear dynamic variable [x$view$66(-1)] is preserved but with an  
> > incompatible type.
> 
> Which make sense to me but I’m not sure how to fix it.
> 
> On Sun, Sep 07, 2014 at 10:40:37PM -0400, Hongwei Xi wrote:
> 
> > Code?
> > 
> > On Sun, Sep 7, 2014 at 10:34 PM, Shea Levy \<[sh...@shealevy.com](mailto:sh...@shealevy.com) \<javascript:\>\> wrote:
> > 
> > > Hi all,
> > > 
> > > I have a function where I create an instance of a dataview from an  
> > > @-view of a var, and after the function I then break the dataview back  
> > > down into the component @-view. The compiler then complains that the  
> > > component @-view is not consumed, how can I consume it?
> > > 
> > > ~Shea
> > > 
> > > –  
> > > 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/20140908023429.GC2286%40nixos.hsd1.nh.comcast.net](https://groups.google.com/d/msgid/ats-lang-users/20140908023429.GC2286%40nixos.hsd1.nh.comcast.net)
> 
> > > .
> > 
> > –  
> > 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/CAPPSPLqDYjgz5JoL\_rpmW%3Dxedzj%2BOFdiuvZPLrA2oRkh-7QK\_A%40mail.gmail.com](https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLqDYjgz5JoL_rpmW%3Dxedzj%2BOFdiuvZPLrA2oRkh-7QK_A%40mail.gmail.com).

---

<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: [September 8, 2014, 8:34pm UTC](https://discourse.ats-lang.org/t/consuming-var-views/511/5 "2014-09-08T20:34:36Z")

</div>

In int@x, x is static.

The declaration ‘var x: int’ also introduces a static address ‘x’.On Monday, September 8, 2014 4:30:01 PM UTC-4, Zhiqiang Ren wrote:

> prval some = Some\_v{int@x}(view@x)
> 
> Am I understanding correct that the static term {int@x} references a  
> dynamic expression “x”? Thanks.
> 
> On Sunday, September 7, 2014 10:34:32 PM UTC-4, Shea Levy wrote:
> 
> > Hi all,
> > 
> > I have a function where I create an instance of a dataview from an  
> > @-view of a var, and after the function I then break the dataview back  
> > down into the component @-view. The compiler then complains that the  
> > component @-view is not consumed, how can I consume it?
> > 
> > ~Shea

---

<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: [September 8, 2014, 2:40am UTC](https://discourse.ats-lang.org/t/consuming-var-views/511/6 "2014-09-08T02:40:37Z")

</div>

Code?On Sun, Sep 7, 2014 at 10:34 PM, Shea Levy [sh...@shealevy.com](mailto:sh...@shealevy.com) wrote:

> Hi all,
> 
> I have a function where I create an instance of a dataview from an  
> @-view of a var, and after the function I then break the dataview back  
> down into the component @-view. The compiler then complains that the  
> component @-view is not consumed, how can I consume it?
> 
> ~Shea
> 
> –  
> 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/20140908023429.GC2286%40nixos.hsd1.nh.comcast.net](https://groups.google.com/d/msgid/ats-lang-users/20140908023429.GC2286%40nixos.hsd1.nh.comcast.net)  
> .

---

<div class="post-metadata">

### Author: ![Shea\_Levy](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Shea\_Levy](https://discourse.ats-lang.org/u/Shea_Levy)
#### Post date: [September 8, 2014, 4:19am UTC](https://discourse.ats-lang.org/t/consuming-var-views/511/7 "2014-09-08T04:19:39Z")

</div>

Ah ha, thanks!On Sun, Sep 07, 2014 at 08:32:53PM -0700, gmhwxi wrote:

> implement main() = let  
> var x = 1 : int  
> prval some = Some\_v{int@x}(view@x)  
> prval Some\_v y = some  
> prval () = view@(x) := y  
> in 0 end
> 
> On Sunday, September 7, 2014 10:47:18 PM UTC-4, Shea Levy wrote:
> 
> > Simple reproduction:
> > 
> > > implement main() = let  
> > > var x = 1 : int  
> > > prval some = Some\_v(view@(x))  
> > > prval Some\_v y = some  
> > > in 0 end
> > 
> > gives me two errors:
> > 
> > > the linear dynamic variable [y$65(-1)] needs to be consumed but it is  
> > > preserved with the type [S2EVar(0)] instead.  
> > > the linear dynamic variable [x$view$66(-1)] is preserved but with an  
> > > incompatible type.
> > 
> > Which make sense to me but I’m not sure how to fix it.
> > 
> > On Sun, Sep 07, 2014 at 10:40:37PM -0400, Hongwei Xi wrote:
> > 
> > > Code?
> > > 
> > > On Sun, Sep 7, 2014 at 10:34 PM, Shea Levy \<[sh...@shealevy.com](mailto:sh...@shealevy.com) \<javascript:\>\> wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > I have a function where I create an instance of a dataview from an  
> > > > @-view of a var, and after the function I then break the dataview back  
> > > > down into the component @-view. The compiler then complains that the  
> > > > component @-view is not consumed, how can I consume it?
> > > > 
> > > > ~Shea
> > > > 
> > > > –  
> > > > 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/20140908023429.GC2286%40nixos.hsd1.nh.comcast.net](https://groups.google.com/d/msgid/ats-lang-users/20140908023429.GC2286%40nixos.hsd1.nh.comcast.net)
> > 
> > > > .
> > > 
> > > –  
> > > 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/CAPPSPLqDYjgz5JoL\_rpmW%3Dxedzj%2BOFdiuvZPLrA2oRkh-7QK\_A%40mail.gmail.com](https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLqDYjgz5JoL_rpmW%3Dxedzj%2BOFdiuvZPLrA2oRkh-7QK_A%40mail.gmail.com).
> 
> –  
> 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/75b55cd6-2d55-4bc6-afc3-f88e82d4716f%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/75b55cd6-2d55-4bc6-afc3-f88e82d4716f%40googlegroups.com).
