brownplt / pyret-docs

The documentation for Pyret.
9 stars 18 forks source link

note distinction between method bindings and method values #73

Closed pnkfelix closed 1 year ago

pnkfelix commented 1 year ago

note distinction between method bindings and method values in docs for dot expressions.

offshoot of https://github.com/brownplt/pyret-lang/issues/1661


(Note that there is a chance that the language designers did not intend for method bindings to be distinct from method values, in which case this is an implementation bug. I.e., there is a sensible semantics that says that method bindings behave like functions, except that they are still method values and can be rebound when they are put into different objects.)

jpolitz commented 1 year ago

Thanks for the documentation and the deep dive!

I can confirm that this is working as intended.

The design intent is to allow method values to be freely shared between multiple objects (as long as they are created as standalone method values), while not requiring type-based resolution of expressions like o.m() to figure out if m is a method or a function, and also to ensure that o.m() is semantically equivalent to (o.m)().

There are a bunch of reasons why this is a sort of sweet spot for not requiring types, not requiring special method-call syntax, and supporting semantics we want for traditional-looking o.m() method calls.