Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Should we rename recover by catch_error? #28

Closed
viboes opened this issue Apr 13, 2014 · 9 comments
Closed

Should we rename recover by catch_error? #28

viboes opened this issue Apr 13, 2014 · 9 comments

Comments

@viboes
Copy link
Collaborator

viboes commented Apr 13, 2014

No description provided.

@ptal
Copy link
Owner

ptal commented Apr 13, 2014

Not sure, "catch" really sounds exception-oriented but here it might not be.

@viboes
Copy link
Collaborator Author

viboes commented Apr 21, 2014

As we have catch_exception that is used also to recover from exception, it seems that recover is to general, and cath_error is more specific.

@ptal
Copy link
Owner

ptal commented Apr 21, 2014

Maybe but I don't like much the catch_exception as a member so I wouldn't pay too much attention about it.

@viboes
Copy link
Collaborator Author

viboes commented Apr 21, 2014

My intention, once we have the monads interface is to remove the definition of the all the functions that can be implemented using the minimal interface. Thus, catch_error, catch_exception, mbind, ... all of them could be removed from the expected interface.

I think that this is the basic idea of splitting Algorithm and Data Structures.

@ptal
Copy link
Owner

ptal commented Apr 21, 2014

Ok, I didn't know you wanted to remove that from the interface. But it's right and it's the spirit of the C++ STL. However I'm afraid we'll lose some conveniences without the chaining. Hopefully a binary operator (such as the previously proposed |>) or a construction similar to the do notation would simplify this a lot. Now that I understand your point, I'm ok with the name.

@viboes
Copy link
Collaborator Author

viboes commented Apr 21, 2014

I have defined the operator &() for mbind and operator |() for catch_error on monads errors. These operators allows to chain as if we used the haskell operators >>= and 'catch_error'

Concerning the do notation, I have added it to the documentation removing the keyword expect.

return auto a <- f :
       auto b <- g : 
       a + b;

@ptal
Copy link
Owner

ptal commented Apr 21, 2014

Ok nice, could we extend this to:

auto x = auto a <- f :
         auto b <- g : 
         a + b;

So it could appear outside a return statement.

@viboes
Copy link
Collaborator Author

viboes commented Apr 21, 2014

The return statement is not part of the do-expression. This was an example. You could even do the following

auto x = (auto a <- f :
          auto b <- g : 
          a + b)
        | recoverHandler;

@viboes
Copy link
Collaborator Author

viboes commented Apr 21, 2014

4b62de9

@viboes viboes closed this as completed Apr 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants