Performance question

Craig Dickson crd@REDACTED
Thu Mar 25 18:50:02 CET 1999


I have an algorithm which requires a recursive function to have access to a
fairly large fixed-size array of constants (probably a tuple, indexable with
element/2 since that should have O(1) performance, and it won't need to be
anywhere near 64k elements long). My question is, if I simply declare this
tuple as a value within the function, will it be recreated for each
recursive call to the function, or is Erlang smart enough to set it up once
(at compile time, even, as pre-initialized static data, since it is never
modified) and keep it around for subsequent usage? Would it make any
difference if the tuple was passed in as an argument?

Incidentally, why is there no recognizer guard for funs? If you don't mind
having your code assume that a fun is a certain type of record, you can use
record/2, but I don't recall the standard saying that funs had to be
implemented as records, so I'm not comfortable with that.

Craig





More information about the erlang-questions mailing list