language idea: plurals
[note: this is a bad idea]
What if a programming language understood plurals for the purposes of foreach
loops?
Here's some normal python code:
items = ...
for item in items:
DoStuff(item)
And here's what it could look like if it understood plurals:
items = ...
foreach item:
DoStuff(item)
The idea is that item
would get pluralized to items
, so there's no need to specify the collection that's being looped through. The lnguage could figure it out from the singular!
Here's another example, with nested loops:
data = ...
boxen = ...
codices = ...
foreach datum:
foreach box:
foreach codex:
DoStuff(item,box,codex)