Skip to content

Importing with a function #100

@danilopedraza

Description

@danilopedraza

Komodo has a dedicated syntax construct to import stuff:

from "place" import thing
from "place" import (thing1, thing2)

This is fine and can be used nicely, but I'm starting to think it would be better to use import like a function:

let {"thing" => thing,..} := import("place")

This will make dependency injection straightforward and remove the need from some keywords (import, from, as) to exist.

The only thing that I don't like is that there wouldn't be a special syntax for stdlib imports anymore.

Also, to make this new way of importing things more ergonomic, I would like to add the following:

  • a more explicit syntax difference between sets and dicts. For example:

    let %{ "thing" => thing,.. } := import("place")
    

    To just import thing from place.

  • Use <name> as a shorthand for "<name>" => name in dicts. The example above would be like this:

    let %{ thing,.. } := import("place")
    

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