C static variable functionality

95 views
Skip to first unread message

RedDevil

unread,
May 25, 2013, 4:13:33 AM5/25/13
to clay-l...@googlegroups.com
Can Clay provide similay funstionality to C static variables in a function (ie retauned state across calls)?
RedDevil

Joe Groff

unread,
May 25, 2013, 3:49:08 PM5/25/13
to clay-l...@googlegroups.com
On Saturday, May 25, 2013, RedDevil wrote:
Can Clay provide similay funstionality to C static variables in a function (ie retauned state across calls)?

There are no function local static variables, but you can use a private global variable to keep the state local to your module. 

-Joe 

RedDevil

unread,
May 25, 2013, 8:36:14 PM5/25/13
to clay-l...@googlegroups.com
Thanks Joe - my lackof understanding of module usage gets me either undefined variable or an import loop errors.
Is there (or can you please provive) an example say of simple incrementing a variable and printing?

RedDevil

unread,
May 25, 2013, 8:38:03 PM5/25/13
to clay-l...@googlegroups.com

Joe Groff

unread,
May 26, 2013, 10:03:48 AM5/26/13
to clay-l...@googlegroups.com
On Saturday, May 25, 2013, RedDevil wrote:
Thanks Joe - my lackof understanding of module usage gets me either undefined variable or an import loop errors.
Is there (or can you please provive) an example say of simple incrementing a variable and printing?

Something like this should work:

private var counter = 0;
next() {
  counter += 1;
  return counter;
}

-Joe
Reply all
Reply to author
Forward
0 new messages