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

LANG-28: flesh out a concept for reflected type parameters #3467

Closed
wants to merge 9 commits into from

Conversation

ggreif
Copy link
Contributor

@ggreif ggreif commented Sep 30, 2022

Researching a type reflection mechanism. JIRA: https://dfinity.atlassian.net/browse/LANG-28.

I expect that deconstruction will be rather easy, but construction will be very tricky (needs CPS?).

@github-actions
Copy link

github-actions bot commented Sep 30, 2022

Comparing from 6ab555d to 14051b1:
The produced WebAssembly code seems to be completely unchanged.

@ggreif
Copy link
Contributor Author

ggreif commented Sep 30, 2022

As of 14051b1 the following abilities are present

  • analysis side (deconstruct A)
    • primitive types
    • pairs (tuples?)
    • up-structuring (integrate A into something bigger)
    • records
    • variants
  • synthesis side (build an A knowing the type's structure)
    • ...

Currently all the administrative glue is manually written, but I expect that the compiler can fill this in by straightforward metaprogramming based on the call-site's known type structure resp. the passed-in Desc<B>.

@ggreif
Copy link
Contributor Author

ggreif commented Sep 12, 2023

see also #2348 and #2096

@ggreif
Copy link
Contributor Author

ggreif commented Sep 12, 2023

In today's ICP.Lab Motoko office hours the following simplified context came up:

func ws_send<to_candid A>(data : A)

would allow using to_candid(data) to obtain a Blob, where the caller would pass in a conversion (serialisation) function implicitly. Similarly

func ws_receive<from_candid A>(blob : Blob) : A { let ?(a : A) = from_candid(blob) else trap(); a }

would work for deserialising. Stacking would make sense too <switch from_candid to_candid A> etc. (not pretty though...)

@luc-blaeser
Copy link
Contributor

Just doing some repo cleanup for better focussing on active work:
Closing PR as it seems inactive for a longer time. Please re-open if it is still relevant and after it has been updated with latest master changes.

@luc-blaeser luc-blaeser closed this Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants