let (rec) insertion without Effects, Lights or Magic

01/03/2022
by   Oleg Kiselyov, et al.
0

Let insertion in program generation is producing code with definitions (let-statements). Although definitions precede uses in generated code, during code generation `uses' come first: we might not even know a definition is needed until we encounter a reoccurring expression. Definitions are thus generated `in hindsight', which explains why this process is difficult to understand and implement – even more so for parameterized, recursive and mutually recursive definitions. We have earlier presented an interface for let(rec) insertion – i.e. for generating (mutually recursive) definitions. We demonstrated its expressiveness and applications, but not its implementation, which relied on effects and compiler magic. We now show how one can understand let insertion, and hence implement it in plain OCaml. We give the first denotational semantics of let(rec)-insertion, which does not rely on any effects at all. The formalization has guided the implementation of let(rec) insertion in the current version of MetaOCaml.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
11/20/2018

A right-to-left type system for mutually-recursive value definitions

In call-by-value languages, some mutually-recursive value definitions ca...
research
09/25/2018

Towards Automated Let's Play Commentary

We introduce the problem of generating Let's Play-style commentary of ga...
research
07/25/2022

Evolving Recursive Definitions with Applications to Dynamic Programming

Inspired by computability logic<cit.>, we refine recursive function defi...
research
02/16/2021

Nominal Unification and Matching of Higher Order Expressions with Recursive Let

A sound and complete algorithm for nominal unification of higher-order e...
research
08/05/2022

Recurrence extraction and denotational semantics with recursive definitions

With one exception, our previous work on recurrence extraction and denot...
research
11/06/2018

Unboxing Mutually Recursive Type Definitions in OCaml

In modern OCaml, single-argument datatype declarations (variants with a ...
research
02/04/2018

A Scheme-Driven Approach to Learning Programs from Input/Output Equations

We describe an approach to learn, in a term-rewriting setting, function ...

Please sign up or login with your details

Forgot password? Click here to reset