Skip to content

Instantly share code, notes, and snippets.

@ShawSumma
Created January 15, 2021 09:49
Show Gist options
  • Save ShawSumma/37f5a99fea03407a07bba4168c4c02f7 to your computer and use it in GitHub Desktop.
Save ShawSumma/37f5a99fea03407a07bba4168c4c02f7 to your computer and use it in GitHub Desktop.
Polyfill for Quest to add "Unary" Object.
unary_polyfill_config = {
typename = 'Unary';
aliases = {
'+@' = '+/1';
'+' = '+/2';
'-@' = '-/1';
'-' = '-/2';
:0
}();
debug = {};
:0
}();
:0.(unary_polyfill_config.typename) = {:0}();
:0.(unary_polyfill_config.typename).'-' = {
args = __args__;
unary_polyfill_config::debug('-', __args__);
if(args.len() == 1, {
(args[0]).(unary_polyfill_config.aliases.'-@')()
}, {
(args[0]).(unary_polyfill_config.aliases.'-')(args[1])
});
};
:0.(unary_polyfill_config.typename).'-@' = {
(__args__[0]).'-'()
};
:0.(unary_polyfill_config.typename).'+' = {
args = __args__;
unary_polyfill_config::debug('+', __args__);
if(args.len() == 1, {
(args[0]).(unary_polyfill_config.aliases.'+@')()
}, {
(args[0]).(unary_polyfill_config.aliases.'+')(args[1])
});
};
:0.(unary_polyfill_config.typename).'+@' = {
(__args__[0]).'+'()
};
Number.(unary_polyfill_config.aliases.'+@') = Number::'+@';
Number.(unary_polyfill_config.aliases.'+') = Number::'+';
Number.(unary_polyfill_config.aliases.'-@') = Number::'-@';
Number.(unary_polyfill_config.aliases.'-') = Number::'-';
Number.__del_attr__('-@');
Number.__del_attr__('+@');
Number.__del_attr__('-');
Number.__del_attr__('+');
Number.__parents__.push(:0.(unary_polyfill_config.typename));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment