Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom infix operators via <infix> in spec, kill OP! #36

Merged
merged 1 commit into from
Aug 11, 2015
Merged

Custom infix operators via <infix> in spec, kill OP! #36

merged 1 commit into from
Aug 11, 2015

Conversation

hostilefork
Copy link
Member

This provides the ability to make arbitrary infix functions. This is
for both user code and to simplify the creation of Rebol's default
infix operators as mezzanines. It introduces as the first
case of a function "attribute", which you put at the start of a spec:

+: func [<infix> value1 value2] [add value1 value2]

The INFIX attribute is implemented as one of the value-specific
option bits in the Rebol value header, which previously is where
OP! would store its "actual type" of the function it was wrapping.
The OP! datatype has been killed, and a new infix? test
replacing OP?.

(Note: an OP? implementation is temporarily provided, with the
traditional behavior of tolerating any type whether function or not.)

The infix mezzanines will perform slightly slower than their old
OP! counterparts would, as they are functions with Rebol code
bodies that execute vs. just a trampoline to the C code. However
by being "just a bit" on the spec, it means infixness would be able
to be applied to any speedy mode of specialization or function
aliasing that gets implemented...which is a general need and will
have to be written to turn :append/only into a "refined" function
(for instance). In the meantime, the mezzanines are at least
partially "compiled" with the literal NATIVE! value they wrap.

This provides the ability to make arbitrary infix functions.  This is
for both user code and to simplify the creation of Rebol's default
infix operators as mezzanines.  It introduces <infix> as the first
case of a function "attribute", which you put at the start of a spec:

    +: func [<infix> value1 value2] [add value1 value2]

The INFIX attribute is implemented as one of the value-specific
option bits in the Rebol header, which previously is where OP!
would store its "actual type" of the function it was wrapping.  The
OP! datatype has been killed, and a new infix? test replacing
OP?.

(Note: an OP? implementation is temporarily provided, with the
traditional behavior of tolerating any type whether function or not.)

The infix mezzanines will perform slightly slower than their old
OP! counterparts would, as they are functions with Rebol code
bodies that execute vs. just a trampoline to the C code.  However
by being "just a bit" on the spec, it means infixness would be able
to be applied to any speedy mode of specialization or function
aliasing that gets implemented...which is a general need and will
have to be written to turn :append/only into a "refined" function
(for instance).  In the meantime, the mezzanines are at least
partially "compiled" with the literal NATIVE! value they wrap.
@hostilefork hostilefork merged commit cfae703 into metaeducation:master Aug 11, 2015
@hostilefork hostilefork deleted the infix-custom branch August 12, 2015 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant