An Actor sending a message to itself

13 views
Skip to first unread message

Carl Hewitt

unread,
Jun 4, 2021, 4:10:06 PM6/4/21
to fr...@googlegroups.com

Today at FriAM there was discussion of issues involved where

an Actor holding its region of mutual exclusion sends a message to itself.

 

Issues include the following:

  • Why would an Actor release its region of mutual exclusion when it could just process the message without releasing.
  • Should the Actor abstraction have a special axiom for messages sent to itself?
  • What happens when while holding the region of mutual exclusion, an Actor in parallel sends two messages to itself?

 

Cheers,

Carl

https://professorhewitt.blogspot.com/

 

Terry Hayes

unread,
Jun 6, 2021, 1:13:39 PM6/6/21
to fr...@googlegroups.com
Regarding an actor sending a message to itself:

I'll give as my example Carl's own Indeterminate actor: actually the Counting actor that provides the indeterminism.  (This version from Carl's post on cap-talk, March 1, 2021)

Counting :[ ]Interface goVoid, stopNatural   

    [ ]  ↦↦                                                                  // constructor has no arguments

          count := 0,                         // The variable count is initially 0

       continue := False|           // The variable continue is intially False

   go ↦                              // When a go message is received:

        continue cases         // Cases continue for are as follows:

                     True then                             // If continue is True 

                              count := count+1;         // then increment count and afterward

                  Hole (This Counting)go      // in a hole in the region of mutual exclusion,

                                                                                         // send a go message this instance of Counting

              False then   Void     // If continue is False, then return Void

  stop ↦                                 // When a stop message is received:

                    continue := False;       // Assign continue the value False and then

                        count                       // return count

Please notice the statement (expression?) "Hole (This Counting).go" - which sends a "go" message to the actor itself, while giving up the region of mutual exclusion. This is critical to the operation of this actor, since immediately processing the new "go" message would never allow a pending "stop" message to be handled.

For reference, this would look something like this in Humus.

LET counting_beh(value) = \msg. [

 CASE msg OF

  #go: [

   SEND #go TO SELF

   BECOME counting_beh(add(value, 1))

  ]

  (#stop, cust): [

    SEND value TO cust

    BECOME \msg. []

  ]

 END

]


CREATE actor WITH counting_beh(0)

SEND #go TO actor

SEND (#stop, println) TO actor


Notice the SEND TO SELF on line 4.


Terry


------

NOTES:

The Humus simulator doesn't have enough arbitrariness in message delivery to demonstrate fully.  It tends to process three messages: #go, (#stop, cust) and #go; in that order.


I've replaced the case analysis in Carl's code by new behavior for the actor.  I think this is an advantage of having functional capabilities together with the BECOME statement (effect).


I believe the "Hole (This Counting).go" in Carl's version waits for a response before continuing.  I'm using a "fire and forget" version of the "go" message. I've always been concerned that Carl's version might accumulate "continuations" which then reacquire the region of mutual exclusion, and then do nothing.  This can probably be optimized away by the compiler.


--
You received this message because you are subscribed to the Google Groups "friam" group.
To unsubscribe from this group and stop receiving emails from it, send an email to friam+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/friam/BY5PR10MB4274A05DD45E251718F4EB5AD93B9%40BY5PR10MB4274.namprd10.prod.outlook.com.

Carl Hewitt

unread,
Jun 6, 2021, 1:34:05 PM6/6/21
to fr...@googlegroups.com

Probably worth noting that the counting example is an exercise in

providing a minimal example to illustrate inadequacies of Nondeterministic Turing Machines.

The example is not an illustration of good practices to use in applications.

 

Regards,

Carl

https://professorhewitt.blogspot.com/

 

PS. The Humus example below is somewhat special case because

Humus is  built on 1-way messaging.

Current generation applications mainly using request-response.

Always requiring explicit customers leads to long string-bean style code :-(

 

Also worth noting that Humus is not strictly speaking an Actor programming language because

it is not the case that everything is an Actor.

For example, the lambda expressions (for behaviors) are not Actors.

Carl Hewitt

unread,
Jun 7, 2021, 9:11:26 AM6/7/21
to fr...@googlegroups.com

PS. Would be interesting to see if Humus can be upgraded to be a true Actor programming language ;-)

Dale Schumacher

unread,
Jun 7, 2021, 1:19:43 PM6/7/21
to fr...@googlegroups.com
Terry,

Thanks for your illustrative examples. I concur with the correctness of your Humus implementation. You clearly have a good grasp of Humus semantics.

Carl,

I've said this before, but this time I'm putting it in writing for all to see.

There is a description of the semantics of Humus (which I've used as a basis for multiple running reference-implementations) in which each language construct is implemented with primitive actor messages. This includes function definitions (lambda) and invocations (even recursive), expression evaluation, behavior execution, etc.


Carl Hewitt

unread,
Jun 7, 2021, 5:29:48 PM6/7/21
to fr...@googlegroups.com

Dale,

 

Thanks for your interesting Humus language experiment :-(

 

It is very important not to confuse a programming language with

the Actor mathematical model which is the unique model up to a unique isomorphism of the theory Actors.

See the following:  https://papers.ssrn.com/abstract=3418003

 

In a pure Actor programming language, everything is an Actor including

the binding of every identifier and the result of every expression.

 

Mixing up a programming language with an (axiomatic) specification of a programming language may be less than optimal.

 

Regards,

Carl

https://professorhewitt.blogspot.com/

Carl Hewitt

unread,
Jun 7, 2021, 6:09:05 PM6/7/21
to fr...@googlegroups.com
PS. Actually intended smiley face for Dale's experiment!


From: fr...@googlegroups.com <fr...@googlegroups.com> on behalf of Carl Hewitt <hew...@irobust.org>
Sent: Monday, June 7, 2021, 14:29
To: fr...@googlegroups.com
Subject: RE: FW: [friam] An Actor sending a message to itself

Mark S. Miller

unread,
Jun 7, 2021, 6:49:27 PM6/7/21
to fr...@googlegroups.com
First emoticon typo correction I can remember !


Carl Hewitt

unread,
Jun 8, 2021, 1:04:42 PM6/8/21
to fr...@googlegroups.com

PS. In other words, if a pure Actor programming language has first-class expressions for “behaviors”, then a “behavior” must be an Actor.

 

From: Carl Hewitt
Sent: Monday, June 7, 2021 14:30
To: fr...@googlegroups.com
Subject: RE: FW: [friam] An Actor sending a message to itself

 

Dale,

 

Thanks for your interesting Humus language experiment :-)

Reply all
Reply to author
Forward
0 new messages