inkytonik / cooma

The Cooma project is investigating secure programming language design based on fine-grained object capabilities.
Mozilla Public License 2.0
3 stars 2 forks source link

refactor: make Primitives a mixin trait #38

Closed nhweston closed 3 years ago

nhweston commented 3 years ago

This PR simplifies the definitions of primitives.

The existing Primitives.scala requires every primitive class to have a type parameter 'I <: Backend' and every method of these classes to have a parameter block '(interp: I)', with fields of interp (including types) frequently accessed.

The key change proposed in this PR is to change Primitives from an object to a trait that is mixed in with a Backend. This eliminates the type parameters, the extra parameter block, and all accesses on interp.

The only complication I ran into is in CoomaPrimitiveValue.java for Truffle, which seems to arise from some Scala-to-Java weirdness with mixins and inner classes. I explored some possible type-safe fixes, but was unable to find one. I have resolved this using a type coercion.

nhweston commented 3 years ago

Will need to do a rebase if you merge in the vectors branch first.

inkytonik commented 3 years ago

This one is tricky since I've got a major reworking of Primitives on my prelude branch. I've switched from an object-oriented approach to a more functional one, mostly due to wanting to use a grammar specification to define the legal primitive forms. So, I think things are getting simpler anyway. Maybe we can wait until after the prelude is done and see if more is needed.

nhweston commented 3 years ago

Closing as this was achieved in PR #41.