Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esip_codec:encode_via not check member value =:= undefined #3

Open
wanglihe opened this issue May 13, 2016 · 4 comments
Open

esip_codec:encode_via not check member value =:= undefined #3

wanglihe opened this issue May 13, 2016 · 4 comments
Assignees

Comments

@wanglihe
Copy link

For example, if host =:= undefined, it just encode record with some atom undefined, the encode returns ok, and it's result can not transfer to binary or send with udp port. I think it should return error, or just encode "undefined" to some string but not an atom.

@zinid
Copy link
Contributor

zinid commented May 13, 2016

Well, in that case we need to add checks in many places of encoding functions. I don't think we need this burden really. For example, in the same encode_via we should check Proto, Transport etc have correct values.

@wanglihe
Copy link
Author

I agree with you that it is difficult to check every mistake, but that is codecs should do. Every mistake create by compilers will make bugs far far away and debug is very difficult, I have just spent about 3 hours to catch one, it is dangerous. Maybe it is not the good time to fix it right now, but it should be fixed as soon as possible.

@zinid
Copy link
Contributor

zinid commented May 14, 2016

Then you probably chose a wrong language. That's a common problem of duck typing. When you put wrong values to some built-in OTP functions you will get pretty cryptic errors as well. Also, the error you're talking about is not that cryptic, typically you will get badarg which is pretty easy to understand.

@wanglihe
Copy link
Author

Erlang says: crash as soon as possible. I am not choose wrong, and this is not a problem of duck typing. OTP try to throw exceptions everywhere, debug is easy. BTW, is Erlang's type system duck typing? I thought duck typing is something about OO, not functional languages. Maybe I was wrong. This issue is only a suggestion, try to make esip better and easier to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants