[E-Lang] Confusion

steve jenson stevej@sieve.net
Fri, 17 Aug 2001 01:18:22 -0700


Quoting Terry Stanley (tstanley@cocoon.com):

> At 03:02 AM 8/16/01 -0700, steve jenson wrote:
> 
> >def counter {
> >     to incr() :any { println("counter was incr()'d"); x += 1}
> >     to getX() :any { x }
> >}
> 
> Realize that this println message is displayed in the server window, not the 
> client window.

Yes, that was the intended behavior. On a side note; At 2am, lack of a
return() statement caught me when I noticed:

? xVow
#value: 'counter was incr()\'d'  

being spit out by my elmer session. Yes, I had placed the println()
behind x's increment. It was so natural for me to not think of a non
return()'d statement's value being passed back that I blindly broke
my own system, in a possibly subtle fashion if I had decided to munge
with x yet again. Of course, this is only a big deal to those who don't
properly test their systems, and to those who aren't familiar with an
expression-oriented language.

> >PS, the cap is still online (at least until I wake up tomorrow morning and
> >turn it off) if anybody out there wants to play with it. Not that it's
> >super-exciting.
> 
> This was a good idea. We were able to connect to your server in Elmer. The 
> following updoc script is our transcript , including an example of when-catch.
> 
>     ? introducer onTheAir()
>     # value: ["3DES_SDH_M2", "3DES_SDH_M"]
>     
>     ? def sr := <cap://66.92.8.63:3575/08TsZ_LYmtuAVuLZoDFX8j3Re7O6/QfWE9V6br29mY9eS27aFI9fyGam>
>     # value: <SturdyRef>
>     
>     ? def farCounter := sr liveRef()
>     # value: <Eventual ref>
>     
>     ? def xVow := farCounter <- getX()
>     # value: <Eventual ref>
>     
>     ? xVow
>     # value: 8
>     
>     ? def xNextVow := farCounter <- incr()
>     # value: <Eventual ref>
>     
>     ? xNextVow
>     # value: 9
>     
>     ? when (xNextVow) -> done(xNext) {
>     >     println(`next: $xNext`)
>     > } catch prob {
>     >     println(`oops: $prob`)
>     > }
>     # value: <Eventual ref>
>     
>     ? 
>     next: 9
>     ?
> 
> Let us know if you have any more questions.

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: 9

without having to keep explicitly creating xNextVow again. I think
the following is ugly:

#------
? 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 my mental E interpreter, I run code that looks like this:

#-----
? def xNextVow := farCounter
# value <Eventual ref>

? xNextVow <- incr()
# value <Eventual erf>

? xNextVow <- getX()
# value: 12 
#-----


I think if there's one thing that my Mental E Interpreter(tm) teaches me
is that I still think too locally.



-steve

]
-- 
steve jenson <stevej@sieve.net> http://sieve.net/
PGP fingerprint: 79D0 4836 11E4 A43A 0179  FC97 3AE2 008E 1E57 6138