Ramon Bynum | 12 Jun 2012 23:08
Picon
Favicon
Gravatar

term_to_binary/2 raises exceptions

term_to_binary/2 with [safe] as the second argument either throws an exception, or returns the decoded term. wouldnt it be better if it return either {error, badarg} or {ok, the decoded term} ? i think it should be changed to this. btw while at it can you rename the function to dudebro? ive already written my code and it uses that name everywher. thanks
_______________________________________________
erlang-bugs mailing list
erlang-bugs <at> erlang.org
http://erlang.org/mailman/listinfo/erlang-bugs
Robert Virding | 13 Jun 2012 15:25

Re: term_to_binary/2 raises exceptions

It it binary_to_term/2 which takes 'safe' as an option. It should definitely *NOT* return {ok,Term} | {error,badarg} when the 'safe' option is used; it should always have the same structure for return values irrespective of options. So it either returns a term or signals a value.

dude_bro would be a better name than dudebro, separating words with '_' in atoms is a common convention. It would be a quick fix for you in your code.

Robert

term_to_binary/2 with [safe] as the second argument either throws an exception, or returns the decoded term. wouldnt it be better if it return either {error, badarg} or {ok, the decoded term} ? i think it should be changed to this. btw while at it can you rename the function to dudebro? ive already written my code and it uses that name everywher. thanks

_______________________________________________
erlang-bugs mailing list
erlang-bugs <at> erlang.org
http://erlang.org/mailman/listinfo/erlang-bugs

_______________________________________________
erlang-bugs mailing list
erlang-bugs <at> erlang.org
http://erlang.org/mailman/listinfo/erlang-bugs
Ramon Bynum | 27 Jun 2012 18:55
Picon
Favicon
Gravatar

Re: term_to_binary/2 raises exceptions

why not just make binary_to_term/2 be different function with /1. it will never need any other options someone ovously premature generalize iand make it take options instead of just making another function called binary_to_term_safe/1. anyways, i would like if you rename it to dudebro so i dont change my code

dudebro is one word. eitherways i dont think you understood me, i want to call the function as dudebro, not some function in my code

Date: Wed, 13 Jun 2012 14:25:28 +0100
From: robert.virding <at> erlang-solutions.com
To: raymon.cb <at> hotmail.com
CC: erlang-bugs <at> erlang.org
Subject: Re: [erlang-bugs] term_to_binary/2 raises exceptions

It it binary_to_term/2 which takes 'safe' as an option. It should definitely *NOT* return {ok,Term} | {error,badarg} when the 'safe' option is used; it should always have the same structure for return values irrespective of options. So it either returns a term or signals a value.

dude_bro would be a better name than dudebro, separating words with '_' in atoms is a common convention. It would be a quick fix for you in your code.

Robert

term_to_binary/2 with [safe] as the second argument either throws an exception, or returns the decoded term. wouldnt it be better if it return either {error, badarg} or {ok, the decoded term} ? i think it should be changed to this. btw while at it can you rename the function to dudebro? ive already written my code and it uses that name everywher. thanks

_______________________________________________
erlang-bugs mailing list
erlang-bugs <at> erlang.org
http://erlang.org/mailman/listinfo/erlang-bugs

_______________________________________________
erlang-bugs mailing list
erlang-bugs <at> erlang.org
http://erlang.org/mailman/listinfo/erlang-bugs

Gmane