[erlang-questions] *current* value?

YC yinso.chen@REDACTED
Wed Oct 17 23:17:32 CEST 2007


On 10/17/07, David King <dking@REDACTED> wrote:
>
>
> > Can you be more specific as to what a "current" variable is?


Certainly.

In Erlang, the best example I know at this time is self() - which returns
the "current" process ID.  i.e., the returned values of self() changes as
it's called within different processes.

I'm trying to see if there are ways to write functions similar to the
context dependent effect of self().  I'm not looking for global variables;
context dependent functions such as self() is fine.

Some of other examples I can think on top of my head are:

In Java, an example is the Thread.currentThread(), which returns the current
thread.

OOP uses this or self as an implicit keyword to retrieve the current object.


In PLT Scheme, there is a facility called parameters, that can be bound for
a particular block of code to be a particular value (parameters are
retrieved like function calls rather than a naked variable).

In Lisp - special variables can also be bound by context.

Basically - one can bind the value by a particular context (I think in
Erlang process is the basic unit for a context).  The main use is to reduce
the # of parameters that needs to be explicitly passed in, which obviously
makes the function impure (although can be more practical).

Let me know if this explains it better, thanks.
yc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20071017/6ca6b0f4/attachment.htm>


More information about the erlang-questions mailing list