Could try/catch be added to SSharp?

116 views
Skip to first unread message

Andrew

unread,
Jun 11, 2014, 6:11:27 AM6/11/14
to ssh...@googlegroups.com
I'm trying to add scripting to a program that will interact with the file system and an HTTP web service.  The C# facilities for both HTTP and the file system throw exceptions for many common cases.  Without try/catch in SSharp it is almost impossible to write trustworthy code.  Do you think it is possible to add try/catch to SSharp?

I suspect that implementing try/catch/finally like in C# would be difficult, particularly with multiple catch() clauses.  However, I think that a simplification would be enough - only allow one catch clause, make the Exception variable implicit and eliminate the finally clause completely.  This would still allow somebody to trap errors, and they could use "is" to test the type of the exception if it was really necessary.

Do you think this is possible within the architecture of SSharp or do you know of a reason why it would not work?

Andrew

unread,
Jun 11, 2014, 8:41:29 AM6/11/14
to ssh...@googlegroups.com
After I posted this I decided to read the source.  I guess I should have done that first.

I've never been able to get a try/catch of the this form to work.  It always produces a syntax error:
try { x; }
catch (e) { y; }

I just assumed that the syntax error was because try/catch is not implemented.

It turns out that the "finally" clause in SSharp is non-optional.  I modified the grammar to make the finally clause optional, and now I'm happy.

Reply all
Reply to author
Forward
0 new messages