Add more functionality for rule-set creation. #6
Labels
documentation
Improvements or additions to documentation
enhancement
New feature or request
new core feature
Adds a new core feature.
The basic notion of a rule-set is complete.
However, in order to do more complex rule-sets, right now you have to make intermediary rule-sets, then merge them, like this:
However, it would be nice if we could represent these operations in one go like this:
The
Then
andBack
keywords could control the current rule-set scope.Then
grabs the last child of the current rule-set in scope and sets it as the new scope.Back
grabs the parent of the current rule-set and switches the scope back to it.If one notices the code above, one would realize that we're calling
FindField("x")
many times. Wouldn't it be nice if we cached it?We would need an instruction for it to do so, so we may think of something that looks sort of like this:
We would then introduce the following:
Every rule-set would have a reference to its parent node, through the
parent
field.However, interacting with it directly would be error-prone, as a node could lack a parent (i.e. the root node), so we could have a
GetParent(x)
function, wherex
would determine the amount of jumps it needs to do.i.e.:
GetParent(0)
would return the parent of the rule-set that is in scope right now, andGetParent(1)
would return the parent of the parent of that rule-set.NewCache(x)
would create a cache for the scoped rule-set of sizex
.Cache(i, x)
would cache some resultx
at positioni
of the rule-set in scope.GetCache(i)
would return the cache's contents at indexi
of the rule-set in scope.Now, this entire rule-set would be difficult to write for a Vec3 made with IsNumeric on each sub-element, so it would be nice if we could have some way of repeating rule-sets in-line, maybe something like this:
We could use the cache as a pattern to generate multiple rule-sets.
CachePattern(x)
would create new rule-sets based off of the currently-scoped rule-set's cached contents.In this case, this would create 3 rule-sets with different
FindField
calls, one forFindField("x")
, one forFindField("y")
, and one forFindField("z")
.This would create a rule-set that would create a
IsNumeric
for aVec3
-like structure, aIsNumericVec3
rule-set.The beauty of this is that it could scale massively, and it would require very little re-writing.
This functionality would prove very useful for writing interfaces in one single-line, in a fluent way.
These are all just illustrative, the syntax is bound to be different post implementation, these are just some ideas of desired behavior.
The text was updated successfully, but these errors were encountered: