Skip to content

return statements #3

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

Open
ProfessorTom opened this issue Oct 17, 2018 · 4 comments
Open

return statements #3

ProfessorTom opened this issue Oct 17, 2018 · 4 comments

Comments

@ProfessorTom
Copy link

After watching the Skills Matter video a non-trivial number of times, I realized that returning values from functions was not addressed.

return is too easy.

I propose that a system similar to INTERCAL's politeness be used for returning values from functions vs. Scala's implied returns (although, implied returns means the return semantics are invisible–a highly desirable feature for BS.). To wit: the key phrase please give back in lieu of return but this must be balanced with the key phrasetake that or do the needful in lieu of return if the compiler detects too much politeness which will be determined by a PRNG-generated percent of correct politeness each time the compiler is invoked, thus causing additional source edits per compile.

@MonstraG
Copy link

MonstraG commented Nov 1, 2021

Far easier solution, I think, is to return all undeleted variables in reverse (compared to declaration) order.

@carlsonj
Copy link

carlsonj commented Nov 2, 2021

Better still, have only a "please take <variable> from <function>" used in the caller's context, with no indication in the called function about what is to be returned. That way, the called function becomes an open book. Any caller can specify which variable it would like to have. Just imagine the code-reuse possibilities.

@barkermn01
Copy link

Better still, have only a "please take <variable> from <function>" used in the caller's context, with no indication in the called function about what is to be returned. That way, the called function becomes an open book. Any caller can specify which variable it would like to have. Just imagine the code-reuse possibilities.

but it messes with the Delete keyword you can't take a delete variable but you must delete all variables or you have one hell of a memory leak.

@Argavyon
Copy link

Argavyon commented Oct 5, 2023

Better still, have only a "please take <variable> from <function>" used in the caller's context, with no indication in the called function about what is to be returned. That way, the called function becomes an open book. Any caller can specify which variable it would like to have. Just imagine the code-reuse possibilities.

but it messes with the Delete keyword you can't take a delete variable but you must delete all variables or you have one hell of a memory leak.

Using please take <variable> from <function> and clean up should easily handle deletion of the function's variables when expecting a returned value; all is fine but please clean up should handle deletion of the function's when no returned value is desired.

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

No branches or pull requests

5 participants