Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

language: packages with proper namespacing #201

Open
vitorarins opened this issue Mar 31, 2017 · 1 comment
Open

language: packages with proper namespacing #201

vitorarins opened this issue Mar 31, 2017 · 1 comment

Comments

@vitorarins
Copy link
Member

Packages will work by returning a value that can be used when you import a
package.

For example,

import "x"

Will create a local variable x containing the value returned by package "x".
You can change the name of the imported package using the syntax below:

y = import "x"

The value returned from the package could be anything. See examples below:

Ex.:

# package strings
# returns a map of functions

fn join(lst, sep) {}
fn trimleft(str) {}
fn trimright(str) {}
fn trim() {}

return {
    "join": $join,
    "trimleft": $trimleft,
    "trimright": $trimright,
    "trim": $trim,
}

You can use the package above with code below:

import "strings"

str <= strings["trim"]("    test  ")
echo $str # Output: test
@katcipis katcipis changed the title Packages language: packages with proper namespacing Mar 31, 2017
@vitorarins
Copy link
Member Author

I think this depends on #202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants