ohm
Our great sponsors
proposal-operator-overloading | ohm | |
---|---|---|
9 | 10 | |
612 | 4,877 | |
1.5% | 1.0% | |
3.1 | 6.8 | |
4 months ago | about 1 month ago | |
JavaScript | JavaScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
proposal-operator-overloading
-
I think Zig is hard but worth it
There's a not-very-active proposal to add operator overloading to JS which takes a similar scoped approach:
https://github.com/tc39/proposal-operator-overloading
-
Applying common operators (like +, *, -, /, etc.) to objects/arrays/lists?
There's a proposal to add operator overloading to the language, but AFAIK it never landed.
-
Immutability: what a monster...
An example of it would be the operator overloading proposal https://github.com/tc39/proposal-operator-overloading that would allow overriding === and it would also solve in one shot many other problems (like numeric types extension, pipeable operator, and all the ones listed in the proposal).
-
Is there a way to access native operations via class methods?
Kind of but not really. There is the concept of operator overloading that would let you specify how to handler uses of operators like - and + with your class instances, but this is not yet officially supported in JavaScript. There is an operator overloading proposal to maybe add it in the future (and if you're using QuickJS that has support built in), but right now there's not a whole lot you can do.
- Proposed Operator Overloading in JavaScript
-
Extending Built-ins with ES6 Classes
Though this is not possible now since operators always work on primitive values, there is a proposal for operator overloading that could potentially allow us to use operators on objects in the future. It's still very early, so its not something you can use today (or anytime soon, if ever at all). In the meantime, you'll need to use method calls to perform these kinds of operations.
-
[AskJS] Why does our community hate Operator Overloading?
I'm not sure who hates it, but I have seen it abused (which people don't like). But, quickjs has it now, and there's a proposal to have it added to the JS spec. The proposal is only stage 1, so who knows what will happen with it or when, but its not counted out.
-
ES2022 feature: class static initialization blocks
https://github.com/tc39/proposal-operator-overloading
There are still a couple issues that have to be solved. m2c: I hope that won't get to stage 3, though I like operator overloading in general, I think it's something that will complicate JS even more.
- TC39 proposal: operator overloading in JavaScript
ohm
-
Ohm: A library and language for building parsers, interpreters, compilers, etc.
Building an interpreter or a compiler from a grammar is an interesting idea. I can't immediately see how to go about it - the grammar would need to match on SSA or similar.
The examples have a lisp-like interpreter at https://github.com/ohmjs/ohm/blob/main/examples/simple-lisp/... which definitely uses a grammar for parsing and might use a generic AST representation.
Will have to think more - a grammar might be a worthwhile way to specify a nanopass style compiler pipeline.
-
Is there a generalised, abstract programming language, designed to be specialised to a specific domain?
Look for OMeta and its successor Ohm.
-
[AskJS] Why does our community hate Operator Overloading?
One more suggestion: Maybe create your own scripting-language using Ohm? The project works in JavaScript, so whatever you created would sit on top of your existing APIs.
-
A different / new way to write compilers?
OMeta and its successor ohm might provide some interesting ideas.
-
Ohm – A library and language for building parsers, interpreters, compilers, etc.
Always fun to find the first commit:
https://github.com/harc/ohm/commit/4611bf63c5ecb90d782112d68...
2014
Neat tool. I write parsers by hand though. More fun, and you can be a lot sleazier.
What are some alternatives?
match-iz - A tiny pattern-matching library in the style of the TC39 proposal.
PEG.js - PEG.js: Parser generator for JavaScript
quickjs - Public repository of the QuickJS Javascript Engine.
peggy - Peggy: Parser generator for JavaScript
proposal-pattern-matching - Pattern matching syntax for ECMAScript
Pegged - A Parsing Expression Grammar (PEG) module, using the D programming language.
proposal-deep-path-properties-for-re
usfm-grammar - An elegant USFM parser.
Chevrotain - Parser Building Toolkit for JavaScript
meowlang - Meow Programming Language
pymetaterp - A python parser that builds python ASTs in 502 lines of python without using modules