stampit
stampit copied to clipboard
New syntax for stamps as Babel plugin
I believe stamps are much better approach to OOP. In fact, I call classical OOP as BOP (Blueprint Oriented Programming).
Stamps can, should, and must be inbuilt into programming languages. Imagine you could write this in JS:
let StampA = stamp {
myMethod() {},
myState: "a state",
static staticVar: "static var",
init({instance, stamp, args}) { ... }
}
let StampB = stamp {
static staticMethod() {}
}
let StampC = StampA.compose(StampB).props({ X: "y" });
var instance = StampC({X: "x"})
I haven't thought about syntax much (I haven't thought about it at all actually).
Do you get the idea? Do you feel it? Do you agree we can turn the programming world upside down?
import stampit from 'stampit';
Object.prototype.stampit = stampit;
Object.prototype.isStamp = stampit.isStamp;
let StampA = {
myMethod() {},
myState: "a state",
static staticVar: "static var",
init({instance, stamp, args}) { ... }
}.stampit();
let StampB = {
static staticMethod() {}
}.stampit();
let StampC = StampA.compose(StampB).props({ X: "y" });
Object.prototype.isStamp.call(StampC);
\o/ This feels hot.
Polluting Object
prototype? :) Maybe next time.
You wanted stampit built into the language... stamps are objects. :)
Exactly. Stamps are object. Arrays are objects. Going further, classes in Java/C# are also objects of a special kind. Why stamps can't be one of them? :)
Haha, cool idea, but this is out of scope for this repository. Maybe create a separate one for a Babel plugin? =)
BTW, while I think native support would be great, I'll probably continue to use stampit as a library until there is a real effort to standardize it in the language.
In order to gain support for language standardization, we need to get closer to 20k stars for Stampit, so spread the word. ;)
Having stampit
, react-stampit
, supermixer
and, hopfuly, babel-stampit
someday we should consider moving all that to an organization: github.com/stampit
.
:+1:
I'm cool with an org, but somebody else already has the "stampit" username but I just grabbed "stampit-org".