You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a TODO mark for many of the methods in environment module. Are they supposed return ResultValue to indicate success or a failure so that the call sites can be notified upon errors and can handle them appropriately?
There's a TODO mark for many of the methods in environment module. Are they supposed return ResultValue to indicate success or a failure so that the call sites can be notified upon errors and can handle them appropriately?
Yes. the environments were set up before exceptions (TypeError, ReferenceError, etc), one way of solving this is to use ResultValue this would require the Interpreter to be passed to every call. Another way is to create a Error enum, that contains, the error type and message and return Result<TheNormalReturntype, Error>, and when we call those function when we need to throw we convert them to a javascript Error (TypeError, RangeError, etc) type. This has the advantage that we dont need to introduce the interpreter to the environments
Activity
54k1 commentedon Aug 11, 2020
There's a TODO mark for many of the methods in environment module. Are they supposed return
ResultValueto indicate success or a failure so that the call sites can be notified upon errors and can handle them appropriately?@HalidOdat could you verify this? Thanks.
HalidOdat commentedon Aug 11, 2020
Yes. the environments were set up before exceptions (
TypeError,ReferenceError, etc), one way of solving this is to useResultValuethis would require theInterpreterto be passed to every call. Another way is to create aErrorenum, that contains, the error type and message and returnResult<TheNormalReturntype, Error>, and when we call those function when we need to throw we convert them to a javascriptError(TypeError,RangeError, etc) type. This has the advantage that we dont need to introduce the interpreter to the environments54k1 commentedon Aug 11, 2020
Thanks for confirming this and suggesting the approach. Could I take this up?
HalidOdat commentedon Aug 11, 2020
sure! :)
Razican commentedon Oct 8, 2020
@54k1 let us know if you need any further guidance.