Alternative for lazy entrypoint in the new Syntax

The following question has been asked on Telegram:

How can we use lazify entrypoint with new syntax?

You can use lambdas in the storage.

To do this, you can create a field named storage in It will contain everything you usually store in Then you can have option of lambdas in that correspond to the entrypoints you want to lazify. These lambdas parameter is in the form sp.lambda_(sp.pair[t_storage, t_param], t_storage, with_operations=True) where t_storage is the type of the storage field and t_param the type of the entrypoint parameter.

For example:

import smartpy as sp

def main():
    t_storage: type = sp.record(,
    t_lazy_ep: type = sp.record(,

    class MyContract(sp.Contract):
        def __init__(self):
   = sp.cast(
                        sp.pair[t_storage, t_lazy_ep],
            storage = sp.record(x=0, y=1)
   = sp.cast(storage, t_storage)

        def lazy_ep(self, param):
            sp.cast(param, sp.record(,
            p = (, param)
            storage =
   = storage

        def set_lazy_ep(self, l):
   = l

    def lazy_ep(p):
        (storage, param) = p
        sp.cast(storage, t_storage)
        sp.cast(param, t_lazy_ep)
        return sp.record(x=storage.x + param.a, y=storage.y + param.b)

if "templates" not in __name__:

    def test():
        sc = sp.test_scenario(main)
        c1 = main.MyContract()
        sc += c1