Skip to content

Handle flexible type protocols appropriately #3165

Closed
@eholk

Description

@eholk

Pipe protocols allow for some rather magical things regarding types. For example, consider this protocol:

proto! type_switch {

    start:send {
        get_int -> wait_thing<int>,
        get_str -> wait_thing<~str>
    }

    wait_thing:recv<T:send> {
        thing(T) -> start
    }

}

Furthermore, start could be polymorphic itself and go to different instances of wait_thing.

This is really flexible. Whether this flexibility is desirable is definitely a valid question.

If we decide we do want this flexibility, the protocol compiler needs to be sure to handle this correctly. I think compiling that protocol as an unbounded protocol would probably work fine, but the bounded version will probably fail in mysterious ways.

If we decide we don't want that flexible of polymorphic protocols, we should change the item macro syntax so we can do this instead:

proto! type_switch<T: send> {

    start:send {
        get -> wait_thing
    }

    wait_thing {
        thing(T) -> start
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: ConcurrencyA-syntaxextArea: Syntax extensionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions