[prev in list] [next in list] [prev in thread] [next in thread] 

List:       e-lang
Subject:    Re: [E-Lang] Confusion
From:       Terry Stanley <tstanley () cocoon ! com>
Date:       2001-08-17 17:49:50
[Download RAW message or body]

At 01:18 AM 8/17/01 -0700, steve jenson wrote:

> Hmm, I hadn't thought about using promises yet (although I should have
> been, thank you). I suppose my question, which I worded very poorly and
> assumed it would be obvious (which is foolish), is that I wish to know
> how to easily determine the value of my newly incremented x without
> having to def my variable mutltiple times. So, I want to know how to
> do this: 

> #------
> ? def xNextvow := farCounter <-incr()
> # value: <Eventual ref>
> 
> ? xNextVow
> # value: 10
> 
> # now I wish to increment x again, but I have to def the object over again
> # for some reason
> 
> ? def xNextVow := farCounter <- incr()
> # value: <Eventual ref>
> 
> ? xNextVow
> # value: 11
> #-------
> 
> How can I call incr() on the farCounter in such a way that I only have
> to def xNextVow once? Is this possible in E? 

In Elmer,  you can redefine a variable but you don't have to. Once xVow 
is defined you can continue using it by simply assigning into it.

    def xVow := farCounter <- incr()
    ...
    xVow := farCounter <- getX()

By the way, starting with version 0.8.9t, you must define mutable variables with \
"var" rather than "def". In your version (0.8.9.x) you have to use "def" for all \
variable definitions.

(Steve: I imagine you know most of the following but it's easier to explain 
if I start from the beginning.)

If the counter object and the client were in the same vat (address space), 
the client could send messages to counter using immediate calls.

    def before := counter getX() 

    def after := counter incr()

In Elmer you would see the values (of before and after) immediately.

In your example, the counter object and client are in different vats so the 
client must use eventual sends.

    # since this is a remote reference, use the naming convention of
    # prepending the variable name with far to remind yourself 
    # to use only eventual sends (not immediate calls)

    def farCounter := sr liveRef()     

    def before := farCounter <- getX() 

    def after := farCounter <- incr() 

Keep in mind that E never blocks waiting on the network. That means that 
before and after must receive values immediately. Since the actual results 
will not be known until a round trip has been made between the vats, these 
values must be promises. So, before and after will eventually have the 
values you're interested in, but they always start out as promises.

Hope this helps.
--Terry



_______________________________________________
e-lang mailing list
e-lang@mail.eros-os.org
http://www.eros-os.org/mailman/listinfo/e-lang


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic