Skip to content

language: packages with proper namespacing #201

Open

Description

@vitorarins

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

Activity

  1. changed the title [-]Packages[/-] [+]language: packages with proper namespacing[/+] on Mar 31, 2017
  2. vitorarins commented on Apr 15, 2017

    @vitorarins
    MemberAuthor

    I think this depends on #202

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions