instead of tracking the index, how about:
```dart
bool first = true;
for (var medium in node.media) {
  emit(first ? ' ' : ',');
  first = false;
  medium.visit(this);
}
```