[erlang-questions] How expensive are guard clauses?
Thu Jan 28 12:22:12 CET 2016
See http://erlang.org/doc/man/assert.hrl.html (requires Erlang/OTP 18 or
later, otherwise the same macros can only be accessed by including
2016-01-28 12:01 GMT+01:00 Roger Lipscombe <>:
> 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),
> ?is_valid_id(CourseId) ->
> ...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.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions