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

children(type) to allow children only #65

Closed
TheJJ opened this issue Sep 8, 2019 · 3 comments
Closed

children(type) to allow children only #65

TheJJ opened this issue Sep 8, 2019 · 3 comments
Labels
c++ involves C++ code nice new thing ☺ adds new functionality specification involves the nyan language specification

Comments

@TheJJ
Copy link
Member

TheJJ commented Sep 8, 2019

This is a new type that matches to objects that are child of the given type.
This is useful for e.g. describing this case:

DiplomaticAbility(Ability):
    stances : set(children(DiplomaticStance))

The DiplomaticStance is a non-abstract API object, and therefore is valid to be used on its own as a value for stance. As we only want to allow children, the children(DiplomaticStance) matches to that.

This implements preventing "too abstract" objects from being used.

@TheJJ TheJJ added nice new thing ☺ adds new functionality specification involves the nyan language specification labels Sep 8, 2019
@TheJJ TheJJ added the c++ involves C++ code label Oct 5, 2019
@heinezen
Copy link
Member

heinezen commented Sep 22, 2020

I would suggest the following syntax

DiplomaticAbility(Ability):
    stances : set(DiplomaticStance, onlychildren=True)

We could pass an arbitrary number of additional parameters or flags to complex types this way. It would probably work for nyan object references too:

SomeObject():
    some_member : OtherObject(onlychildren=True)

We don't even have to define children as keyword this way.

@TheJJ
Copy link
Member Author

TheJJ commented Sep 22, 2020

This was an earlier thought, but for the type checker it's easier to define children(something). We can use the keyword arguments for other things, but this I think can be done better by nesting types.

Your two examples would also need two different implementations - one for the set, one for a regular type.

children is a built-in type, not a keyword. It can be "applied" on non-containers only.

@TheJJ TheJJ changed the title childs(type) to allow children only children(type) to allow children only Sep 22, 2020
@heinezen heinezen linked a pull request Oct 5, 2020 that will close this issue
8 tasks
@TheJJ
Copy link
Member Author

TheJJ commented Aug 20, 2021

Done in #87.

@TheJJ TheJJ closed this as completed Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ involves C++ code nice new thing ☺ adds new functionality specification involves the nyan language specification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants