Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate InternalListFunc #3943

Open
B-rando1 opened this issue Aug 23, 2024 · 1 comment
Open

Investigate InternalListFunc #3943

B-rando1 opened this issue Aug 23, 2024 · 1 comment
Labels
design Related to the current design of Drasil (not artifacts).

Comments

@B-rando1
Copy link
Collaborator

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:

  • Java's listAppend calls G.listAppend
  • G.listAppend calls Java's listAppendFunc from InternalListFunc typeclass
  • Java's listAppendFunc calls G.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 a listAppend n l v = objMethodCall void l n [v], and in Java have listAppend = 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.

@B-rando1 B-rando1 added the design Related to the current design of Drasil (not artifacts). label Aug 23, 2024
@JacquesCarette
Copy link
Owner

Indeed, the high-level APIs have suffered from too much ad hoc evolution. I think this is because "lists" are rendered in all sorts of different ways in different languages. For languages where lists are objects, I'm sure your suggestions above are good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Related to the current design of Drasil (not artifacts).
Projects
None yet
Development

No branches or pull requests

2 participants