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

Make UNTIL arity-2, add LOOP-UNTIL & LOOP-WHILE #108

Closed
wants to merge 1 commit into from
Closed

Make UNTIL arity-2, add LOOP-UNTIL & LOOP-WHILE #108

wants to merge 1 commit into from

Conversation

hostilefork
Copy link
Member

This transitions UNTIL to be arity-2, to be a natural pairing with the
WHILE construct. (In the same spirit of IF vs. UNLESS). The previous
version that is a condition only is then moved to LOOP-UNTIL, as a
way of saying what to do in the missing arity slot of the body. Then
LOOP-WHILE is added to be the arity-1 WHILE complement of that.

Compatibility in <r3-legacy> is accomplished with:

UNTIL: :LOOP-UNTIL

The word LOOP was chosen due to its generic sense. ("What should
I be doing UNTIL that happens...or WHILE it is happening..." => "You
should loop.") That's as opposed to having any specific relationship to
LOOP the construct's parameterization (now or under future redesign).

LOOP-WHILE has slightly more overhead than LOOP-UNTIL, because
it seeks to return the last TRUE? result (instead of being guaranteed to
return the FALSE or NONE value that caused the loop to break). Thus
LOOP-UNTIL remains the "most efficient" base looping construct.

@hostilefork
Copy link
Member Author

I'll mention that originally the rebol-proposals version of WHILE and UNTIL had a refinement /AFTER. It instructed the condition to be run after the loop body instead of before. That was somewhat unnatural looking, and LOOP-UNTIL and LOOP-WHILE offer a clear enough alternative.

So /AFTER is omitted from this.

This transitions UNTIL to be arity-2, to be a natural pairing with the
WHILE construct.  (In the same spirit of IF vs. UNLESS).  The previous
version that is a condition only is then moved to LOOP-UNTIL, as a
way of saying what to do in the missing arity slot of the body.  Then
LOOP-WHILE is added to be the arity-1 WHILE complement of that.

Compatibility in <r3-legacy> is accomplished with:

    UNTIL: :LOOP-UNTIL

The word LOOP was chosen due to its generic sense.  ("What should
I be doing UNTIL that happens...or WHILE it is happening..." => "You
should loop.")  That's as opposed to having any specific relationship to
LOOP the construct's parameterization (now or under future redesign).

LOOP-WHILE has slightly more overhead than LOOP-UNTIL, because
it seeks to return the last TRUE? result (instead of being guaranteed to
return the FALSE or NONE value that caused the loop to break).  Thus
LOOP-UNTIL remains the "most efficient" base looping construct.
@hostilefork
Copy link
Member Author

In consideration of the established people who are interested in this language, the ostensible linguistic correctness of this is eclipsed by their investment.

Your pull request is therefore closed.

@hostilefork hostilefork deleted the arity-2-until branch November 3, 2015 10:28
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

Successfully merging this pull request may close these issues.

1 participant