Child pages
  • Coding Style and Guidelines for Contributors

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added typed equality section


evaluates a + b when lv is first called/used, and saves the value, so that it is only computed once.

Use Typed Equality

Subtle bugs can arise when comparing a == b, when a and b turn out to be different types. The == operator is "natural" equality, which simply returns false if a and b are different types.

There are arguments for why this is good and useful and such, see:

However, very often this masks a programmer error. If a and b are of types that it makes no sense to be comparing, then a == b should, ideally, be a scala compile-time type error.

To achieve this, we have two forms of strongly typed equality in the daffodil.equality package. To use them you must

Code Block
import edu.illinois.ncsa.daffodil.equality._


There are two operators:

  • a =:= b provides "Type Equality" for use when a and b have a subtype relationship, including the most obvious case of a and b both being of the same type.
  • a =#= b provides "View Equality" for use when a and b are convertible, that is, a can be implicitly converted to b's type, or b can be implicitly converted to a's type. Numbers and number-like types are common cases for this so the "#" in the operator is suggestive of  "number"

Of these, the a =:= b is the more important and more commonly used. The ":" in the name is supposed to suggest the concept of "typed".

(To be determined - what is the performance of these relative to ordinary a == b.)

Attach the Source Code

Our build system will obtain the source code for libraries when sbt is able to retrieve them. If a library is not sbt-managed the library itself goes in the lib sub-directory, and the source code and documentation go into libsrc.