Skip to content

Make interface sets ordered and thread-safe #600

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

Merged
merged 1 commit into from
Feb 17, 2021

Conversation

turbolent
Copy link
Member

Work towards #436

Description

Composite types and restricted types have sets of interfaces: Composite types' conformances, and restricted types' restrictions.

Make the sets deterministic by using ordered maps.

Also, initialize these sets in a thread-safe way, as the elaboration they might be contained in will be used concurrently in the future.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Comment on lines 21 to +23
//go:generate go run github.com/cheekybits/genny -pkg=sema -in=../common/orderedmap/orderedmap.go -out=ordered_map_string_type.go gen "KeyType=string ValueType=Type"
//go:generate go run github.com/cheekybits/genny -pkg=sema -in=../common/orderedmap/orderedmap.go -out=ordered_map_string_member.go gen "KeyType=string ValueType=*Member"
//go:generate go run github.com/cheekybits/genny -pkg=sema -in=../common/orderedmap/orderedmap.go -out=ordered_map_interfacetype_struct.go gen "KeyType=*InterfaceType ValueType=struct{}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be good to move all the generated maps to a single place like runtime/commons/orderedmap, eventually?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm currently distinguishing between "primitive" ordered maps that are useful in multiple packages (e.g. string-to-string), and sema-specific maps (generated by this file, e.g. string-to-type).

We can't move the sema-specific types to common, because common is used by multiple other packages, and that would introduce a circular dependency (common is at the bottom of the dependency chain)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. cool!

@turbolent turbolent merged commit bcd29cd into master Feb 17, 2021
@turbolent turbolent deleted the bastian/concurrent-ordered-interface-sets branch May 18, 2021 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants