Open Braqzen opened 1 year ago
sounds helpful!
The repeat keyword should be mandatory. Even if it's more characters. If you want to use anything multiple times in a row, you must use the repeat keyword. For example:
repeat const 2 name = "Lu" repeat ! 2
repeat const 2 name = "Luke"!
print(name)! repeat / 2 "Lu"
repeat const 2 name = "Lu or Luke (either is fine)" repeat ! 9
print(name)! repeat / 2 "Lu or Luke (either is fine)"
This applies to comments and exclamation points as well, so //
becomes repeat / 2
and !!!!!!!!!
becomes repeat ! 9
.
Also notice the additional space in repeat const 2
. Without it, it would expand to constconst
, and nobody wants that although everyone wants that, it would confuse new programmers.
Obviously, this would add a step to the compilation, since the repeating !
's would have to be parsed before the main compilation.
Context
Programming takes effort and the language has a lot of syntax that is repeated for example:
const const const
next
,previous
,reverse
etc. multiple times in a rowThe language requires a new keyword, that is syntactic sugar, for unpacking or executing the same line multiple times in a row.
Specification
Abstract
Use the
repeat
keyword followed by the item that should be repeated followed by the number of times the item should be repeated (with some clever syntax this sentence could probably be factored out using therepeat
keyword, we can implement that after the MVP)Concrete example
The example above may be used to call the same function multiple times instead of using multiple lines, in a row, to call the same function.
This
becomes
Considerations
We do not allow loops but we need to consider the usage of the
reverse
keyword. We do not want to accidentally get stuck ping-ponging between multiple lines of code - effectively a loop.