flitter-core | ||
flitter-macros | ||
.gitignore | ||
.rustfmt.toml | ||
Cargo.toml | ||
README.md |
Language changes from Flitter 1
Columns
Vectors may now include numeric "columns", which allows both for matrices and
neater processing of structured data, like vectors of points or colours.
Columns are created with the {…}
operator, which will only accept a
numeric vector as input. Vectors of columns with the same height are
optimised into a matrix. Existing indexing, iterating and let de-structuring
expressions treat columns as individual values. Applying the same {…}
syntax
around a name-list allows for de-structuring a column, e.g.:
let p = {0;1};{2;3}
let {x;y} = p[1]
will bind x
to 2
and y
to 3
.
New expansion rules apply for columns: the height of the result of a numeric binary operation will be the maximum of the heights of the operands, and the shorter operand is wrapped in both dimensions. So with:
let x = {0;1;2};{3;4;5};{6;7;8}
y = 1;2
z = {1;2}
x + y
will be {1;2;3};{5;6;7};{7;8;9}
and x + z
will be
{1;3;3};{4;6;6};{7;9;9}
.
Mixed-height vectors are supported, just as mixed type vectors are still supported. However, mixed-height vectors are less efficiently stored and are not considered to be "numeric" for the purposes of mathematical operations. Indexing/de-structuring can be used to extract fully numeric vectors.
Mathematical operations
The %
operator is now a C-style remainder, %%
is "proper" modulo. These
are intended to pair visually with the /
and //
division operators.
As most extant Flitter modulo-arithmetic code doesn't involve negative numbers, this is probably not a breaking change for most code.
Comparison operations
All comparison operations are now piece-wise instead of operating on whole
vectors. Equality, inequality and greater/lesser comparisons will evaluate to
vectors of true
/false
values. Expansion rules apply for vectors of
different lengths and/or heights.
New any
and all
prefix operators collapse a vector of truth values into a
single truth value. In the absence of the explicit use of one of these, the
default boolean value of a vector (for if
, and
, or
, etc.) is all
. This
is a change from Flitter 1 where the default was effectively any
.
There are unlikely to be many places where comparison operators were used on
non-scalar values, so this should hopefully not be a significant problem. The
change to all
instead of any
default logic may cause issues.
(To be precise, all
will always return a truth value, any
actually returns
the first non-false value from its input vector or null
otherwise.)
Attributes
Attributes are now an ordered sequence of named values and nodes do not impose
uniqueness on the names. So a name may be repeated multiple times with
different values. It is up to the renderers to decide how to interpret any
repeated attributes. In general, it is expected that most renderers will use
the last value, which effectively maintains the previous behaviour. However,
there are places where it will be more useful to take all attributes in order.
For example, the !transform
node could then apply multiple transforms of the
same kind, such as a translation, followed by a rotation and then another
translation.