Skip to content

[SUGGESTION][FIX] Add support for pointer as function return types #99

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

Conversation

filipsajdak
Copy link
Contributor

Current implementation does not allows to write functions that explicitly return pointers (they can be deduced with using auto).

working: (inout i : int) -> auto = {
    return i&;
}

not_working: (inout i : int) -> *int = {
    return i&;
}

During the presentation, Herb presented a function that returns a pointer (https://github.com/hsutter/cppfront/wiki/Design-note%3A-Postfix-operators#two-examples-from-cppfront-parseh) so I have implemented it.

peek: (this, num: int) -> * const token = {
    // skipping content
}

If we skip explicit this use then the rest of the function will compile in cppfront after this change. So, this code will compile:

peek: (num: int) -> * const token = {
    // skipping content
}

The support for multi-level pointers is included.

@filipsajdak
Copy link
Contributor Author

Covered by #93

@filipsajdak filipsajdak closed this Nov 2, 2022
@filipsajdak filipsajdak deleted the fsajdak-add-support-for-pointers-as-fuction-return-types branch November 15, 2022 10:29
hsutter added a commit that referenced this pull request Dec 13, 2022
Signed-off-by: Herb Sutter <[email protected]>
Azmah-Bad pushed a commit to Azmah-Bad/cppfront that referenced this pull request Feb 24, 2023
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.

1 participant