Go to the first, previous, next, last section, table of contents.


Function: ]makeEphemeralVector { [any] -> evec }
file: job.t
package: muf
status: alpha

The ]makeEphemeralVector function is much like the ]makeVector function, except that it returns an ephemeral (stack-allocated) vector instead of a vanilla (heap-allocated) vector.

The only advantage of using an ephemeral vector is that stack allocation is generally more efficient than heap allocation, since the storage is automatically released upon return from the function creating the vector, without need to run the garbage collector. This can be a significant advantage if you are creating lots of vectors with very short lifetimes.

In all other cases, you should avoid using ephemeral vectors, due to the potential problems they introduce:

Ephemeral vectors are only useful within the job that created them (that is, the job on whose loop stack they reside). Thus, storing an ephemeral vector in the db, or passing it to another job via a message stream, is almost always a bad idea. The other job will wind up looking in its own loop stack for the ephemeral vector, and either not find it or (worse) find the wrong one.

Ephemeral vectors should normally be created at the start of a function. If you must create one within a "with...do{" type nested scope, you should pop the vector off the stack at the end of the construct using popEphemeralVector: Otherwise, you'll get an error when the function attempts to exit the scope and finds an unexpected vector pushed on the loop stack.

For those of us addicted to conciseness, this function is also available under the synonym ]evec.

See section ]makeVector. See section makeEphemeralVector. See section popEphemeralVector.

Go to the first, previous, next, last section, table of contents.