cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

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

Open filipsajdak opened this issue 3 years ago • 0 comments
trafficstars

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 avatar Oct 28 '22 07:10 filipsajdak