Skip to main content
2 of 4
added 3 characters in body
alamar
  • 137
  • 4

I believe this is because PLAs have been conservative, especially around syntax and reserved words, and they had no chance to absorb these highly useful ideas from template languages, which are newcomers to this landscape and prioritize convenience over tradition.

C had three-section for loop which influenced a lot of languages and which allowed for fine tuning of looping conditions, which almost nobody used.

Java used "smart for-loop" which Steve Yegge called "dumb for-loop" because you could do even less things with it than with traditional for-loop. Unfortunately, it did not catch further, and now you have better chances of seeing functional programming / Java streams / LINQ in a PLA rather than any innovative structured programming constructs.

If you would be designing a PLA from scratch, of course you will have a way to iterate a collection, and it will have the ability to

  • Determine whether current item is first/last item being iterated.
  • Remove current item from collection being iterated.
  • Run an auxiliary code block when the collection was empty (that's what this question is about).

I'm placing some hopes on Kotlin which has rich syntax already.

alamar
  • 137
  • 4