Introduction to Mindscript
Why Mindscript Language
For security reasons, we did not allow the execution of a script (or DSL) inside the Reasoning Engine. Therefore, selection class evaluation is done on Webhook and sends the result in JSON, and extract “selection term” from the JSON using JSONPath. The selection class evaluates the extracted value with the “selection term” in the configuration. We see more limitations without interfacing with Webhook, such as:
value formatting (response or Webhook request POST JSON payload),
value evaluation (parameter or Webhook JSON response), and
simple boolean logic operations (parameter or Webhook JSON response).
There should be no security compromise.
Introduction
Mindscript is a fully object-oriented, dynamically typed, reflective programming language with no
non-objecttypesMindscript was created as the language to underpin the
Mind Expressionof computing exemplified byhuman–computer symbiosis
Everything is an object
Integers are instances of one of the
numericclassesClasses are instances of the class
Metaclassand are just as manipulable as any other objectAll classes are part of a single class tree; no disjoint class trees
There are no pointers into memory locations that you can dereference and mess with
Functions are not called and messages are sent to objects
Work is done by sending messages to objects, which decide how to respond to that message and run a method as a result, which eventually returns some object to the original message sending code.
The system knows the class of the object receiving a message and looks up the message in that class’s list of methods. If it is not found, the lookup continues in the super class until either it is found or the root of the classes is reached and there is still no relevant method.
Syntax
Mindscript code does only two things:
assign variables and
send messages.
To assign variable, we use operator :=
The other basic operation is to send a message to an object
There are three sorts of messages.
Unary - a single symbol that may be several words conjoined in what we call camelcase form, with no arguments. For example
size,newEmptyDB,currentBinary - a small set of symbols often used for arithmetic operations in most languages, requiring a single argument. For example
+,//,@We support traditional arithmetic precedence, which is different with other smalltalk dialects.
For example, for the following expression\
Keyword - the general form where multiple arguments can be passed. As with the unary form we use camelcase to join words together but arguments are inserted in the midst of the message with colons used to separate them lexically. For example
at: put:,at:
Please note that in an expression for an object, unary message is precedent than binary message, and binary message is precedent than keyword message.
For example, for the following expression:
It executes based on their message types priority likes this:
Example
Allowable characters
a-z
A-Z
0-9
.+/*~<>@%|&?
blank, tab, cr, ff, lf
Variables
variable names are untyped
reserved names:
nil,true,false,self,super, andthisContext
Variable scope
Global: installed by the engine and can be used anywhere, for example global class
Parameter.Special (reserved):
super,self,true,false,nil.Method Temporary: local to a method
Block Temporary: local to a block
Block Parameters: automatic block temp vars that name the incoming parameters. Cannot be assigned to
Comments
Statement Separator
Period (.) is the statement separator
Not required on last line of a method
To execute multiple statements we must separate them by
.For example we execute the following two statements one by one based on statement separator.
Assignment
Constants
Blocks
Blocks are objects and may be assigned to a variable
Value is last expression evaluated unless explicit return
Blocks may be nested
Specification [ arguments | | localvars | expressions ]
^ expression terminates block & method (exits all nested blocks)
Method Calls
Unary methods are messages with no arguments
Binary methods
Keyword methods are messages with selectors including colons standard categories/protocols:
In an expression for an object,
unarymessage is precedent thanbinarymessage, andbinarymessage is precedent thankeywordmessage.
Array
Associations
Dictionary
Last updated
Was this helpful?