static variable

new topic     » topic index » view thread      » older message » newer message

better to start new thread...

So what I envision is like C static inside function

--fibonacci generator 
function fibo() 
static atom a=0,b=1 
atom tmp    
  tmp=b 
  b=a+b 
  a=tmp 
  return b  
end function 
-- print 10 first terms of fiboacci serie 
  for i=1 to 10 do 
     ? fibo() 
  end for 

Here a and b should be stored and initialized as any top level variable but they are only visible inside fibo() function. This can be managed at front end. There is no need for special storage class.

Jacques

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu