Skip to content

Rework imports  #21

@gregofi

Description

@gregofi

Currently, imports are done like this:

import { id } from './path';

As of now, it has shortcomings

  • Using functions return type is impossible if it isn't also imported. For example fn foo(): A, if module imports foo, it must also import A, otherwise it can't do anything with the type (if its a enum, it can't match. If its a struct, it can't access its attributes).

However, how to solve this? The design of type inference unfortunately does not make this much easy. Transitive imports then plague the namespace of the module (remember, there are no namespaces, so we must be careful with this). Importing the return type could also work, but has same drawbacks as the transitive imports, although on smaller scale.

Maybe import the standard library in its whole by default, that would cut it down a little.

It would be nice if we could at least use the members and methods of the returned value. That would probably be best solution. However, the implementation is not ready for it. It would have to be added on several layers (inference, ast interpreter).

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