Mutating Programming Language?
- by MattiasK
For fun I was thinking about how one could build a programming language that differs from OOP and came up with this concept. I don't have a strong foundation in computer science so it might be common place without me knowing it (more likely it's just a stupid idea :)
I apologize in advance for this somewhat rambling question :) Anyways here goes:
In normal OOP methods and classes are variant only upon parameters, meaning if two different classes/methods call the same method they get the same output.
My, perhaps crazy idea, is that the calling method and class could be an "invisible" part of it's signature and the response could vary depending on who call's an method.
Say that we have a Window object with a Break() method, now anyone (who has access) could call this method on Window with the same result.
Now say that we have two different objects, Hammer and SledgeHammer. If Break need to produce different results based on these we'd pass them as parameters Break(IBluntObject bluntObject)
With a mutating programming language (mpl) the operating objects on the method would be visible to the Break Method without begin explicitly defined and it could adopt itself based on them). So if SledgeHammer calls Window.Break() it would generate vastly different results than if Hammer did so.
If OOP classes are black boxes then MPL are black boxes that knows who's (trying) to push it's buttons and can adapt accordingly.
You could also have different permission sets on methods depending who's calling them rather than having absolute permissions like public and private.
Does this have any advantage over OOP? Or perhaps I should say, would it add anything to it since you should be able to simply add this aspect to methods (just give access to a CallingMethod and CallingClass variable in context)
I'm not sure, might be to hard to wrap one's head around, it would be kinda interesting to have classes that adopted themselves to who uses them though.
Still it's an interesting concept, what do you think, is it viable?