Skip to content

using namespace should support dynamic namespaces #1133

Open
@StartAutomating

Description

@StartAutomating

Useful syntax

using namespace https://x/y/z # is valid syntax
# so is:
using namespace @'
ghcr.io/startautomating/pipescript
'@
# so is:
using namespace anynamespacethatdoesnotexist
# or
using namespace language.javascript

By using syntax like this, we can describe as dynamic of a namespace as we'd like.

Additionally, since dynamic namespaces are simply dynamic objects, they can dynamically describe a "use"

For example, we could "use" a container registry as a base image to run code in a container.

We could also simply "use" any language object to attempt to run or translate the script (that would be up to each language to decide).

Architecture

Using one or more dynamic namespaces should be fairly straightforward.

Let us imagine our using namespace statements, and the namespace keyword, as a stack of namespaces.

If any of the stack items are defined and have a .Use method, that will be called with the ScriptBlock as input.

Any output will be passed to the next defined .Use for a namespace.

If the output from the entire chain is a [ScriptBlock], and the file is a template, it will be the output of the template.

Using Languages

Since anything can become a namespace, all languages will be considered namespaces.

Thus, if a language defines a .Use, and it is in the stack, it will be used.

Using Protocols

Since anything can become a namespace, all protocols will be considered namespaces.

Thus, if a protocol defines a .Use, and it is in the stack, it will be used.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions