Programming Search⌘K

Patterncore

Proxy pattern

Also called Proxy, Surrogate, stub, smart reference, smart pointer.

A proxy stands in for another object and has the same interface. It controls access to the real object: it can make it on first use, check permissions, or send the call to another process.

Family
structural-design
Intent
Provide a surrogate or placeholder for another object, to control access to it.
Also called
Surrogate

Intent

Provide a surrogate or placeholder for another object, to control access to it.1 The proxy has the same interface as the real object, which Design Patterns calls the subject. A client that holds the proxy cannot tell it from the subject. The proxy decides when and whether to pass each request on.

Problem

A document editor shows a document with large images. To load each image from disk when the document opens would be slow, and many images are never on the screen. But the document wants to treat each image as an object with a size and a draw method. Design Patterns starts from this example.1

The same shape appears in other places. An object lives in another process, but the caller wants to call its methods as if it were local. An object must be shown only to some users. An object is costly to copy, and most copies are never changed. In each case, a client must use an object through its normal interface, and some work must happen between the client and the object.

The forces are these. The client code must not change. The extra work, such as loading, checking or sending, must be in one place. And the real object must not know about it.

Solution

Design Patterns names three participants.1

  • Subject is the interface that the real object and the proxy share.
  • RealSubject is the object that does the work.
  • Proxy holds a reference to the real subject, or the means to get one. It implements the subject interface and passes requests on.

Design Patterns lists four kinds of proxy.1

  • A virtual proxy makes a costly object on demand. The image proxy is one.
  • A protection proxy checks that the caller may make a request.
  • A remote proxy stands for an object in another address space.
  • A smart reference does extra work on each access, such as counting references, loading a persistent object, or locking.

The examples build a virtual proxy and a protection proxy for one report. The report prints a line when it loads, so the output shows when the load happens:

Language Virtual proxy Protection proxy
Python __getattr__ forwards each attribute a class with render
JavaScript the built-in Proxy with a get trap a Proxy over the report
TypeScript a class that implements Report a class that implements Report
Java java.lang.reflect.Proxy and an InvocationHandler a second handler
C# Lazy<T> inside a class DispatchProxy
Go sync.OnceValue a struct with the same method
Rust OnceCell a generic struct over any Report
C++ a template with operator-> a class that holds a reference

Lazy loading

A virtual proxy holds a factory and an empty slot. On the first request it calls the factory, fills the slot, and forwards. Later requests forward at once. Standard libraries hold this logic in one type: Lazy<T> in .NET, sync.OnceValue in Go, OnceCell and LazyCell in Rust, and functools.cached_property in Python.1719202118 With these types, the proxy class has only the forwarding methods.

The lazy object must be safe when threads share it. Two threads can find the slot empty at the same moment and make two objects. Lazy<T> is thread safe by default, and sync.OnceValue may be called from many goroutines.1719 Rust's OnceCell is for one thread, and OnceLock is the thread-safe form.21

Access control

A protection proxy runs a check before it forwards. The check is in the proxy, so the real object has no code for permissions. Design Patterns gives the example of objects in an operating system that different clients may use in different ways.1 The Python, TypeScript, Go, Rust and C++ examples write the check as a method of a class with the same interface. The JavaScript and C# examples put it in a dynamic proxy that sees each call.

ECMAScript has a proxy that a program can turn off. Proxy.revocable returns a proxy and a function that revokes it. After the call, each operation on the proxy throws a TypeError.7 A program can give a proxy to code that it does not trust, and take the access back later.

Remote proxies

A remote proxy turns each call into a message. It packs the method name and the arguments, sends them, waits for the answer, and unpacks the result. Birrell and Nelson built remote procedure calls this way. A call goes from the user to a user-stub, then through the RPC runtime to a server-stub, which makes a normal local call to the server. A program named Lupine generated both stubs from the interface.3 The user-stub is a remote proxy.

This program has a client stub and a server stub, with a transport function in between. A second transport fails, as a network can:

import json


class Report:
    def render(self, month):
        return f"report for {month}: 42 orders"


def server_stub(subject, message):
    call = json.loads(message)
    result = getattr(subject, call["method"])(*call["args"])
    return json.dumps({"result": result})


class ReportStub:
    """A remote proxy: it has the interface of Report, and it sends each call as a message."""

    def __init__(self, transport):
        self._transport = transport

    def render(self, month):
        message = json.dumps({"method": "render", "args": [month]})
        print("send:", message)
        return json.loads(self._transport(message))["result"]


def network(message):
    return server_stub(Report(), message)


def broken_network(message):
    raise ConnectionError("no route to the report server")


print(ReportStub(network).render("May"))
try:
    ReportStub(broken_network).render("June")
except ConnectionError as error:
    print("error:", error)
Output
send: {"method": "render", "args": ["May"]}
report for May: 42 orders
send: {"method": "render", "args": ["June"]}
error: no route to the report server

The second call shows the limit of the pattern. Report.render never raises ConnectionError, but the stub does. Waldo, Wyant, Wollrath and Kendall argue that a remote object cannot be made to look like a local one. They name four differences: latency, memory access, partial failure and concurrency.4 A remote proxy hides the code that sends a message. It cannot hide that the call is slow, that the argument is a copy and not a reference, or that the network can fail in the middle of a call. An interface for remote objects should show these facts, for example with a timeout and an error in the type of each method.

Example

The example files share the script of the table above. They make the lazy proxy, call render twice, and then guard the lazy proxy for a guest and for an admin. The load message comes after proxy made and appears once.

PythonGitHub
class Report:
    def __init__(self):
        print("load: read the report from disk")
        self.orders = 42

    def render(self):
        return f"report: {self.orders} orders"


class LazyReport:
    """A virtual proxy: it makes the real report on first use."""

    def __init__(self, factory):
        self._factory = factory
        self._real = None

    def __getattr__(self, name):
        # Python calls __getattr__ only for names that the proxy itself does not have.
        if self._real is None:
            self._real = self._factory()
        return getattr(self._real, name)


class GuardedReport:
    """A protection proxy: it checks the role and then forwards."""

    def __init__(self, report, role):
        self._report = report
        self._role = role

    def render(self):
        if self._role != "admin":
            return "access denied"
        return self._report.render()


lazy = LazyReport(Report)
print("proxy made")
print(lazy.render())
print(lazy.render())
for role in ["guest", "admin"]:
    print(f"{role}: {GuardedReport(lazy, role).render()}")
Output
proxy made
load: read the report from disk
report: 42 orders
report: 42 orders
guest: access denied
admin: report: 42 orders
  • Verdict: idiom. __getattr__ runs only when the normal lookup fails, so one method forwards every attribute that the proxy does not define. The proxy needs no copy of the real class's interface.
  • __getattr__ does not catch special methods such as __len__. Python looks them up on the type, not on the instance, so len(lazy) fails. The node page shows this error.
  • The guard is written out by hand. A protection proxy names the methods it checks, so a forwarding method for each of them is clearer than __getattr__.
  • functools.cached_property gives a lazy attribute without a proxy object, when the class that owns the attribute can change.
#include <functional>
#include <iostream>
#include <memory>
#include <string>

struct Report {
    virtual ~Report() = default;
    virtual std::string render() const = 0;
};

struct DiskReport final : Report {
    DiskReport() { std::cout << "load: read the report from disk\n"; }
    std::string render() const override { return "report: " + std::to_string(orders) + " orders"; }
    int orders = 42;
};

// A smart reference: operator-> makes the object on first use and then forwards to it.
template <class T>
class LazyPtr {
public:
    explicit LazyPtr(std::function<std::unique_ptr<T>()> factory) : factory_(std::move(factory)) {}
    T* operator->() {
        if (!real_) {
            real_ = factory_();
        }
        return real_.get();
    }

private:
    std::function<std::unique_ptr<T>()> factory_;
    std::unique_ptr<T> real_;
};

// A virtual proxy with the same interface as the real report.
class LazyReport final : public Report {
public:
    LazyReport() : real_([] { return std::make_unique<DiskReport>(); }) {}
    std::string render() const override { return real_->render(); }

private:
    mutable LazyPtr<DiskReport> real_;  // mutable: loading does not change what render returns
};

// A protection proxy.
class GuardedReport final : public Report {
public:
    GuardedReport(const Report& inner, std::string role) : inner_(inner), role_(std::move(role)) {}
    std::string render() const override { return role_ == "admin" ? inner_.render() : "access denied"; }

private:
    const Report& inner_;
    std::string role_;
};

int main() {
    LazyReport report;
    std::cout << "proxy made\n";
    std::cout << report.render() << "\n";
    std::cout << report.render() << "\n";
    for (const char* role : {"guest", "admin"}) {
        std::cout << role << ": " << GuardedReport(report, role).render() << "\n";
    }
}
Output
proxy made
load: read the report from disk
report: 42 orders
report: 42 orders
guest: access denied
admin: report: 42 orders
  • Verdict: idiom. Design Patterns shows a smart reference in C++ that overloads operator->. LazyPtr is one: real_->render() calls operator->, which makes the object if it does not exist, and the call goes on to the pointer it returns.
  • std::unique_ptr and std::shared_ptr are proxies of the same kind. They forward -> and * to the object, and they add ownership.
  • render is const, but the first call fills the pointer. The member is mutable, because loading does not change the value that the report shows. A proxy shared by threads needs std::call_once or a mutex here.
  • GuardedReport holds a reference, so it must not outlive the report that it guards.
JavaGitHub
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.function.Supplier;

public class Main {
    interface Report {
        String render();
    }

    static final class DiskReport implements Report {
        private final int orders;

        DiskReport() {
            System.out.println("load: read the report from disk");
            orders = 42;
        }

        public String render() {
            return "report: " + orders + " orders";
        }
    }

    // A virtual proxy: the handler makes the real object on the first call.
    static final class Lazy implements InvocationHandler {
        private final Supplier<Report> factory;
        private Report real;

        Lazy(Supplier<Report> factory) {
            this.factory = factory;
        }

        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            if (real == null) {
                real = factory.get();
            }
            try {
                return method.invoke(real, args);
            } catch (InvocationTargetException e) {
                throw e.getCause(); // rethrow what the real method threw
            }
        }
    }

    // A protection proxy: the handler checks the role before it forwards.
    record Guard(Report inner, String role) implements InvocationHandler {
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            if (method.getName().equals("render") && !role.equals("admin")) {
                return "access denied";
            }
            return method.invoke(inner, args);
        }
    }

    static Report proxy(InvocationHandler handler) {
        return (Report) Proxy.newProxyInstance(
                Report.class.getClassLoader(), new Class<?>[] {Report.class}, handler);
    }

    public static void main(String[] args) {
        Report report = proxy(new Lazy(DiskReport::new));
        System.out.println("proxy made");
        System.out.println(report.render());
        System.out.println(report.render());
        for (String role : new String[] {"guest", "admin"}) {
            System.out.println(role + ": " + proxy(new Guard(report, role)).render());
        }
    }
}
Output
proxy made
load: read the report from disk
report: 42 orders
report: 42 orders
guest: access denied
admin: report: 42 orders
  • Verdict: stdlib. java.lang.reflect.Proxy.newProxyInstance makes at run time an object that implements the given interfaces. Each call on it goes to the invoke method of an InvocationHandler.
  • A dynamic proxy works only for interfaces. To proxy a class, a program needs a subclass or a library that generates bytecode.
  • Method.invoke wraps an exception from the real method in an InvocationTargetException. The lazy handler unwraps it, so the caller sees the original exception.
  • One handler serves every method of the interface. This fits proxies that do the same work for each call, such as logging, timing or a check.
#:property PublishAot=false
using System.Reflection;

var lazy = new Lazy<IReport>(() => new DiskReport());
IReport report = new LazyReport(lazy);
Console.WriteLine("proxy made");
Console.WriteLine(report.Render());
Console.WriteLine(report.Render());
foreach (var role in new[] { "guest", "admin" })
{
    Console.WriteLine($"{role}: {Guard.For(report, role).Render()}");
}

public interface IReport
{
    string Render();
}

sealed class DiskReport : IReport
{
    readonly int _orders;

    public DiskReport()
    {
        Console.WriteLine("load: read the report from disk");
        _orders = 42;
    }

    public string Render() => $"report: {_orders} orders";
}

// A virtual proxy: Lazy<T> makes the real object on the first read of Value.
sealed class LazyReport(Lazy<IReport> real) : IReport
{
    public string Render() => real.Value.Render();
}

// A protection proxy made at run time: DispatchProxy sends each call to Invoke.
public class Guard : DispatchProxy
{
    IReport _inner = null!;
    string _role = "";

    public static IReport For(IReport inner, string role)
    {
        var proxy = Create<IReport, Guard>();
        var guard = (Guard)(object)proxy;
        guard._inner = inner;
        guard._role = role;
        return proxy;
    }

    protected override object? Invoke(MethodInfo? method, object?[]? args)
    {
        if (method?.Name == nameof(IReport.Render) && _role != "admin")
        {
            return "access denied";
        }
        return method?.Invoke(_inner, args);
    }
}
Output
proxy made
load: read the report from disk
report: 42 orders
report: 42 orders
guest: access denied
admin: report: 42 orders
  • Verdict: stdlib. Lazy<T> holds the factory and makes the value on the first read of Value. By default it is thread safe, so two threads that read Value at once get the same object.
  • DispatchProxy.Create<TInterface, TProxy> makes at run time an object that implements the interface and derives from TProxy. Each call goes to Invoke with the MethodInfo of the method.
  • DispatchProxy generates code at run time. A file-based C# program is compiled for native AOT by default, and native AOT has no code generation at run time, so Create throws PlatformNotSupportedException. The #:property PublishAot=false line turns AOT off for this file.
  • Create takes no arguments, so For sets the fields of the guard after Create returns. The cast through object reaches the Guard part of the generated object.
  • The lazy proxy is a class written by hand, because it has one method. A dynamic proxy pays off when an interface has many methods that all need the same treatment.
JavaScriptGitHub
class Report {
  constructor() {
    console.log("load: read the report from disk");
    this.orders = 42;
  }
  render() {
    return `report: ${this.orders} orders`;
  }
}

// A virtual proxy: a built-in Proxy whose get trap makes the real object on first use.
function lazy(factory) {
  let real = null;
  return new Proxy(
    {},
    {
      get(_target, name) {
        real ??= factory();
        const value = Reflect.get(real, name);
        return typeof value === "function" ? value.bind(real) : value;
      },
    },
  );
}

// A protection proxy: the get trap replaces render for a role that may not read.
function guarded(report, role) {
  return new Proxy(report, {
    get(target, name, receiver) {
      if (name === "render" && role !== "admin") {
        return () => "access denied";
      }
      return Reflect.get(target, name, receiver);
    },
  });
}

const report = lazy(() => new Report());
console.log("proxy made");
console.log(report.render());
console.log(report.render());
for (const role of ["guest", "admin"]) {
  console.log(`${role}: ${guarded(report, role).render()}`);
}
Output
proxy made
load: read the report from disk
report: 42 orders
report: 42 orders
guest: access denied
admin: report: 42 orders
  • Verdict: native. Proxy is part of the language. A handler object holds traps, such as get, that the engine calls for operations on the proxy. An operation without a trap goes to the target.
  • Reflect.get does the default lookup, so a trap can change one case and forward the rest.
  • The lazy proxy binds each method to the real object. Without bind, this in render would be the proxy, which is a different object. A class with private #fields fails in that case, and the node page shows the error.
TypeScriptGitHub
interface Report {
  render(): string;
}

class DiskReport implements Report {
  private readonly orders: number;
  constructor() {
    console.log("load: read the report from disk");
    this.orders = 42;
  }
  render(): string {
    return `report: ${this.orders} orders`;
  }
}

// A virtual proxy: it has the same interface and makes the real object on first use.
class LazyReport implements Report {
  private real: Report | null = null;
  private readonly factory: () => Report;
  constructor(factory: () => Report) {
    this.factory = factory;
  }
  render(): string {
    this.real ??= this.factory();
    return this.real.render();
  }
}

// A protection proxy: it checks the role before it forwards.
class GuardedReport implements Report {
  private readonly inner: Report;
  private readonly role: string;
  constructor(inner: Report, role: string) {
    this.inner = inner;
    this.role = role;
  }
  render(): string {
    return this.role === "admin" ? this.inner.render() : "access denied";
  }
}

const report: Report = new LazyReport(() => new DiskReport());
console.log("proxy made");
console.log(report.render());
console.log(report.render());
for (const role of ["guest", "admin"]) {
  console.log(`${role}: ${new GuardedReport(report, role).render()}`);
}
Output
proxy made
load: read the report from disk
report: 42 orders
report: 42 orders
guest: access denied
admin: report: 42 orders
  • Verdict: idiom. Each proxy is a class that implements the same interface as the real object. The client holds a Report and cannot tell which class it has.
  • A static proxy is checked by tsc. A method added to Report makes each proxy class that lacks it a type error. A built-in Proxy, as in the JavaScript example, forwards the method with no change, but tsc cannot check its traps.
  • ??= makes the real object only when real is null, so the second call reuses it.
package main

import (
	"fmt"
	"sync"
)

type Report interface{ Render() string }

type diskReport struct{ orders int }

func loadReport() *diskReport {
	fmt.Println("load: read the report from disk")
	return &diskReport{orders: 42}
}

func (r *diskReport) Render() string { return fmt.Sprintf("report: %d orders", r.orders) }

// lazyReport is a virtual proxy. sync.OnceValue runs loadReport on the first call only.
type lazyReport struct{ real func() *diskReport }

func newLazyReport() lazyReport { return lazyReport{real: sync.OnceValue(loadReport)} }

func (l lazyReport) Render() string { return l.real().Render() }

// guardedReport is a protection proxy.
type guardedReport struct {
	inner Report
	role  string
}

func (g guardedReport) Render() string {
	if g.role != "admin" {
		return "access denied"
	}
	return g.inner.Render()
}

func main() {
	var report Report = newLazyReport()
	fmt.Println("proxy made")
	fmt.Println(report.Render())
	fmt.Println(report.Render())
	for _, role := range []string{"guest", "admin"} {
		fmt.Printf("%s: %s\n", role, guardedReport{report, role}.Render())
	}
}
Output
proxy made
load: read the report from disk
report: 42 orders
report: 42 orders
guest: access denied
admin: report: 42 orders
  • Verdict: stdlib. sync.OnceValue wraps a function so that it runs once, and each later call returns the first result. It is safe to call from many goroutines.
  • Go interfaces are satisfied without a declaration, so a proxy is any type with the same methods. The client holds a Report and does not know which type it has.
  • Go has no dynamic proxy. A proxy for an interface with many methods must forward each of them by hand, or embed the interface and override only some methods.
  • httputil.ReverseProxy in the standard library is a remote proxy for HTTP. It is an http.Handler that sends each request to another server.
RustGitHub
use std::cell::OnceCell;

trait Report {
    fn render(&self) -> String;
}

struct DiskReport {
    orders: u32,
}

impl DiskReport {
    fn load() -> Self {
        println!("load: read the report from disk");
        DiskReport { orders: 42 }
    }
}

impl Report for DiskReport {
    fn render(&self) -> String {
        format!("report: {} orders", self.orders)
    }
}

// A virtual proxy: the OnceCell is empty until the first call fills it.
struct LazyReport {
    real: OnceCell<DiskReport>,
}

impl Report for LazyReport {
    fn render(&self) -> String {
        self.real.get_or_init(DiskReport::load).render()
    }
}

// A protection proxy over any Report.
struct Guarded<'a, R: Report> {
    inner: &'a R,
    role: &'a str,
}

impl<R: Report> Report for Guarded<'_, R> {
    fn render(&self) -> String {
        if self.role != "admin" {
            return "access denied".to_string();
        }
        self.inner.render()
    }
}

fn main() {
    let report = LazyReport { real: OnceCell::new() };
    println!("proxy made");
    println!("{}", report.render());
    println!("{}", report.render());
    for role in ["guest", "admin"] {
        println!("{role}: {}", Guarded { inner: &report, role }.render());
    }
}
Output
proxy made
load: read the report from disk
report: 42 orders
report: 42 orders
guest: access denied
admin: report: 42 orders
  • Verdict: stdlib. OnceCell holds a value that is set at most once. get_or_init runs the function only when the cell is empty, and it works through &self, so render does not need &mut self.
  • OnceCell is not thread safe. OnceLock is the form for many threads, and LazyCell and LazyLock hold the function in the cell.
  • Guarded is generic over R, so the compiler makes a version for each real type, and the call to inner.render() is direct, not through a vtable.
  • Rust smart pointers are proxies in the sense of Design Patterns. Deref lets Box, Rc and MutexGuard forward method calls to the value they hold.

Consequences

Design Patterns says that a proxy adds a level of indirection, and that the indirection has a different use for each kind of proxy.1 A remote proxy hides that the object is in another address space. A virtual proxy can make an object on demand. A protection proxy and a smart reference can do extra work when the object is used. Design Patterns also describes copy-on-write: a proxy can share one subject between copies and copy it only when a client changes it.1

The costs are these. Each call goes through one more object. A proxy with many methods needs a forwarding method for each, unless the language can forward all of them, as Python's __getattr__, the JavaScript Proxy, Java's java.lang.reflect.Proxy and .NET's DispatchProxy can.951314 And identity changes: the proxy is not the real object, so a comparison by identity, a type test, or code that the real object runs on this can tell them apart.

A forwarding proxy does not forward everything. Python calls __getattr__ only when the normal lookup fails.9 For special methods, such as __len__, Python looks on the type of the object and skips the instance, so __getattr__ does not run.10

This code raises TypeError, on purpose.

class LazyList:
    def __init__(self, factory):
        self._factory = factory
        self._real = None

    def __getattr__(self, name):
        if self._real is None:
            self._real = self._factory()
        return getattr(self._real, name)


items = LazyList(lambda: [1, 2, 3])
print(items.count(2))  # works: count is found through __getattr__
print(len(items))  # fails: len looks up __len__ on the type LazyList

The fix is to define each special method that the proxy needs on the proxy class.

A JavaScript Proxy has a related limit. A class method that reads a private field #name runs with this set to the proxy. The proxy does not have the private field, so the read throws a TypeError.8

This code raises TypeError, on purpose.

class Account {
  #balance = 100;
  balance() {
    return this.#balance;
  }
}

const proxy = new Proxy(new Account(), {});
console.log(proxy.balance());

The fix is a get trap that binds each method to the target, as the JavaScript example does.

When not to use it

Do not write a proxy class when the language gives a lazy value. A field of type Lazy<T>, OnceCell or sync.OnceValue, or a cached_property, does the work with no extra class.17211918

Do not hide a remote call behind a local interface when the caller must handle its failures. Give the remote interface its own types, with timeouts and errors that the caller sees.4

Do not use a protection proxy as the only check when other code can reach the real object. The check works only if every path to the object goes through the proxy.

