September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -1,5 +1,5 @@
class MyException :: Exception
class MyException : Exception
{
constructor new
<= new literal:"MyException raised".
constructor new()
<= new:"MyException raised";
}

View file

@ -1,4 +1,4 @@
foo
[
MyException new; raise.
]
foo()
{
MyException.new().raise()
}

View file

@ -1,7 +1,8 @@
try(o foo)
{
on(MyException e)
[
// handle exceptions of type MyException and derived
]
}
try
{
o.foo()
}
catch(MyException e)
{
// handle exceptions of type MyException and derived
}

View file

@ -1,4 +1,4 @@
o foo | if(:e)
[
// handle any type of exception not handled by above catches
].
o.foo() | on:(e)
{
// handle any type of exception
};

View file

@ -0,0 +1,19 @@
foo(X) :-
\+ integer(X),
throw(b('not even an int')).
foo(X) :-
\+ between(1,10,X),
throw(a('must be between 1 & 10')).
foo(X) :-
format('~p is a valid number~n', X).
go(X) :-
catch(
foo(X),
E,
handle(E)).
handle(a(Msg)) :-
format('~w~n', Msg),
!.
handle(X) :- throw(X).