-
Notifications
You must be signed in to change notification settings - Fork 5
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
Parameterized Infos #15
Comments
I think we only need StringListInfo for now. For other list types, it is too complex to support. I don't want to end up reinventing |
For anyone who is wondering, the syntax in the Parsing section is This syntax is for psuedocoding and is not an actual language, |
what invariant mean |
ok what bnf mean |
what jq mean |
Graph::pathFind |
oh I meant it doesn't depend on the parameters
search on Wikipedia, it's a syntax specification format
a Linux command for manipulating JSON data
what about tit? also @keopiwauyu please don't quote the whole post |
Parameterized infos will be available in v2: https://github.com/SOF3/InfoAPI/blob/v2-virion/src/ast.php |
Motivation
It is useful to be able to pass simple parameters, such as string and number literals, into the info resolution path. For example,
{number add(1)}
comes handy in many cases. This also allows to implement new info types like{stringList join(", ")}
.Goals
Non-goals
Graph::pathFind
continues to work. This also means return type of an info is fixed, invariant of the input parameters.Design details
Parsing
Currently, the template syntax inside
{}
is defined asIt is proposed that
qualified_name
be modified toIn particular, the parser must properly support
)
and|
inside string literals.API
Add a new method
provideParameterizedInfo
, which takes a closureClosure(Info, Arguments): Info
.Arguments
is one ofNamedArguments
providingget(string $key)
orUnnamedArguments
providingget(int $index)
.Possible enhancements
Use parameterized infos to implement the following new infos:
NumberInfo add(number) -> NumberInfo
NumberInfo sub(number) -> NumberInfo
NumberInfo mul(number) -> NumberInfo
NumberInfo div(number) -> NumberInfo
NumberInfo reciprocal -> NumberInfo
(such that{a reciprocal mul(b)}
givesb / a
)NumberInfo mod(number) -> NumberInfo
NumberInfo imod(number) -> NumberInfo
(mod
with arguments flipped)StringInfo wrapIfNonEmpty(prefix?: string, suffix?: string) -> StringInfo
The text was updated successfully, but these errors were encountered: