ENDCASE

Interpretation:

Interpretation semantics for this word are undefined.

Compilation:

( C: case-sys -- )

Mark the end of the CASE...OF...ENDOF...ENDCASE structure. Use case-sys to resolve the entire structure. Append the run-time semantics given below to the current definition.

Run-time:

( x -- )

Discard the case selector x and continue execution.

See:

Rationale:

Typical use:
: X ...
   CASE
   test1 OF ... ENDOF
   testn OF ... ENDOF
   ... ( default )
   ENDCASE ...
;

Testing:

ContributeContributions

enochavatar of enoch Proposal: end-caseComment2016-01-13 20:48:24

There are numerous old forum arguments against the endcase consuming the top stack value, typically the case selector. Isn't it time to add an end-case variant to the standard which would leave the top stack value intact. Based on my personal experience with Amforth-Shadow both forms are useful.

AntonErtlavatar of AntonErtl 2016-01-14 15:29:49

I think the proposed name is too close to ENDCASE, so that's probably bug-prone. I guess we have to live with 0 ENDCASE for that function.

enochavatar of enoch 2016-01-15 20:43:41

You meant, no doubt, dup endcase. No point to rehash the old arguments for and against endcase current behavior. What is needed IMHO is for the committee to invite user code statistics. In my applications endcase and end-case find equal use.

AntonErtlavatar of AntonErtl 2016-02-05 18:31:42

I actually meant 0 ENDCASE. The stack might be empty before, so DUP could cause a stack underflow.

Thanks for the statistics.

Reply