mason

polys are polymorphic functions; they have different implementations for different types.

Normally for polymorphism you'll want to use regular class-based methods, but polys can be safely implemented for builtins because implementations are attached to a type's prototype using Symbols, so there is no chance of a name conflict.

Implement them using the builtin function impl!.

|| The default implementation of a method is implicitly a `.\`, meaning that `this` is freshly bound inside.
magnitude = poly \
	|| This is the default implementation.
	"#this".length

|| This modifies Number.prototype.
impl! magnitude Number .\
	this
impl! magnitude String .\
	.length

|| To implement statically, use self-impl!
self-impl! magnitude Number .\
	3

. magnitude 1
. magnitude "2!"
. magnitude Number
|| This uses the default implementation.
. magnitude true

If you don't want a default implementation, use `abstract`.

In that case, arguments listed are purely for documentation.

foo. poly \bar
	abstract

Certain polys such as binary=? also work on null and undefined values.

poly makes polymorphic methods look like regular functions, so it is used extensively in msl.

But you usually won't have to define new polys yourself.