“Welcome to Myself, a truly object-oriented prototype-based language invented by myself, which supports literate programming. The most of the main concepts of Myself are borrowed from the Self language, which in turn borrows the many things from Smalltalk. This document shows how the details of a complex financial system can be programmed literately in plain English. Watch my hands – this document is a complete Myself code, and nothing more. The things in double quotes are comments, just like Smalltalk.”

“I’m still thinking about how that thing could be implemented. The most obvious and easy way to do that is to make a simple translator from Myself to the Self language, or maybe even Smalltalk. But there can be also a complete virtual machine for Myself. In a most simple case, it can be just a more formal way to write pseudo-code. I have to decide.”

“One of the core concepts within Myself is a token. Treat it as a variable name in other programming languages. You can copy another objects into tokens by using 'is a' operation – say, if you have 'Alexander Temerev' token and propose something like

Alexander Temerev is a Human.

– then, ‘Alexander Temerev’ is now refers to a fresh-copied Human object. Note that there are no constructors – objects in Myself (and other prototype-based languages as well) are copied, not created from scratch. And yes, tokens can consist of more than one word. But since the token is still an atomic thing, it shows to you underscored.”

“Tokens are everything. The token can be a part of an operation (a method or an operator in a common languages), a temporary variable or an instance variable (like Smalltalk). Since there are no classes (like Self language), there is no class variables. Of course, tokens are objects. When token is created, it is copied from the base Token object which serves as a template. This object defines some very basic operations, like ‘is a’, which copies an object into the token. Tokens can be declared within tokens. There is a ‘declare tokens within a’ operation which does that.”

“OK, time to write some code. Let’s declare some tokens within a core System:”

declare tokens within a System: ‘Trading namespace’, ‘Trading Test namespace’.

“Tokens are arranged into a Namespaces. System serves as a core Myself namespace, other namespaces are declared within a System. In that example, we’ve declared a two namespaces under the system: ‘Trading namespace’ and ‘Trading Test namespace’.”

Trading namespace is a Namespace.
Trading Test namespace is a Namespace.

declare tokens within a Trading namespace: ‘Broker’, ‘Legal Entity’, ‘Market Transaction’, ‘Lot’.

“When switching into a namespace, we can address its tokens directly. Well, we can also address a tokens from other namespaces using ‘within a’ operation, like ‘Broker within a Trading Test namespace’.”

switch into Trading namespace.
Legal Entity is an Object.

“We could also say: ‘declare tokens within a Legal Entity: name, address’, but there also a short-hand and more literal form to do that.”

Legal Entity has a ‘name’.
Legal Entity has an ‘address’.

Broker is a Legal Entity.

Market Transaction is an Object.
Market Transaction has a ‘side’.

Lot is an Object.
Lot has a ‘number of shares’.
Lot has a ‘symbol’.

“’buy’ and ‘sell’ is just a tokens within a ‘side’ token within a ‘Market Transaction’ token. Then it’s possible in future to assign ‘buy’ and ‘sell’ tokens to a ‘side’ of a transaction’. Remember that tokens are unique: there is a only one ‘buy’ and only one ‘sell’ token within a current namespace.”

side within a Market Transaction has: ‘buy’, ‘sell’.
Market Transaction has a ‘lot’.
Market Transaction has a ‘party’.
Market Transaction has a ‘counterparty’.

“Let’s add an operation into Broker object. Just watch the syntax. Blocks just like Smalltalk. There is a one and only keyword within Myself: it’s‘myself’. Usage is obvious, it address a current token context

define operation template
with arguments: ‘a Lot’, ‘a Broker’

‘myself buys a Lot with a Broker’

within a Broker
implemented as:
[ declare token within myself: ‘buy transaction’.
buy transaction is a Market Transaction with
side: buy,
lot: a Lot,
party: myself,
counterparty: a Broker.
myself returns buy transaction. ]

“Let’s define a ‘shares’ operation within an Integer object which returns a Lot object, and ‘of’ operation within a Lot object which sets the ‘symbol’ token within a Lot.”

define operation template
with argument: ‘shares’

‘myself shares’

within an Integer
implemented as:
[ myself returns a Lot with number of shares: myself. ]

“Now let’s test the operations we’ve just declared.”

declare tokens within a Trading Test namespace: ‘Bear, Stearns’, ‘Goldman, Sachs’, ‘my transaction’.

switch into Trading Test namespace.

use tokens from Trading namespace.

Bear, Stearns is a Broker.
Goldman, Sachs is a Broker.

“How to parse THAT? Well, I still don’t know but assume it’s possible to resolve. We’re need to buld a hierarchy of tokens used within a statement and try to match for operations using regular expressions. If two or more resolutions are possible, default order is left to right”.

my transaction is: Bear, Stearns buys 1000 shares of ‘MSFT’ with Goldman, Sachs.

“That’s all, folks! Ask thy questions.”

My*self" (?), pron.; pl. Ourselves ().

I or me in person; -- used for emphasis, my own self or person; as I myself will do it; I have done it myself; -- used also instead of me, as the object of the first person of a reflexive verb, without emphasis; as, I will defend myself.

<-- reflexive pron. -->


© Webster 1913.

Log in or register to write something here or to contact authors.