a couple of basic questions (for me and the wiki)

70 views
Skip to first unread message

Brandon Barker

unread,
Apr 16, 2013, 11:48:13 PM4/16/13
to ats-lan...@googlegroups.com
1) val vs var with dependent types
Why is ok to "get" some dependent type info this way:
val [n:int] ptmp = mystr1_of_mystr(strtmp)
but not this way:
val _ = p->size := (p->size - p->pos + 1) 

2) Stack allocation
val tmp = 1
val tmp = 2
//  Internally, is it now the case that we have allocated two integers in memory on the stack?

3) Possibly more to come soon ...

gmhwxi

unread,
Apr 17, 2013, 12:21:33 AM4/17/13
to ats-lan...@googlegroups.com
1) I don't understand the question.
2) It depends on the actually compilation. In this case, none is allocated due to constant propagation.

Brandon Barker

unread,
Apr 17, 2013, 12:40:46 AM4/17/13
to ats-lan...@googlegroups.com
For 1) I'm sorry, I had a typo I didn't correct in the email.  It should be:

// This is ok:
val [n:int] ptmp = mystr1_of_mystr(strtmp)
// but not this
val _ =  [n:int] p->data := mystr1_of_mystr(strtmp)

I suppose an acceptable approach  is to write a prffun to get info about dependent information.

For 2) then, is there any case where one could get in to memory efficiency trouble by performing multiple bindings to the same name?

gmhwxi

unread,
Apr 17, 2013, 11:36:25 PM4/17/13
to ats-lan...@googlegroups.com
'[n:int] ptmp' is a *pattern*.

>>[n:int] p->data := mystr1_of_mystr(strtmp)

It is not that this cannot be supported. However, adding new syntactic features like this is quite involved (given the already very rich and complex syntax of ATS).


>> is there any case where one could get in to memory efficiency trouble by performing multiple bindings to the same name?

It is conceivable but highly unlikely in my opinion as the underlying compiler optimization is straightforward to implement.



Reply all
Reply to author
Forward
0 new messages