OBUFFER

OBUFFER stands for Output Buffer.

  • It is a keyword.

  • It is used to store values in output buffer.

  • To display content of OBUFFER, use 'console' attribute.

{
   name : Main
   
   @ use += to add content to OBUFFER
   OBUFFER += 27062003
   OBUFFER += "\tSaksham Joshi"
   
   @ to display content on terminal
   console : ( OBUFFER )

   @ remember you **cannot** print the OBUFFER using print or println
   @ println( OBUFFER )
   @ because OBUFFER is managed by interpreter itself 
}

OBUFFER can speed up your code's speed by 100 times if you use it smartly. Look at this code for instance:

{
   name : Main
   
   for : {
       range : ( Int i = 0 , 10000 )
       console : ( i , '\n')
    }
    
    console : ("\n Time taken = " , get_exec_time())
}

And if I want to optimize this code using 'OBUFFER', then

{
   name : Main
   
   for : {
       range : ( Int i = 0 , 10000 )
       OBUFFER += i
       OBUFFER += '\n'
    }
    
    console : ("\n Time taken = " , get_exec_time())
}

Run these both code and you will understand how OBUFFER can be used to achieve greater optimization levels.

Last updated