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

dev: make EVM an implicit argument of EVM-modifying functions #885

Open
enitrat opened this issue Jan 17, 2024 · 5 comments
Open

dev: make EVM an implicit argument of EVM-modifying functions #885

enitrat opened this issue Jan 17, 2024 · 5 comments

Comments

@enitrat
Copy link
Collaborator

enitrat commented Jan 17, 2024

func charge_gas{range_check_ptr}(self: model.EVM*, amount: felt) -> model.EVM* {

takes the EVM as explicit parameters and returns a new instance.
It could be refactored to

func charge_gas{range_check_ptr, evm: model.EVM*}(amount: felt) {

@joseSalazar4
Copy link

Hey there! Could I take this one? I believe the idea is to modify the attributes of the EVM received so we don't create a new instance with almost all the parms being the same on the second instance creation, correct?

@enitrat
Copy link
Collaborator Author

enitrat commented Mar 31, 2024

@ClementWalter should we go forward with this?

@ClementWalter
Copy link
Member

@joseSalazar4 it wouldn't save any steps actually, it's just to (possibly) increase readability. Tbh I'm not 100% sure that it'd be much better though, because the explicit f(evm) -> evm shows well that the evm is updated, as opposed to f().

If you want to give it a try, please, but be aware of the fact that upon PR, when actually seing it, we may decide to close instead of merge

@ClementWalter
Copy link
Member

(to be more precise, in Cairo Zero, using an implicit arg is exactly the same as defining the same arg (same name and type) as input and output

@joseSalazar4
Copy link

Your comment makes a lot of sense, this is better being explicit, agreed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔖 Ready
Development

No branches or pull requests

3 participants