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

pick does not work with isInstanceOf, when should (protocol == protocol) #138

Open
griffith1deady opened this issue Jul 4, 2024 · 1 comment
Labels
Status: Inactive (Abandoned) For now, there is no plan to work on it Type: Improve Improve features which are working

Comments

@griffith1deady
Copy link

import oolib

protocol Session:
    proc connect()
    proc disconnect() 

protocol Streamable:
    proc read(): string
    proc write(data: string)

class Player impl (Session, Streamable):
    proc connect() = echo "Player connected"
    proc disconnect() = echo "Player disconnected"
    proc read(): string = echo "Reading"
    proc write(data: string) = echo "Writing"

proc resolve(self: Session) = echo self

let player = Player.new()
let playerProtocol = player.toProtocol()
resolve(playerProtocol.pick(Session))

let session = playerProtocol.pick(Session)
echo session.isInstanceOf(Session) ## false
echo session.isInstanceOf(Streamable) ## false
echo session.isInstanceOf(Player) ## false
@glassesneo
Copy link
Owner

To be honest I haven't decided how to implement isInstanceOf on protocol itself yet, because It's obvious that an instance of a certain protocol like session has the structure of Session type(though the same can be said for the relation between player and Player) and I don't know if there's a case where an instance of protocol need type-checking.

@glassesneo glassesneo added Type: Improve Improve features which are working Status: Inactive (Abandoned) For now, there is no plan to work on it labels Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Inactive (Abandoned) For now, there is no plan to work on it Type: Improve Improve features which are working
Projects
None yet
Development

No branches or pull requests

2 participants