<br><div><span class="gmail_quote">On 10/17/07, <b class="gmail_sendername">David King</b> <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>> Can you be more specific as to what a "current" variable is?</blockquote><div><br>Certainly.<br><br>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. <br></div></div><br>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.
<br><br>Some of other examples I can think on top of my head are:<br><br>In Java, an example is the Thread.currentThread(), which returns the current thread. <br><br>OOP uses <span style="font-weight: bold;">this </span>or
<span style="font-weight: bold;">self</span> as an implicit keyword to retrieve the current object. <br><br>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).
<br><br>In Lisp - special variables can also be bound by context. <br><br>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).
<br><br>Let me know if this explains it better, thanks.<br>yc<br><br>