Skip to content

return variable of a function #1621

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

Closed
DartBot opened this issue Feb 11, 2012 · 8 comments
Closed

return variable of a function #1621

DartBot opened this issue Feb 11, 2012 · 8 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 Feb 11, 2012

This issue was originally filed by [email protected]


The return variable of the function should be able to be referenced in the function body, like in Visual Basic. It will start off with a value of null, and be possibly changed by the function to return a value, e.g. something like "returnset <expression>;", that is like the return statement, but does not pass back control to calling process. Even better, give the variable a fixed identifier like "_returnvalue" so that expressions or array functions can change the value, e.g. "_returnvalue++;".

@DartBot
Copy link
Author

DartBot commented Feb 11, 2012

This comment was originally written by [email protected]


Sorry, I don't know how to change the type of issue to "Enhancement".

@DartBot
Copy link
Author

DartBot commented Feb 11, 2012

This comment was originally written by [email protected]


I thought of this because many of my JavaScript functions end up declaring a variable that I will in the end return, which is kind of redundant. The return variable name should be short in length, although my example has quite a long one. It also should be fixed, instead of changing with the function name as in BASIC, since the function name should be separate from the function body, so that renaming (on the programmer's side) is easy.

@anders-sandholm
Copy link
Contributor

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

@anders-sandholm
Copy link
Contributor

Added Triaged label.

@gbracha
Copy link
Contributor

gbracha commented Feb 14, 2012

Set owner to @gbracha.
Added Accepted label.

@whesse
Copy link
Contributor

whesse commented Feb 14, 2012

I think it is very common for people to use "result" for this, and for them to type:

var result;
at the beginning of the function, and

return result;
at the end of the function.

This seems short and simple enough that it might not
be worth changing the language to make it one or two words shorter.

@DartBot
Copy link
Author

DartBot commented Feb 14, 2012

This comment was originally written by [email protected]


But internally, will it be two variables or somehow optimized into one?

@gbracha
Copy link
Contributor

gbracha commented Apr 13, 2012

Added WontFix label.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Apr 13, 2012
@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
copybara-service bot pushed a commit that referenced this issue Dec 18, 2024
This is a minor change with just bug fixes:

* Handle trailing commas in for-loop updaters (#1354).
* Format `||` patterns like fallthrough cases in switch expressions (#1602).
* Handle comments and metadata before variables more gracefully (#1604).
* Ensure comment formatting is idempotent (#1606).
* Better indentation of leading comments on property accesses in binary operator
  operands (#1611).
* Don't crash on doc comments in local variable declarations (#1621).

This won't affect much code, but it does change the formatting in some cases.

Change-Id: I2d52fee92aecbc24315e4f1a89360af85ec85942
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401482
Auto-Submit: Bob Nystrom <[email protected]>
Commit-Queue: Alexander Thomas <[email protected]>
Reviewed-by: Alexander Thomas <[email protected]>
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