Software Engineering

Programming with Implicit Values, Functions, and Control

by Jonathan Im­manuel Brachthäuser and Daan Lei­jen

Tech­ni­cal re­port MSR-TR-2019-7. Mi­crosoft Re­search, 2019.

This pub­li­ca­tion is re­lated to the Lex­i­cal Ef­fect Han­dlers re­search pro­ject.

Ab­stract

We in­tro­duce two new lan­guage fea­tures, called im­plicit func­tions and im­plicit con­trol. Both gen­er­al­ize im­plicit val­ues (or pa­ra­me­ters) which are a typed im­ple­men­ta­tion of dy­namic bind­ing. Im­plicit func­tions are bound dy­nam­i­cally but eval­u­ated in the lex­i­cal scope of their bind­ing. We show how this small gen­er­al­iza­tion from reg­u­lar im­plicit val­ues leads to bet­ter ab­strac­tion. In par­tic­u­lar, im­plicit func­tions en­cap­su­late (side) ef­fects at the de­f­i­n­i­tion site, as op­posed to leak­ing them to the call site. Im­plicit con­trol fur­ther gen­er­al­izes im­plicit func­tions by adding the abil­ity to re­turn into the lex­i­cal scope of the bind­ing or to re­sume to the call-site. We for­mal­ize the new fea­tures as an ex­ten­sion to Moreau’s cal­cu­lus of dy­namic bind­ing (1998). Uni­fy­ing all three lan­guage fea­tures in one frame­work guar­an­tees that the in­ter­ac­tion be­tween im­plicit val­ues, func­tions, and con­trol is well-de­fined. We also show how our se­man­tics cor­re­spond to a macro-trans­la­tion into al­ge­braic ef­fect han­dlers.