51

Increment operator (++)
Decrement operator (--)
Excrement operator (πŸ’©πŸ’©)

Comments
  • 8
    The excrement operator marks a value as untouchable/immutable at runtime with the guarantee of immutability checked at compile time - from the site of operator application onwards. If the compiler can't guarantee that further mutation can't happen, that results in a compile-time type error instead of leading to potential surprises at runtime.

    Basically works like sealing an object - but at compile time. Pretty useful actually.
  • 12
    Javascript operator (🀑🀑)
  • 5
    Smooth operator (@Oktokolo)
  • 3
    @Oktokolo i would love this. Does it exist on any language?
  • 5
    Maximum heap size reached πŸ’©πŸ’©πŸ’©πŸ’©πŸ’©
  • 1
    @horus I doubt it - statical analysis would need to ensure no mutation happening by any code executed after application of the operator. You have to write rather pure code to allow a static analyzer to see the guarantee satisfied.

    The obvious solution is to just go for immutable types by default and make mutation the exception instead of the mainstream way of everything being mutable by default (thankfully, even in such languages, strings and numbers normally still aren't mutable)...
  • 0
    ah, the main operator for unit tests ☺️
  • 4
    @Demolishun
    You'd want type safety so i'd suggest using 🀑🀑🀑 instead
  • 0
    @oktoloko you are right. I read your comment when i was half awake and the poopoo operator you described seemed way more useful before than after coffee.
  • 3
    @Probabil perfect!

    In fact, considering the clown nature of the + operator in JS, it could simply be replaced by 🀑.
    It would make the intent more clear and would be compatible with your proposal.
  • 2
    Do we evolve a natural language only using emojis / pictograms?

    I mean, we often communicate with them, for example:

    - copy, paste, cut and select everything in Android.

    - Doors on Trains, buses and trams.

    - Signs in train stations and on streets.

    Somehow we go back in time to the ancient Egypt.
  • 0
    @horus It would still be a useful operator to have. You could give away your original mutable state while enforcing that the receiving code not only can't mutate your state - but it also couldn't accidentally try a mutation which could lead to hard-to-find bugs where the dev assumes a change to happen but it doesn't actually happen (like when a getter just clones the thing before returning).

    This operator could be used to optimize away a lot of safety cloning.
  • 0
    So despite my initial negative response, the operator would be useful and there are some nice use cases that are easy to verify by static analysis by treating the value as differently typed after the operator.

    Also, TypeScript actually covers some use cases by casting to Immutable<T>.
  • 0
    .inc()
    .dec()
Add Comment