Open ghost opened 4 years ago
The exponentiation operator, **
, would be an infix, right-associative operator (operator **(arg)
) with a precedence just stronger than the multiplicative operators. It would be user-implementable, and implemented by num
.
It would be hard to type in a useful way, because unlike other arithmetic operators, we can't special case int ** int
to have static type int
. That's only true if the exponent is non-negative.
The slice operator would be a new ternary suffix operator, operator [:]([arg1, arg2)
. It would probably also have a slice-set operator operator [:]=(arg1, arg2, value)
. The calling convention would be that arg1
and arg2
must be nullable, because they can be omitted, or only make them omitable if they are nullable. (Making them optional works badly, unless we make the named, and that's very different than other operators).
Then x[:]
would pass null
for both parameters, x[1:]
would pass null
for the second parameter and x[:4]
would pass null
for the first parameter.
The input
function is fairly simple:
import "dart;io";
String input([String query]) {
if (query != null) stdout.write(query);
return stdin.readLineSync();
}
I'm not sure that function belongs in the platform libraries. Console input is not something that you will use in any real program (it's a really horrible UI), so it'd just be there for people learning Dart. I'd probably prefer to make dartpad.dev easier to use instead.
Well thanks for taking the time to reply but I didn't get the part about the slice operator.
Dart is pretty simple, but there are a few additions that ould be nade to dart core.