evhub / rabbit

Rabbit is a modern, functional programming language built on top of Python.
13 stars 1 forks source link

Make all operators redefinable #88

Open evhub opened 10 years ago

evhub commented 10 years ago

Operators should be defined using a special binding system. An operator function should be bound to an operator, which should be given a level and (optionally) made reserved. Possible syntax:

bind :: +(x,y) = add(x,y)
infix :: mod(x,y) = x%y
bind :: + :: -(x,y) = sub(x,y)
evhub commented 10 years ago

For adding comparison operators:

bind :: = :: ≠(x,y) = x != y

For creating operators over multiple arguments:

bind :: +(x,y,z) = add(x,y,z)
bind :: *(__) = mul(__)

For creating a unary function:

bind :: ?(x) = bool(x)

For creating an open/close group:

bind :: "(x)" = str(x)

For redefining an operator:

bind :: + :: +(__) = add(__)
evhub commented 10 years ago

The default operators should be the same, but use special funcfloats wrapping Python instead of pure Rabbit.

Additionally, only these operators should be hardcoded and unredefinable:

#
;;
::
=   # You can redefine =, but that redefines the comparison =
:
.
\
§