Skip to content

Add type inference capabilities to AST #455

@UnsignedByte

Description

@UnsignedByte

This is a purely front-end proposal for possibly adding type inference to Filament. This would allow the user to write programs without directly specifying their timing, Initially, we can just eliminate the requirement for providing events.

add1 := Add[W](in0, in1);
add2 := Add[W](add1.out, add1.out);

This should be relatively simple to implement, but does have a few interesting questions on the backend side.

  1. Instances and Invocations?
    • I think the best way to go here is to allow instances and invocations just the same. This means however that if the user invokes a component twice, the compiler would still have to infer a non-intersecting timing for reuse.
    • Another idea is to allow the compiler to infer reuse, which we could do using a component level attribute flag. In this case, we might turn every invocation into an instantiation, or instead only allow the compiler to combine instantiations, not create new ones.
  2. Partially type inferenced components
    • This representation allows for some invocations to be type inferenced, while others can still be explicitly described. Not sure how this feature would be useful, but we could use these explicit invocations to further constrain the compiler.
  3. Enable/Disable?
    • For safety, I think it would be nice to maybe have an attribute like type_inference or something that needs to be set, so that the user has to explicitly ask for this feature. Not sure if this is necessary though.

As this is simply a frontend proposal, we can implement it for now and simply have the compiler throw an error when the the user attempts to use it.

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