Shop OBEX P1 Docs P2 Docs Learn Events
FlexProp: a complete programming system for P2 (and P1) - Page 59 — Parallax Forums

FlexProp: a complete programming system for P2 (and P1)

1535455565759»

Comments

  • ersmithersmith Posts: 6,161

    The idea of interfaces is kind of like structs but for functions (only). So for example you could have something like:

    con
      %interface winio(
        pub puts(p_str)
        pub newline()
    )
    
    pub myfunc(^winio w)
        w.puts(@"hello, world")
        w.newline()
    

    Then any object which implements the puts and newline methods can be passed to the myfunc method.

    I have a tentative implementation for Spin2 checked in to github now, but it's probably buggy. We could also change the way it works a bit, if there are shortcomings we find now.

  • Ah man that is fantastic :) That worked straight away...That's a nice simple syntax and I think it really fills a good space between function pointers and object pointers.
    Thanks a million!

Sign In or Register to comment.