stampit icon indicating copy to clipboard operation
stampit copied to clipboard

New syntax for stamps as Babel plugin

Open koresar opened this issue 9 years ago • 8 comments

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?

koresar avatar May 27 '15 13:05 koresar

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.

troutowicz avatar May 27 '15 13:05 troutowicz

Polluting Object prototype? :) Maybe next time.

koresar avatar May 27 '15 13:05 koresar

You wanted stampit built into the language... stamps are objects. :)

troutowicz avatar May 27 '15 13:05 troutowicz

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? :)

koresar avatar May 27 '15 14:05 koresar

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. ;)

ericelliott avatar May 27 '15 18:05 ericelliott

Having stampit, react-stampit, supermixer and, hopfuly, babel-stampit someday we should consider moving all that to an organization: github.com/stampit.

koresar avatar May 28 '15 00:05 koresar

:+1:

troutowicz avatar May 28 '15 00:05 troutowicz

I'm cool with an org, but somebody else already has the "stampit" username but I just grabbed "stampit-org".

ericelliott avatar May 28 '15 01:05 ericelliott