StackLanguge / stack-language

The official impilmentation of the Stack programming language created by BookOwl
4 stars 1 forks source link

Exception handling #18

Open BookOwl opened 8 years ago

BookOwl commented 8 years ago

It would probably be a good idea to add exception handling to Stack.

towerofnix commented 8 years ago

Need OOP first so that we have a good way to handle it :P

Future possible usage:

{ sup } try dup
`success -> /* property op? */
True =
{ 'All good!' print }
{ 'We got an error:' print `msg -> print }
ifelse
BookOwl commented 8 years ago

I was thinking more like

{ 'Try running this code' print }
{ /* If this gets run, the item on top of the stack is an error object */  'An error occurred' print }
try
towerofnix commented 8 years ago

Works as well.

oop version thing:

{ 'Try running this code' print }
{ `msg -> `msg set 'Error: ' msg concat print }
try