Decorator. A decorator and a proxy have the same structure: an object with the same interface wraps another. Design Patterns separates them by purpose. A decorator adds responsibilities, and a program often stacks several of them. A proxy controls access to the subject, and it often makes or finds the subject itself.1 See Decorator pattern.

Adapter. An adapter gives an object a different interface. A proxy gives it the same interface.1 See Adapter pattern.

Facade. A facade gives a smaller interface to a group of objects. A proxy stands for one object. See Facade pattern.

Smart pointers. Design Patterns shows a smart reference in C++ that overloads operator->.1 Norvig lists smart pointers among the patterns that are invisible in dynamic languages, and Proxy among the patterns that first-class types make less complex.2 In Rust, Deref lets a smart pointer such as Box or Rc forward method calls to the value it holds.16 Reference counting in a smart pointer does the work that a garbage collector does in other languages. See Garbage collection and ownership.

Weak references. Python's weakref.proxy returns a proxy that uses a weak reference to its object. The proxy does not keep the object alive, and it is not hashable.11

Known uses

  • JavaScript: Proxy objects are part of the language. A handler object holds traps that the engine calls for the internal methods of the proxy, such as [[Get]] and [[Set]].56
  • Java: java.lang.reflect.Proxy makes at run time an object that implements a list of interfaces, and sends each call to an InvocationHandler.13
  • .NET: System.Reflection.DispatchProxy makes proxy objects and sends their method calls to one Invoke method.14
  • Python: a multiprocessing proxy refers to a shared object that lives, presumably, in a different process. Its methods call the methods of that object.12
  • Go: httputil.ReverseProxy is an HTTP handler that takes a request and sends it to another server.15

References

  1. Gamma, Helm, Johnson and Vlissides, Design Patterns, Elements of Reusable Object-Oriented Software, Addison-Wesley, 1994, Chapter 4, Proxy (Intent, Also Known As, Motivation, Applicability, Participants, Consequences, Implementation, Related Patterns)
  2. Peter Norvig, Design Patterns in Dynamic Programming, Object World, May 1996, slide 10 (Proxy is among the patterns affected by first-class types) and slide 30 (Other Invisible Patterns, smart pointers)
  3. Andrew D. Birrell and Bruce Jay Nelson, Implementing Remote Procedure Calls, ACM Transactions on Computer Systems 2(1), 1984, section 1.5, Structure
  4. Jim Waldo, Geoff Wyant, Ann Wollrath and Sam Kendall, A Note on Distributed Computing, Sun Microsystems Laboratories, SMLI TR-94-29, November 1994, Abstract
  5. ECMA-262, ECMAScript 2025 Language Specification, 28.2 Proxy Objects
  6. ECMA-262, ECMAScript 2025 Language Specification, 10.5 Proxy Object Internal Methods and Internal Slots
  7. ECMA-262, ECMAScript 2025 Language Specification, 28.2.2.1 Proxy.revocable
  8. MDN Web Docs, Proxy, No private field forwarding
  9. The Python Language Reference, Data model, Python 3.14, 3.3.2 Customizing attribute access
  10. The Python Language Reference, Data model, Python 3.14, 3.3.13 Special method lookup
  11. The Python Standard Library, weakref, Python 3.14, weakref.proxy
  12. The Python Standard Library, multiprocessing, Python 3.14, Proxy Objects
  13. Java SE 25 API, java.lang.reflect.Proxy, class description
  14. .NET API reference, System.Reflection.DispatchProxy, class description
  15. Go standard library, package net/http/httputil, type ReverseProxy
  16. Rust standard library, std::ops::Deref, trait description
  17. .NET API reference, System.Lazy<T>, class description and remarks on thread safety
  18. The Python Standard Library, functools, Python 3.14, functools.cached_property
  19. Go standard library, package sync, func OnceValue
  20. Rust standard library, std::cell::LazyCell, struct description
  21. Rust standard library, std::cell::OnceCell, struct description

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/HYDT82/text.yaml