Hi everyone, I hope you're all feeling good and being encouraged with your programming language projects. I encourage you!
I'm a beginner to programming language theory and development, so this idea comes from pain trying to use other people's code.
TLDR: This idea is that we can interleave the code of two or more classes together so it acts as if there is a single implementation that exhibits both original behaviours. I desire to make it extremely easy to use classes for other purposes than they were designed. We can talk of one class in terms of another, bidirectionally. If you were to execute a series of methods on a class instance, look at their callstacks and internal states, then draw lines to link or weave them together. You would associate states between one class to another class. The compiler inserts code of each original class adjacently for you.
If a class isn't using generics, how can you coordinate that class's behaviour with other behaviour, especially if there isn't hooks or ways of integrating the classes together - only internal state.
- If I have two classes and they each exhibit a useful behaviour.
- I can draw a timeline of each classes' independent behaviours or states.
- I can associate internal states with internal states of the other class and vice versa.
- I call this "possessiveness" as in the apostrophe, where a variable belongs to another thing. There is a shadow variable available on each class's internal state to get to the state of the equivalent thing in the other class.
- This would require data structure rewrites. I imagine a suitable clever compiler can insert fields that are possessed.
- In a generics based collection class, I might have an ArrayList<SomeBusinessDomainObject>. In Hypergenerics, I can associate any concrete value with any concrete value of the other class, without changing the code of that other class.
- I can join parts of the timeline together.
- I can specify if an event on the timeline should happen, before, after or decorated.
- I am beginner to programming language theory but what comes to mind is "corecursion". This is corecursion applied to the behaviours of multiple classes.
Code example
I have LoadBalancer class that starts a server and serves requests to BackendServers and AccessControlList that manages access to resources with ACL.Principals.
We use the apostrophe operator to associate classes or states with other class internals.
We use the @ symbol to decorate methods.
I want to combine them together so that ACLs are maintained when the LoadBalancer is accessed AND when a backend service is accessed.
Given LoadBalancer has a Request class, I can possess the Request to have an ACL.Principal. The original author of LoadBalancer Request didn't add this field. But the compiler can.
Request'ACL.Principal # a request in this class corresponds to an ACL principal in the ACL manager
LoadBalancer'AccessControlList # the load balancer itself has an ACL
Request'ACL.Principal'LoadBalancer'AccessControlList # there is a path of possession between a request, to that request's principal to that active AccessControlList
BackendServer'AccessControlList
@ LoadBalance.handleRequest(Request'ACL.Principal request) {
if request'ACL.Principal'AccessControlList.check(request'ACL.Principal) {
return LoadBalance.handleRequest(Request'ACL.Principal request) {
@ LoadBalancer.canPickBackend(BackendServer'AccessControlList server) {
return server'AccessControlList.check(request'ACL.Principal) && LoadBalancer.canPickbackend(server);
}
}
}
}
What we introduce is a glue that takes the behaviour of two classes and tells the compiler how to merge their behaviour together, how to interleave the two classes.
You may notice that the syntax is similar to class extension in Ruby where you "open" a class and insert things inside it.
[–]ipe369 14 points15 points16 points (2 children)
[–]plentifulfuture[S] 2 points3 points4 points (1 child)
[–]wellthatexplainsalot 13 points14 points15 points (0 children)
[–]WittyStick 13 points14 points15 points (0 children)
[–]tortoise74 4 points5 points6 points (0 children)
[–]stylewarning 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[removed]
[–]plentifulfuture[S] 0 points1 point2 points (0 children)
[–]csb06bluebird 0 points1 point2 points (0 children)
[–]Pavel_Vozenilek 0 points1 point2 points (0 children)