IsDef.jl: maintainable type inference

07/26/2023, 4:00 PM — 4:30 PM UTC
32-141

Abstract:

IsDef.jl provides maintainable type inference in that it

  1. Uses code generation where possible to deterministically infer the types of your code
  2. Allows you to overload type-inference with your custom implementation
  3. If neither code generation works nor a custom type inference rule is given, it falls back to Core.Compiler.return_type, wrapped by some safety nets

In this talk IsDef.jl is presented, along with typical applications and details about the implementation.

Description:

I am super happy to announce the release of IsDef.jl. Since years I wanted to be able to check whether some function is defined for my types. Plain applicable was not enough for me, because it just inspects the first layer, and if this is a generic function (like syntactic sugar), it won't give meaningful results. That was the motivation.

It turns out, you need full-fledged type-inference for this, however Julia's default type-inference is not intended for usage in packages. Inference is not guaranteed to be stable, may be indeterministic, and may change on any minor Julia version, which makes it really hard for maintainability. The purpose of Julia's default type-inference is just code-optimization and as such it is an implementation detail to Julia.

Hence, there is a need for another type inference system, or at least a layer around Julia's default inference which makes it maintainable. Welcome to IsDef.

The highlevel interface of IsDef is very simple, consisting of two functions isdef and Out. The usage of these will be explained, along with implementation details and design decisions.

The package version is 0.1.x - suggestions, critics, and improvement ideas about the way inference is made maintainable are very welcome so that IsDef.jl can become the go-to package for maintainable type inference.

Platinum sponsors

JuliaHub

Gold sponsors

ASML

Silver sponsors

Pumas AIQuEra Computing Inc.Relational AIJeffrey Sarnoff

Bronze sponsors

Jolin.ioBeacon BiosignalsMIT CSAILBoeing

Academic partners

NAWA

Local partners

Postmates

Fiscal Sponsor

NumFOCUS