Skip to content

Could spawn return a "type-safe" process item (ProcessId)? #7

Description

@StefanBertels

Is there a reason for having ProcessId typeless?

I guess this might have something todo with generic handling of processes but isn't something like this more typesafe:

public static Unit tell<T>(ProcessId<T> pid, T message, ProcessId sender = default(ProcessId))

public static ProcessId<T> spawn<T>(ProcessName Name, Action<T> Inbox, ...)

Together with making ProcessId implement some (typeless) IProcessId or just allow casting ProcessId to ProcessId this might be compatible with the existing typeless ProcessId system.

(Of course ProcessId could be named ProcessIdTypesafe or anything else.)

So we could have typesafe wiring of actors:

var actorHandler = spawn<string>("my actor", Console.WriteLine);
tell(actorHandler , "hello world"); // compiles
tell(actorHandler, 123); // compile time error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions