PolyhedralDev / Terra

Voxel world generation modding platform
MIT License
670 stars 88 forks source link

Add let expression support #478

Closed astrsh closed 3 weeks ago

astrsh commented 3 weeks ago

Pull Request

Description

Adds support for Paralithic let expressions (currently in Paralithic dev awaiting proper release). Let expressions enable the ability to bind names to expressions within the context of another expression, e.g.

5 + let
  a := 3.5,
  b := a^2, // Optional trailing comma
in a * b * (let d := sqrt(x) in cos(d))

As the introduction of let expressions may break config packs and the noise predicate addon (which uses the in invocation variable reserved as a keyword in let expressions), this must explicitly be enabled in pack.yml via the following:

expressions:
  options:
    enable-let-expressions: true

The noise predicate addon will use input instead of in if let expressions are enabled, which currently affects only the EXPRESSION_NORMALIZER sampler.

Checklist

Mandatory checks

Types of changes

Compatibility

Documentation

Testing

Licensing