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

Allow composites to inherit events from interfaces #2081

Closed
Tracked by #1283
dsainati1 opened this issue Oct 20, 2022 · 4 comments
Closed
Tracked by #1283

Allow composites to inherit events from interfaces #2081

dsainati1 opened this issue Oct 20, 2022 · 4 comments
Assignees

Comments

@dsainati1
Copy link
Contributor

This is an alternative to the proposed change in #2069, that solves the same issue outline in #1283.

This would allow composites to inherit events directly from interfaces, rather than requiring them to redeclare these events identically to the interface's definition in the body of the composite. E.g. this:

pub struct interface I {
     pub event Foo(x: string)
}
pub struct S: I {}

emit S.Foo(x: "data")

would be valid, as S has inherited the definition of Foo from I. Note also that here the events are declared/inherited by a struct rather than a contract, as in order to support a proposed change in the new NFT standard (where events are defined in the Vault resource rather than the contract), we would also permit arbitrary composites to define events.

@bluesign
Copy link
Contributor

bluesign commented Oct 21, 2022

I think this is very nice:

pub struct interface I {
    pub event Foo(x: string)
    pub fun deniz(){
      post{
        emit I.Foo("data") 
     } 
   }
}

pub struct S: I {}

If this can emit an event as S, it can be good.

My only concern is this inherit. If we convert events from types to functions. ( with interface default functions etc.) , everything makes more sense.

  • event becomes kind of a function ( typealias event fun )
    pub event Foo(x: string) -> pub fun Foo(x: string): #Foo ( # being event decorator, like @ for resources )

  • emit Foo(x:"data") becomes emit #Foo(d:data)

In this way, we don't introduce any inheritance to the language as an exceptional case, it looks similar to create stuff.

@j1010001
Copy link
Member

this is an alternative to #2069

@j1010001 j1010001 mentioned this issue Apr 18, 2023
2 tasks
@turbolent
Copy link
Member

This might get proposed as part of onflow/flips#111 or separately, it was started to get proposed before in onflow/flips#82

@dsainati1
Copy link
Contributor Author

With #2589 this is now no longer necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants