rant icon indicating copy to clipboard operation
rant copied to clipboard

Prototypes

Open TheBerkin opened this issue 3 years ago • 0 comments

Add support for prototype functions to map objects for OOP workflows, custom access logic, etc.

This is a WIP issue for ongoing design work on prototypes.

Getting and setting prototypes

Map prototypes can be retrieved and assigned with [proto] and [set-proto] respectively:

<$myobj = @()>
<$myproto = @(proto-method = [?]{foo})>
[set-proto:<myobj>;<myproto>]
[proto:<myobj>] # [map(1)]

Prototype methods

Elements of a map's prototype act like elements of the owning map.

<$myobj = @()>
<$myproto = @()>

[$myobj/test] { foo }
[$myproto/test] { bar }

[set-proto: <myobj>; <myproto>]

[myobj/test] # bar

TheBerkin avatar Oct 11 '20 07:10 TheBerkin