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

Docs: book/import#import-func-code lacks examples of importing FunC functions returning tuples #1154

Open
anton-trunov opened this issue Apr 9, 2024 · 3 comments
Assignees
Labels
docs: Book /book section of the docs: Guides, Cheatsheets, and a streamlined sequence of educational materials docs.tact-lang.org Documentation for docs.tact-lang.org kept in docs folder func

Comments

@anton-trunov
Copy link
Member

As Tact does not have tuple types (at least yet), like FunC does, importing such functions is challenging for users:

For instance, how does one import a function like the following?

(int, int) derive_pub_key(priv_key: int);

An obvious attempt for the novice Tact programmer fails:

@name(derive_pub_key)
native derivePubKey(privKey: Int): (Int,Int);   // (Int, Int) is invalid Tact
@anton-trunov anton-trunov added the docs: Book /book section of the docs: Guides, Cheatsheets, and a streamlined sequence of educational materials label Apr 9, 2024
@novusnota
Copy link
Member

novusnota commented Apr 9, 2024

Tact won't need tuples IMO as it operates on structs mapped to FunC's tuples.

There's info on that in https://docs.tact-lang.org/book/func#tuple-return-type, however I agree that we should also add a smaller example right there + provide a link to "Compatibility with FunC" page, which has to be enhanced per #1145.

P.S.: In a way, this is similar to TypeScript, where one may explicitly use a class over implicitly derived types from {} objects in function returns. Like, SomeClass(arg1, arg2, arg3) over {arg1, arg2, arg3}, where the runtime type of two latter objects will differ, while the runtime type of two former class instances will be the same.

@novusnota
Copy link
Member

novusnota commented Apr 11, 2024

Described how to work with the similar issue in: #242

@novusnota novusnota added the func label Apr 11, 2024
@novusnota novusnota self-assigned this Apr 11, 2024
@anton-trunov anton-trunov transferred this issue from tact-lang/tact-docs Dec 12, 2024
@anton-trunov anton-trunov added the docs.tact-lang.org Documentation for docs.tact-lang.org kept in docs folder label Dec 12, 2024
@novusnota novusnota changed the title book/import#import-func-code lacks examples of importing FunC functions returning tuples Docs: book/import#import-func-code lacks examples of importing FunC functions returning tuples Dec 12, 2024
@novusnota
Copy link
Member

novusnota commented Dec 12, 2024

Tied to #1145 and latest notes there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs: Book /book section of the docs: Guides, Cheatsheets, and a streamlined sequence of educational materials docs.tact-lang.org Documentation for docs.tact-lang.org kept in docs folder func
Projects
None yet
Development

No branches or pull requests

2 participants