Abstract Wikipedia/Function evaluator call

Abstract Wikipedia via mailing list Abstract Wikipedia on IRC Wikifunctions on Telegram Wikifunctions on Mastodon Wikifunctions on Twitter Wikifunctions on Facebook Wikifunctions on YouTube Wikifunctions website Translate

This is an example call to the Function evaluator.

Note that the assumption is that only the Function orchestrator would be calling the Function evaluator directly.

The goal of the Function evaluator is to be able to execute without any calls to other data sources, databases, or services.

Consult the architectural sketch of how the orchestrator and the evaluator work together.

{
 "type": "Function call",
 "function": {
  "type": "Function",
  "arguments": [
   {
    "type": "Argument declaration",
    "argument type": "Positive integer",
    "key id": "Z144K1",
    "label": {
     "type": "Multilingual text",
     "texts": [
      {
       "type": "Monolingual text",
       "language": "English",
       "text": "left"
      }
     ]
    }
   },
   {
    "type": "Argument declaration",
    "argument type": "Positive integer",
    "key id": "Z144K2",
    "label": {
     "type": "Multilingual text",
     "texts": [
      {
       "type": "Monolingual text",
       "language": "English",
       "text": "right"
      }
     ]
    }
   }
  ],
  "return type": "Positive integer",
  "testers": [],
  "implementation": [
   {
    "type": "implementation",
    "code": {
     "type": "Code",
     "language": "Javascript",
     "code": "Z144K0 = Z144K1 + Z144K2"
    }
   }
  ],
  "identity": "add"
 },
 "left": {
  "type": "Positive integer",
  "value": "2"
 },
 "right": {
  "type": "Positive integer",
  "value": "2"
 }
}
{
 "Z1K1": "Z7",
 "Z7K1": {
  "Z1K1": "Z8",
  "Z8K1": [
   {
    "Z1K1": "Z17",
    "Z17K1": "Z70",
    "Z17K2": "Z144K1",
    "Z17K3": {
     "Z1K1": "Z12",
     "Z12K1": [
      {
       "Z1K1": "Z11",
       "Z11K1": "Z251",
       "Z11K2": "left"
      }
     ]
    }
   },
   {
    "Z1K1": "Z17",
    "Z17K1": "Z70",
    "Z17K2": "Z144K2",
    "Z17K3": {
     "Z1K1": "Z12",
     "Z12K1": [
      {
       "Z1K1": "Z11",
       "Z11K1": "Z251",
       "Z11K2": "right"
      }
     ]
    }
   }
  ],
  "Z8K2": "Z70",
  "Z8K3": [],
  "Z8K4": [
   {
    "Z1K1": "Z14",
    "Z14K3": {
     "Z1K1": "Z16",
     "Z16K1": "Z301",
     "Z16K2": "Z144K0 = Z144K1 + Z144K2"
    }
   }
  ],
  "Z8K5": "Z144"
 },
 "Z144K1": {
  "Z1K1": "Z70",
  "Z70K1": "2"
 },
 "Z144K2": {
  "Z1K1": "Z70",
  "Z70K1": "2"
 }
}

The result of this should be:

{
 "type": "positive integer",
 "value": "4"
}
{
 "Z1K1": "Z70",
 "Z70K1": "4"
}
Top-level architectural model of Wikifunctions.

The following conditions must be fulfilled by every call to the Function evaluator:

  • it must be a valid ZObject;
  • it must be of type Z7/Function call;
  • the Z7K1/function must be a literal Z8/Function, not a reference to a Z8/Function;
  • every Z17K1/argument type must be of a type that is known by the Function evaluator;
  • the Z8K2/return type must be of a type that is known by the Function evaluator;
  • the Z8K3/testers must be an empty list;
  • the Z8K4/implementation must be list with exactly one element of type Z14/Implementation;
  • only the Z14K3/code key of the Z14/Implementation must be given;
  • the Z14K3/code must point to a Z16/Code with Z16K1/language being Z301/Javascript (for the Function evaluator in Javascript. We will make also Function evaluators in other languages, and here the value must be of the respective language);
  • all given arguments must be literals (in this case, the values of Z144K1/left and Z144K2/right).

In case the function call doesn't fulfil the given invariants (or anything else goes wrong), it will return a Z5/Error.

See also