Investigate InternalListFunc
#3943
Labels
design
Related to the current design of Drasil (not artifacts).
InternalListFunc
#3943
I was looking again at the
List
typeclass of GOOL/GProc, and just wondering if we could simplify how it's implemented.Take, for example, Java's implementation of
listAppend
:listAppend
callsG.listAppend
G.listAppend
calls Java'slistAppendFunc
fromInternalListFunc
typeclasslistAppendFunc
callsG.listAppendFunc
All that for a simple method call! E.g. an alternate definition could be
listAppend l v = objMethodCall void l "add" [v]
This happens for a lot of the implementations of a lot of the List API. It feels like it goes in circles, making it pretty hard to understand how a very simple piece of code is actually created. I'm not saying we shouldn't abstract from the exact implementation (e.g. we shouldn't have to use
objMethodCall
in every renderer), but I feel like we might have gone too far.I wonder if we would be better off getting rid of
InternalListFunc
(or at least most of its methods), and instead do something like:In
CommonPseudoOO.hs
, add alistAppend n l v = objMethodCall void l n [v]
, and in Java havelistAppend = CP.listAppend "add"
That still gives the level of abstraction and flexibility that we want, without having the function calls bounce back and forth as much as they currently do.
Is this a change that would be helpful? It might also apply to sets, as the set implementation was heavily based on the list implementation.
The text was updated successfully, but these errors were encountered: