Smart pascal source code
var
i : Integer;
BEGIN
while True do begin
try
raise Exception.Create('hello');
except
on e:Exception do begin
WriteLn(e.Message);
Break;
end;
end;
end;
repeat
try
raise Exception.Create('world');
except
on e:Exception do begin
WriteLn(e.Message);
Break;
end;
end;
until False;
for i:=1 to 10 do begin
try
try
raise Exception.Create('duh');
except
on e: Exception do begin
WriteLn(e.Message);
Break;
end;
end;
finally
WriteLn('finally');
end;
WriteLn(i);
end;
{ CONSOLE OUTPUTS
hello
world
duh
finally
}
var Exception={
$ClassName: "Exception",
$Parent: TObject,
$Init: function () { FMessage="" },
Create: function (s,Msg) { s.FMessage=Msg; return s }
}
function $W(e) { return e.ClassType?e:Exception.Create($New(Exception),e.constructor.name+", "+e.message) }
function $New(c) { var i={ClassType:c}; c.$Init(i); return i }
function $Is(o,c) {
if (o===null) return false;
return $Inh(o.ClassType,c);
};
function $Inh(s,c) {
if (s===null) return false;
while ((s)&&(s!==c)) s=s.$Parent;
return (s)?true:false;
};
var i = 0;
while (1) {
try {
throw Exception.Create($New(Exception),"hello");
} catch ($e) {
var e = $W($e);
WriteLn(e.FMessage);
break;
}
}
while (1) {
try {
throw Exception.Create($New(Exception),"world");
} catch ($e) {
var e$1 = $W($e);
WriteLn(e$1.FMessage);
break;
}
}
for(i=1;i<=10;i++) {
try {
try {
throw Exception.Create($New(Exception),"duh");
} catch ($e) {
var e$2 = $W($e);
WriteLn(e$2.FMessage);
break;
}
} finally {
WriteLn("finally");
}
WriteLn(i);
}