Advertisement
snake5

new lang syntax proto

Dec 28th, 2014
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.66 KB | None | 0 0
  1. extern func println( str : string );
  2. class array< T : typename >
  3. {
  4.     var m_data : *T;
  5.     var m_size : int32;
  6.     var m_mem : int32;
  7.    
  8.     property size : int32 = readonly m_size;
  9.     // OR (not used here)
  10.     property size : int32
  11.     {
  12.         func get(){ return m_size; }
  13.     };
  14.    
  15.     operator [] ( index : int32 ) : &T
  16.     {
  17.         if( index < 0 || index >= m_size )
  18.         {
  19.             WARNING( "array index out of bounds" );
  20.             return T();
  21.         }
  22.         return m_data[ index ];
  23.     }
  24. };
  25. func main( args : array<string> )
  26. {
  27.     for( i = 0; i < args.size; ++i )
  28.         println( args[ i ] );
  29.     println( "Hello, world! (" $ args.size $ ")" );
  30. }
  31. func _test()
  32. {
  33.     main( array<string>{ "array", "data", "test" } );
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement