[erlang-questions] How expensive are guard clauses?
Thu Jan 28 12:01:42 CET 2016
I'm considering adding more-expressive guard clauses to some of my
functions, in order to prevent garbage data getting past certain
points in my application.
If I have a macro like something the following...
(is_binary(Id) andalso byte_size(Id) =:= 16 andalso Id =/=
...and I use it in the following way...
frobnicate(StudentId, CourseId) when ?is_valid_id(StudentId),
...just how expensive, in terms of timing, is that? Is it something I
need to worry about? Can I scatter these guards everywhere? Should I
restrict them to a few places? Should I make it so that they can be
turned off in production (through a compiler define)?
Obviously, I'll be looking to actually measure it, but I'm wondering
if anyone's tried this and got anything to suggest.
More information about the erlang-questions