etanzapinsky / mongoose

Mongoose Simulation Language
1 stars 1 forks source link

A pass at how the frontend will pass function parameters to the backend. #9

Open christopher-haueter opened 11 years ago

christopher-haueter commented 11 years ago

We didn't define this in the spec, but since mongoose is strongly typed, I thought we would go with strongly-typed parameters:

<return_type> function_name(<type> param_1, .. , <type> param_n) { 
    <expressions>
}

Then the question is how to pass the function parameters

  1. at function definition time
  2. at function call time

Here's a first, rough attempt:

The frontend passes a tuple of two types of nodes:

  1. with vtype of <type>_KEYWORD
  2. with vtype of the <type>

At definition time, the backend raises an InvalidFunctionDefinition exception if there is something wrong with the type keywords.

At calling time, an InvalidParameters exception is raised if the the parameters are invalid, e.g. f('hello') when the function defined the first parameter's vtype to be v.INT.