gerbil icon indicating copy to clipboard operation
gerbil copied to clipboard

Interface Method namespaces

Open drewc opened this issue 6 months ago • 2 comments

The issue is simple: dynamic methods have no namespace and interfaces cast to them. Also, different interfaces (aka typeclasses) could have different methods with the same name. And curly's should {be-not-prefixed 'by-default 'for 'KISS}

In short; module/name#interface-name::method-name for the default allows both easy dispatch AND static signature checking while keeping name and module separation to make unintended duplication difficult.

The solution is a namespace: keyword that acts similar to the externone only defaults to the interface name. If it's #f, no namespace. It could also be prefix:.

So, (interface foo (bar baz)) will, at prototype, look for and bind the foo::bar method. It could then, if foo::bar does not exist, look for the :bar method, and then the bar method. That solves almost all the problems, right?

Then (interface (bat foo) (xyz n)) could first look for the bat::bar method before the foo::bar et al methods. That allows for some interesting specialization while allowing a hierarchy. outside of class/types.

But (interface (fu namespace: foo) (bar me)) could lookup foo::bar as well?

Should the prefix actually be module/name#foo::bar by default? I think that may be better as I can have interfaces with the same name and same functions but in a different space.

So (rename: food foo) on an export and then in another module (interface (foo food) (bar baz)) could have an another/module#foo::bar first dispatch attempt?

Thoughts?

drewc avatar Aug 23 '24 19:08 drewc