-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Deprecate the var keyword #3301
Comments
@chriseth any arguments for keeping |
No, I am not a big fan of |
The task here is to extend The compiler should emit a warning for such instances, unless the experimental mode |
Hi, I'm trying to understand something here. I understand, the use of 'var' keyword was deprecated in solidity version 0.4.20 (https://github.com/ethereum/solidity/releases/tag/v0.4.20), however the documentation for tuple assignments for that version shows the use of the 'var' keyword (https://solidity.readthedocs.io/en/v0.4.20/control-structures.html#assignment). Is this use still correct? In case it's not, how should it be used? |
@briandsutton thanks for noticing, it was left by mistake. Tuple assignments will be changed as proposed in #3314. |
So... what's the resolution on how tuple assignments are done in the future? Instead of
we'd have to first introduce the types like so:
I don't see how that is an improvement. Even the following would be neat enough:
|
potentially |
So what's the fix for the 0.4.21. I have many functions like: |
@OTTTO right, I'm not protesting deprecating |
How about var automatically preserves storage of the variable? For example there is With var I can write:
Without var I should write:
The latter case is very verbose. I would prefer var in this case. What is about this usecase? |
@dukei we want to introduce type aliases for this case. For now, please bear with verbosity - I'm a big fan of the Zen of Python: https://www.python.org/dev/peps/pep-0020/#id3 |
@chriseth except this isn't Python. Python doesn't require explicit type declarations, so Python's zen wouldn't be broken by disallowing automatic type inference since there is none to begin with -___- The whole point of static type checking is that the pieces won't fit wrong, even if you don't explicitly spell out the types. Also, have you considered this form of tuple de-construction?
|
Because it's still so much cleaner. Will be reverted when var *really* is deprecated. ethereum/solidity#3301
@jtakalai yes, this is exactly what we will be implementing for the next release. |
@chriseth notified in ethereum/solidity#3301 that tuple declarations are implemented, removed var, and other warnings too.
I want the ability to change functions. I don't believe functions are a type. It is a grave mistake to depreciate var. Correct me if I'm wrong. |
There are function types. |
I do not think there is any proper legitimate use left for the
var
keyword therefore I suggest we remove it.In for loops already a type is suggested, instead of tuple declarations tuple assignments can be used and there is no need for the
var
for functions as function types can be used now.Is there any other use case for
var
?In #2558 I proposed to replace it with
auto
, but this issue would override that and just drop it.The text was updated successfully, but these errors were encountered: