You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is my understanding that foo(...) in every location denotes an invocation the final, merged result of introducing the declaration named foo in main.dart and augmenting it in some number of steps (in this case just once). In general, a named reference to an instance member is always the post-merge member (the "end result"), never a single augmentation, not even when it occurs in the original (non-augmenting) declaration (here: the declaration in main.dart).
In particular, the invocation of foo(i) in the original declaration is not an infinite loop.
I couldn't find an explicit answer to this question in the feature specification. It is possible that it is considered obvious, but it is still useful to get it clarified, and we might also add a couple of sentences to the feature specification about it.
The text was updated successfully, but these errors were encountered:
foo(...) in every location denotes an invocation the final, merged result
Agree.
There is only one way to refer to a specific base or augmentation declaration, the augmented invocation in an immediately augmenting declaration body.
Any reference by name will refer to that name in the declaration scope, or any other relevant scope, and that scope only contains one entry. An entry that is declared by a base declaration and zero or more augmenting declarations in a specific order.
The example foo function will return 0 if called with 0,
If called with a positive value, it'll recurse with i - 1 until reaching zero.
If called with a negative number, it'll recurse with i - 1 until overflowing into a positive number (if on native) then continue as above and eventually return zero (long after a stack overflow).
It's just like the functions
intfoo(int i) => i >0?foo(i -1) :_$augmented$foo(i);
int_$augmented$foo(int i) {
if (i <0) returnfoo(i -1);
return i;
}
where nothing else can refer to the fresh name _$augmented$foo.
Thanks to @sgrekhov for bringing up this issue. Consider the following situation:
It is my understanding that
foo(...)
in every location denotes an invocation the final, merged result of introducing the declaration namedfoo
inmain.dart
and augmenting it in some number of steps (in this case just once). In general, a named reference to an instance member is always the post-merge member (the "end result"), never a single augmentation, not even when it occurs in the original (non-augmenting) declaration (here: the declaration inmain.dart
).In particular, the invocation of
foo(i)
in the original declaration is not an infinite loop.I couldn't find an explicit answer to this question in the feature specification. It is possible that it is considered obvious, but it is still useful to get it clarified, and we might also add a couple of sentences to the feature specification about it.
The text was updated successfully, but these errors were encountered: