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

Error in Dart spec 6.1 Function Declarations #515

Closed
DartBot opened this issue Nov 18, 2011 · 7 comments
Closed

Error in Dart spec 6.1 Function Declarations #515

DartBot opened this issue Nov 18, 2011 · 7 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).
Milestone

Comments

@DartBot
Copy link

DartBot commented Nov 18, 2011

This issue was originally filed by alexei.kaigor...@gmail.com


The Draft Version 0.05, 6.1 Function Declarations reads:

A function declaration of the form
 T0 id(T1 a1 , . . . , Tn an , [Tn+1 xn+1 = d1 , . . . , Tn+k xn+k = dk ){s}
 is equivalent to a variable declaration of the form
 final F id = (T1 a1 , . . . , Tn an , [Tn+1 xn+1 = d1 , . . . , Tn+k xn+k = dk ]){s},
where F is the function type alias (13.3.1)
 typedef T0 F (T1 a1 , . . . , Tn an , [Tn+1 xn+1 , . . . , Tn+k xn+k ]).

Actually, this forms are not equivalent: first form can be placed anywhere, but second only as a local variable. Placing the second form at isolate or class level causes compile error: "initializer must be a compile time constant".

This is because a function literal is not a compile time constant (10.1 Constants). This is not in line with the fact that a "constant constructor invocation" is a compile time constant, so if a programmer really needs a function to be a compile-time constant, he/she can implement it as a method wrapped in a class constant. So the proposal is to list function literal as a compile time constant, and leave 6.1 Function Declarations intact.

@DartBot
Copy link
Author

DartBot commented Nov 18, 2011

This comment was originally written by drfibonacci@google.com


Added Area-Language, Triaged labels.

@gbracha
Copy link
Contributor

gbracha commented Dec 15, 2011

We are leaning toward making function literals compile-time constants, at least for top level ones. So that may indeed resolve the issue.


Set owner to @gbracha.
Added Accepted label.

@DartBot
Copy link
Author

DartBot commented Dec 22, 2011

This comment was originally written by ief...@unipro.ru


Please note that there is a typo in the spec:

A function declaration of the form
T0 id(T1 a1 , . . . , Tn an , [Tn+1 xn+1 = d1 , . . . , Tn+k xn+k = dk ){s}
                                                                       ^
                                                                       |
                                                                    missing ]

@gbracha
Copy link
Contributor

gbracha commented Jan 24, 2012

Resolved the typo in 0.08 draft.

@anders-sandholm
Copy link
Contributor

Added this to the M1 milestone.

@gbracha
Copy link
Contributor

gbracha commented May 30, 2012

FWIW, final top level/static variables no longer need to be constant so that issue is not a concern. We are reviewing a series of bugs and issues relating to function declarations and will resolve this bug in that context.

@gbracha
Copy link
Contributor

gbracha commented May 30, 2012

Added Done label.

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).
Projects
None yet
Development

No branches or pull requests

4 participants