(no subject)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

Gavin Wraith-4
I hope this query is not a great nuisance for the creators
of Lua. It concerns the semantics of Lua. I know
that as Lua is provided in the form of a C library, in
order to find out what Lua code actually means all we
have to do, in theory, is read the source code. Of course,
some variation in semantics can be expected as due to
differences in C compilers. Alternatively, we users
could experiment with Lua to answer for ourselves our
particular questions, such as ones below.
Nevertheless, it would be nice if there were
some document available, say as for Haskell or ML, which
laid down some specifications, and it might be a help for
those coming new to the language.
I realise that the problem of describing the semantics of
imperative languages is a lot thornier than for declarative
ones, and also that there may be semantic issues which the
creators of Lua might prefer to keep open so as not to
prejudice future developments. 

The sort of questions I have in mind are:

1) In evaluating an expression of the form
       <exp1>[<exp2>] in an environment <env>
   which of the following, if any, may I assume?

   i)  <exp2> is evaluated in <env> to produce a value
      <v2> and the resulting environment is <env'>.
      <exp1> is then evaluated in <env'> to produce a
      value <v1> and the resulting environment is <env''>.
      Finally, <v1>[<v2>] is evaluated in <env''>. 

   ii) <exp1> is evaluated in <env> to produce a value
      <v1> and the resulting environment is <env'>.
      <exp2> is then evaluated in <env'> to produce a
      value <v2> and the resulting environment is <env''>.
      Finally, <v1>[<v2>] is evaluated in <env''>.

   iii) the pair <exp1>,<exp2> is evaluated in <env> to the
        pair <v1>,<v2> to produce an environment <env'>.
        Finally, <v1>[<v2>] is evaluated in <env'>.

2) Similar question for function calls <exp1>(<exp2>) etc.

3) In the evaluation of table expressions { <exp> } what can the
   user assume about the order of evaluation (left-to-right?,
   right-to-left?,unpecified?,or evaluated as a tuple i.e. all
   in the same environment?).


-- Gavin Wraith
-- [hidden email]