# Stack-allocated array variables

**URL:** <https://discourse.ats-lang.org/t/stack-allocated-array-variables/831>\
**Category:** Google Group\
**Created:** [September 22, 2013, 1:43pm UTC](https://discourse.ats-lang.org/t/stack-allocated-array-variables/831 "2013-09-22T13:43:11Z")\
**Posts on this page:** 1\
**Page:** 1

<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 22, 2013, 1:43pm UTC](https://discourse.ats-lang.org/t/stack-allocated-array-variables/831/1 "2013-09-22T13:43:11Z")

</div>

FYI.

I have just implemented support for allocating array-variables on call  
stack.  
Here is the related syntax:

fun foo () = let  
var A0 = @[int]10 // A: array (int?, 10) // uninitialized  
var A1 = @[int]10 // A: array (int, 10) // initialized with 0’s  
var A2 = @[int](0, 1, 2, 3, 4, 5, 6, 7, 8, 9) // A: array (int, 10)  
in  
…  
end // end of [foo]

Note that the size of each stack-allocated array must be a constant.  
The type system makes sure that the proof of at-view associated with  
each array-variable is unavailable outside the legal scope of the variable.

Cheers!
