mani-language / Mani

Máni ... an awesome, super simple programming language!
https://mani-language.github.io/
Mozilla Public License 2.0
28 stars 7 forks source link

Namespaces v2 #46 #77

Closed crazywolf132 closed 5 years ago

crazywolf132 commented 5 years ago

Is your PR related to a feature request or Bug report? If applicable, please list feature request number or bug report ID.

This is related to PR #46

Describe your PR A clear and concise description of what your pull request is changing or adding.

We have implemented namespaces into this language. This will allow a whole load of features, including the use of the same variable names multiple times.

Describe intended use A clear and concise description of the intended use of the feature. Along with example code.

Unless you actively want to work with namespaces, you don't need to do anything. Otherwise, the use of the new nameset "namespace-name"; operator will change the current working namespace.

>> let someList = [1, 2, 3, 'wow'];
>> say someList;
[1.0, 2.0, 3.0, wow]
>> nameset 'otherNamespace';
Namespace switched: otherNamespace

>> say someList;
Undefined variable 'someList'.
>> [line 1]

>> let y = 12 + 12 + 12;
>> say y;
36
>> nameset;
Namespace switched: default

>> say someList;
[1.0, 2.0, 3.0, wow]
>> say y;
Undefined variable 'y'.
>> [line 1]

How did you fix the bug? If applicable, how did you fix the bug? Please use code snippets too.

N/A

Is it in the form of a library

If applicable what is the library called?

N/A

Does your PR replace an existing system If applicable, please describe how this PR changes the use of a related item.

It replaces how the original environment system worked. It simply used to be a key-value pair of information. Now it is a namespace-value pair.

Additional comments Add any additional comments or screenshots here.

crazywolf132 commented 5 years ago

@Kalekdan Designed the Namespaces class. Therefor, the core designer.