You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why should a dynamic language have static namespaces?
If a developer can dynamically define a variable, alias, or function with literally any name, and items can be queried efficiently enough, it makes a startling amount of sense to be able to dynamically define a namespace, too.
PipeScript should embrace dynamic namespacing.
That is, it should be easy to define a namespace in PipeScript, and the namespaces should be as dynamic as possible.
To that end, let us start to think of a dynamic namespace as "a pattern for names".
Justification
In many ways, it already has (see #452). Modules can define CommandTypes, which use a name and pattern to identify themselves.
This is a somewhat awkward name, as it overlaps with the built-in concept of Command Types.
By starting to call these namespaces, the concept should be clear to most programmers.
By letting them be as dynamic as the language they live in, they should be incredibly powerful.
Architecture
A namespace should be able to be self-described in any [PSObject], provided it has the typename 'Namespace'.
Core namespace support will be implemented in .types.ps1xml
Then any object can choose to become a namespace, simply by adding Namespace to it's .pstypenames.
Dynamic Namespaces
Why should a dynamic language have static namespaces?
If a developer can dynamically define a variable, alias, or function with literally any name, and items can be queried efficiently enough, it makes a startling amount of sense to be able to dynamically define a namespace, too.
PipeScript should embrace dynamic namespacing.
That is, it should be easy to define a namespace in PipeScript, and the namespaces should be as dynamic as possible.
To that end, let us start to think of a dynamic namespace as "a pattern for names".
Justification
In many ways, it already has (see #452). Modules can define CommandTypes, which use a name and pattern to identify themselves.
This is a somewhat awkward name, as it overlaps with the built-in concept of Command Types.
By starting to call these namespaces, the concept should be clear to most programmers.
By letting them be as dynamic as the language they live in, they should be incredibly powerful.
Architecture
A namespace should be able to be self-described in any
[PSObject]
, provided it has the typename 'Namespace'.Core namespace support will be implemented in
.types.ps1xml
Then any object can choose to become a namespace, simply by adding
Namespace
to it's .pstypenames.Putting it very simply:
namespace
#1134Once namespaces are easy to declare, they are easy to work with.
Implementation
Dynamic namespaces will bring some core changes to PipeScript:
using namespace
should support dynamic namespaces #1133Any namespace will be able to perform the following methods:
Namespace.Get
should return$this
or other namespaces #1136Namespace.Set
should change$this
or other namespacesNamespace.New
should create namespaces from any object #1135Any namespace will have the following ScriptProperties:
Namespace.get/set_Pattern
should get and set the pattern #1137Namespace.get_Alias
should get aliases in a namespace #1138Namespace.get_Cmdlet
should get cmdlets in a namespace #1139Namespace.get_Function
should get functions in a namespace #1140Namespace.get_Filter
should get filters in a namespace #1141Namespace.get_PSType
should get PSTypes in a namespace #1142Namespace.get_Type
should get types in a namespace #1143Namespace.get_Variable
should get variables in a namespace #1144Namespace.get_Environment
should get environment variables in a namespace #1145Namespace.get_Command
should return namespace commands #1146Any namespace will have the following ScriptMethods:
Namespace.Member(s)()
will return members of objects that are in the namespace. #1148Namespaces should have fairly good formatting:
Namespace
default formatting should display the name and pattern #1147The text was updated successfully, but these errors were encountered: