Author Topic: How do you think about functional programming and structured exception handling?  (Read 7992 times)

wangrenxin

  • Guest
Hi guys,

How do you think about if there were two features in a BASIC dialect as follow:

  • Lambda expression, and closure
  • Structured expression handling, better than ON ERROR ...

Traditional BASIC dialects don't support them, as I know, Visual Basic .NET excluded from my list. Since we could code more elegantly with both functional programming and structured exception handling, I'd like to know your opinions.

Merry Xmas!!!
« Last Edit: December 25, 2015, 04:24:44 AM by wangrenxin »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Hi Tony,

I can't think of a better language / environment than MyBASIC to bring these concepts to reality. I will be following (embedding) your project closely. Thanks!

John
« Last Edit: December 25, 2015, 12:48:07 PM by John »

wangrenxin

  • Guest
Thank you John, I got intention. I'll think carefully over this plan.

Mr SQL

  • Guest
Hi guys,

How do you think about if there were two features in a BASIC dialect as follow:

  • Lambda expression, and closure
  • Structured expression handling, better than ON ERROR ...

Traditional BASIC dialects don't support them, as I know, Visual Basic .NET excluded from my list. Since we could code more elegantly with both functional programming and structured exception handling, I'd like to know your opinions.

Merry Xmas!!!

Tiny BASIC supports structured expression handling, it's just very horizontal.

On Error is structured exception handling IMO, it's up to the programmer to test for the type of error, while catch, try, maybe, finally, is very contrived-around-java structured exception handling not belonging in BASIC.

BASIC has such a plethora of error types a contrived java handler simply cannot be fitted to BASIC without an equally verbose handling tree. 

It would lend itself well to Tiny BASIC because we've only got 3 error types and the 3rd needn't be handled once development is complete:

1. Syntax Error
2. What?
3. Out of Memory



wangrenxin

  • Guest
Nice viewpoint, Mr. SQL.

Mr SQL

  • Guest
Nice viewpoint, Mr. SQL.
Well I think the flexibility of BASIC beats having a rigid set of Java handlers hands down! :)

They don't fit the language well and certainly don't need to be boilerplated on, we can always write our own catch/try/finally error handler routines and include them in every BASIC program but the boilerplate can't fit all scenarios and the language is flexible/general purpose so custom error handlers are still often written.