[e-lang] Newbie question

Kevin Reid kpreid at attglobal.net
Fri Mar 31 10:18:16 EST 2006


On Mar 31, 2006, at 9:48, Mariano Montone wrote:
> 2006/3/30, Kevin Reid <kpreid at attglobal.net>:
>> def sequence(target, messages) :void {
>>
>>    def deliverer implements PassByCopy {
>>      to __optUncall() { ... }
>>      to run(target) :void {
>>        if (Ref.isEventual(target)) {
>>          target <- __whenMoreResolved(deliverer)
>>        } else {
>>          for message in messages { E.callWithPair(target, message) }
>>        }
>>      }
>>    }
>>
>>    deliverer(target)
>> }
>>
>> sequence(carRcvr, [["moveTo", [2, 3]],
>>                     ["moveTo", [5, 6]],
>>                     ["moveTo", [7, 3]]]))
>
> Thanks. I will have to study E in more detail in order to  
> understand some things in your code (and I will). However I can  
> realize that you are building some kind of 'composite message' in  
> the form of message list. I wonder weather executing 'eventual  
> code' may be possible (I mean, it wouldn't break the E model).  
> Something like:
>
> def carRcvr := carMakerRcvr <- ("Mercedes")
> carRcvr <- lambda(car){ car.moveTo(2,3)
>                         car.moveTo(5,6)
>                         car.moveTo(7,3) }

(Please place quoted text above your replies and trim it to relevant  
portions; this makes complex discussions much easier to follow.)

The complexity above is because of abstracting the 'deliver several  
messages' structure. Doing it inline would almost be like your example:

carRcvr <- __whenMoreResolved(def deliverer implements PassByCopy {
                                 to run(target) :void {
                                   if (Ref.isEventual(target)) {
                                     target <- \
                                       __whenMoreResolved(deliverer)
                                   } else {
                                     target.moveTo(2,3)
                                     target.moveTo(5,6)
                                     target.moveTo(7,3)
                                   }
                                 }
                               })

> where lambda(car) {....} is an anonymous function that is executed
> eventually over the car (don't know how to write anonymous  
> functions in E,
> or if it is possible)

  * All object expressions return the objects as well as possibly  
defining a noun.
  * Any object expression may have _ in the name position.
  * A function expression is an object expression.

Therefore:

   doSomethingWith(def _(value) :any { return value + 1 })

However, it is good practice to name objects anyway, so that they can  
be identified in printing and type descriptions.

   doSomethingWith(def plusOne(value) :any { return value + 1 })

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>




More information about the e-lang mailing list