I agree.  It works like a control structure, and probably even better
described as exception handling.  In J (for explicitly defined functions)
it is  implemented as a control structure.  I had suspected that it might
be implemented differently in tacit J, though I did not expect the
implementation to be a combination of a conjuction and a gerund.

In K the colon symbol ":" is overloaded to mean 5 different things depending
upon the context:
1)  Amend
2)  Conditional
3)  Monadic case (with each)
4)  Resume
5)  Return

So, in K, the control structure is implemented as a special case of a verb.

Similarly, in A+, the "left arrow" is overloaded.  In the dyadic case, it means
"Assignment".  In the monadic case, it means "Result".  (So, it is also
implemented as a verb.)

Kona currrently recognizes adverbs at the beginnings of "snippets", but
"early return" is not yet implemented.
There was initially a question as to whether kona needed to check for
execution inside a function.  It looks like no -- it should have
"result" functionality that works everywhere.
It may require some kind of "strong break" to return early
during execution: goto, jump, flags, or otherwise.

Your idea of "wrapping" the subsequent code as in exception handling
is intriguing.

Thanks again,
Tom

On Thu, Oct 18, 2012 at 2:15 PM, Raul Miller <[email protected]> wrote:
> On Thu, Oct 18, 2012 at 11:51 AM, Tom Szczesny <[email protected]> wrote:
>> Thank you for all your comments.  They are very useful.
>>
>> Just for context for my initial question:
>> I am attempting to resolve:
>>   https://github.com/kevinlawler/kona/issues/4
>> and was hoping to see how J did it.
>>
>> However the approach in J is quite different than for A+ or K
>> in that "return." is a control structure in J.
>
> Early return is very like exception handling.
>
> An exception can be thought of as a way of tracking intermediate
> results -- in essence, you've got an if statement which, after you've
> got the intermediate value has a test based on whether you are bailing
> out early -- it wraps the subsequent code.  In the "return now case"
> you are done.  In the "normal case" you run the subsequent code to
> find the value to be returned by that routine.
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to