civboot / fngi

a readable language that grows from the silicon
The Unlicense
59 stars 3 forks source link

Role #26

Closed vitiral closed 1 year ago

vitiral commented 1 year ago

I'm adding role to the compiler

role Resource [
  \ You can always drop a resource
  absmeth drop(&Self);

  meth printDrop(this:&Resource) {
    print("Dropping myself")
    this.drop()
  }
]
vitiral commented 1 year ago

I'm very close. There were a LOT of changes necessary to get this rolling.

The main thing left now is proper handling of Self, which might be... challenging.

I may need a selfStk... or something similar. Basically the type checker needs to know what to convert Self into!

It would be nice if this could be a generalized solution so that I can use it for generics in the future as well. Basically it would be nice if syn functions could interface with some kind of "stack" of mappings from GenericType -> ConcreteType. I would directly use this when accessing methods/etc.

I'm not quite sure I understand the problem space here, but feels like it should be straightforward! I can at least create a specialized case for role in the meantime if I can't think of anything.

vitiral commented 1 year ago

It should be noted that if I can create a specialized case then that means that others can create their own specialized cases. Basically that can create "native" types that are fake and can't actually be concrete.

vitiral commented 1 year ago

This is now implemented