jamiebuilds / ghost-lang

:ghost: A friendly little language for you and me.
302 stars 10 forks source link

for..as 🚲 #28

Closed aleclarson closed 5 years ago

aleclarson commented 5 years ago

What's the motivation behind using for..as and not something more familiar like for..in or for..of?

jamiebuilds commented 5 years ago

There's a lot of languages that use iterable first, item second syntax (very common in templating languages especially). And you'll see it in almost every language with functions-as-values in the form:

iterable.iterMethod(item => ...)

I think that this is an objectively better order. The most important detail that you should type/read first is the value you are iterating over. And the name of your "item" binding should generally be based on the thing you are iterating over.