risc0 icon indicating copy to clipboard operation
risc0 copied to clipboard

Refactor the `entry` macro as an atrribute

Open nategraf opened this issue 1 year ago • 4 comments

Currently the entry macro in risc0_zkvm::guest has the syntax of entry!(main). It would be more stylish (😎) to have it be an attribute so it would be #[entry] fn main() {}.

This issue only a style concern, with no functional impact. If we do want to do this, we would want to do it before 1.0, but if we don't it's fine.

nategraf avatar Dec 20 '23 01:12 nategraf

(is there a way to not require entry!? since it is naturally that the function called main would be the main)

weikengchen avatar Dec 20 '23 10:12 weikengchen

Under no_std, there doesn't seem to be a way to avoid some sort of mechanism to mark what the entrypoint is.

flaub avatar Dec 20 '23 17:12 flaub

This issue only a style concern, with no functional impact

Argument could be made that it's also functionally different because you can parse the function to give more targeted span errors for what about the function makes it incompatible, for a better DevX. Also, if it's ever wanted to include some logic you can only do in proc macros, like parsing any code within the function or signature, you don't need to make breaking changes.

austinabell avatar Dec 23 '23 15:12 austinabell

I'm thinking we should long term try to move towards using std for most things, assuming std doesn't cost us much overhead.

flaub avatar Jan 02 '24 20:01 flaub