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

Shorten type "Dynamic" to "Any" #944

Closed
DartBot opened this issue Dec 22, 2011 · 10 comments
Closed

Shorten type "Dynamic" to "Any" #944

DartBot opened this issue Dec 22, 2011 · 10 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Dec 22, 2011

This issue was originally filed by @seaneagan


"Any" has the obvious advantage of being shorter, and seems no less descriptive.

@DartBot
Copy link
Author

DartBot commented Dec 22, 2011

This comment was originally written by [email protected]


Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@rakudrama
Copy link
Member

I think "Any" is more descriptive. "Dynamic" implies other things are not dynamic, whereas they are simply more constrained.

@DartBot
Copy link
Author

DartBot commented Dec 23, 2011

This comment was originally written by [email protected]


I worry that Any sounds too much like Object, in that it sounds like it's the root of the type system. People might think that Any is just a synonym for Object, and think that its purpose is to hold any value, just like Object can hold any value.
But, what Any/Dynamic really means is disable static checking for a particular variable, so I think calling it Dynamic makes sense and is a useful mnemonic.
Perhaps calling it something like "Loose" or "Unchecked" would work as well if people don't like "Dynamic", but I think it needs to be something that conveys the loosey-goosey nature of the variable.

@DartBot
Copy link
Author

DartBot commented Dec 24, 2011

This comment was originally written by [email protected]


Another word that might work well is "Wild". It's short, and also clearly conveys that the difference from Object is that variables of type Wild are not subject to any static checking.

@gbracha
Copy link
Contributor

gbracha commented Jan 3, 2012

Set owner to @gbracha.
Added Accepted label.

@DartBot
Copy link
Author

DartBot commented Jan 3, 2012

This comment was originally written by @seaneagan


A couple more options to consider:

'_'
'None'
'Free'

@DartBot
Copy link
Author

DartBot commented Jan 18, 2012

This comment was originally written by [email protected]


The word "Unknown" appears multiple times in the Language specification to describe Dynamic. "The type Dynamic denotes the unknown type.". The language specification tells you what the keyword should be.

@DartBot
Copy link
Author

DartBot commented Feb 3, 2012

This comment was originally written by @seaneagan


Of course Object#dynamic should be renamed to match the new type name as well.

However, I wonder if generic type casting syntax would be better:

(Dynamic) expression

which allows casting to any type, not just Dynamic.

@anders-sandholm
Copy link
Contributor

The right solution is to use 'var' instead of 'Dynamic' as suggested in issue #2050.


Added WontFix label.

@DartBot
Copy link
Author

DartBot commented May 10, 2013

This comment was originally written by [email protected]


'dynamic' implies to me something happening at 'runtime'. Whereas in fact at runtime (production mode) type annotations are not used at all.
'any' actually does clearly imply to me - "I really don't care about static type info for this binding".

Also with 'any' i can build a mental model of how the type system works:

var x; // typed to any
var x = 2; // typed to int

But if I really want x to be bind to other non-int values at some later point in the code i would declare x as follows:

any x = 2; // typed to any
x = "hello world"; // no static error

'any' - hits the sweet spot between succinct but readable - while enabling developers to build a mental model of how the semantics hang together.

N.B - any should anyways be used rarely. Only if the developer really wants a duck type.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels May 10, 2013
@kevmoo kevmoo added closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug and removed resolution-wont_fix labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants