From a28017b3aa737e01bac8d047a2d44c228c07d1e4 Mon Sep 17 00:00:00 2001 From: Limin Fu Date: Mon, 10 Oct 2016 16:00:37 +0000 Subject: [PATCH] Fix: a couple of demos; --- demo/errors.dao | 20 +++++++------------- demo/interface.dao | 12 ++++++------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/demo/errors.dao b/demo/errors.dao index 1cfd3caf..a8cd05eb 100644 --- a/demo/errors.dao +++ b/demo/errors.dao @@ -63,24 +63,18 @@ Test2() # if the "block" raises an exception, the default "value" is returned # instead, and the exception is suppressed. -fout = io::stdio +ls = { "A", "B", "C" } +it = "X"; std.exec { - defer ( any ) { return none } - fout = io.open( "NonExistentFile.txt", "r+" ) + defer ( any ) { return "X" } + it = ls[3] # Index out of range; } -if( fout != io::stdio ) defer{ fout.close() } - -fout.writeln( "hello" ) +io.writeln( it ) # A simpler way to write the above codes: -fout = std.exec( io::stdio ){ io.open( "NonExistentFile.txt", "r+" ) } - -# Or using the assertion operator ??: -# fout = io.open( "NonExistentFile.txt", "r+" ) ?? io::stdio - -if( fout != io::stdio ) defer{ fout.close() } +it = std.exec( "X" ){ ls[3] } -fout.writeln( "hello" ) +io.writeln( it ) diff --git a/demo/interface.dao b/demo/interface.dao index 01fab964..088c84f5 100644 --- a/demo/interface.dao +++ b/demo/interface.dao @@ -2,11 +2,11 @@ interface AA { routine Meth( a = 0 ); - routine[]( index: int )=>int; - routine.name()=>string; + routine []( index: int )=>int; + routine .name()=>string; routine for( iter: tuple ); - routine[]( iter: tuple )=>int; + routine []( iter: tuple )=>int; } routine Test( o: AA ) { @@ -20,14 +20,14 @@ routine Test( o: AA ) class BB { routine Meth( a = 0 ){ io.writeln( a ) } - routine[]( index: int ){ return index } - routine.name(){ return "BB" } + routine []( index: int ){ return index } + routine .name(){ return "BB" } routine for( iter: tuple ){ iter[0] = true; iter[1] = 0; } - routine[]( iter: tuple ){ + routine []( iter: tuple ){ id = iter[1]; iter[0] = iter[1] + 1 < 5; iter[1] += 1;