[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implicit variables - should they be reserved keywords?



Title: Implicit variables - should they be reserved keywords?

Following a discussion with an engineer who is just starting with e, I was wondering why implicit variables (result, it, me etc..) are not reserved keywords. Take the following two code examples:

Case 1
<'
extend sys {
        result : bool;
        keep soft result == TRUE;

        tester_fo():bool is {
          result=FALSE;
          return(TRUE);
        };

        print_result() is {
          out(" return = ",tester_fo(),". result = ",result);
        };

        run() is also {
          print_result();
        };
};
'>

Output from this is : return = TRUE. result = TRUE


Case 2

<'
extend sys {
        result : bool;
        keep soft result == TRUE;

        tester_fo() is {
                  result=FALSE;
        };

        print_result() is {
          out("result = ",result);
        };

        run() is also {
          tester_fo();
          print_result();
        };
};
'>

Output from this is : result = FALSE


In both cases, result is defined as a variable in the struct, and used as an implicit variable (is it really though?) within a struct method. In case 2, there is no return type from the method, so when we assign result a value, it updates the struct variable, as you might expect.

However, in case 1, it does not update the struct variable, as it associates result with the return type of the method.

This wouldn't happen if result was a reserved word - the code with either be syntactically correct or incorrect at the beginning, with no scope for confusion. I would like to propose this as a change to the LRM - does anyone agree or disagree with this?

Cheers,

Darren


------------------------------------------------------------------------------------
Darren Galpin                       Tel:        +44 117 9528741
Infineon        Technologies            Fax:    +44 117 9528777
Infineon House                     Darren.Galpin@infineon.com
Great Western Court           
Hunts Ground Road
Stoke Gifford
Bristol, BS34 8HP, England.
------------------------------------------------------------------------------------