Skip to content

react: Investigate more type safety for input vs compute cells #473

Closed
@petertseng

Description

@petertseng

A Reactor may issue CellIDs in response to either a create_input or create_compute.

A Reactor accepts CellIDs in the following circumstances:

  • create_compute so that the caller specifies the dependencies of the compute cell to be created. These dependencies may be either input or compute cells.
  • value. May be either input or compute cell.
  • set_value. Only valid for an input cell.
  • add_callback/remove_callback. Only valid for a compute cell. There is no technical barrier against an input cell having callbacks, but the specification does not call for it and it is never tested.

I believe it is technically feasible to have slightly more safety, as follows:

  • create_input issues only InputCellIDs.
  • create_compute issues only ComputeCellIDs
  • add_callback/remove_callback accept ComputeCellID only.
  • set_value accepts InputCellID only.
  • create_compute and value need to accept enum CellID { Input(InputCellID), Compute(ComputeCellID) }

Should this be done? Is this a reasonable API and/or any other reasons it's a good/bad idea?

If we do this, is it further possible to test at compile-time that InputCellID and ComputeCellID cannot be assigned to each other? Even if it is possible, should we do that? I encourage making them unassignable to each other for more safety, but I don't want students to feel too restricted.

If I do not hear objections or think of any myself, I will investigate what the code looks like. I will not be offended if there were initially no objections but objections come to light after the seeing the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions