Re: [Vala] Suggestion: first {} and last {} operators in iteration-loops
- From: "Daniel Borgmann" <daniel borgmann gmail com>
- To: "Nigel Tao" <nigel tao gnome gmail com>
- Cc: vala paldo org
- Subject: Re: [Vala] Suggestion: first {} and last {} operators in iteration-loops
- Date: Mon, 10 Sep 2007 06:27:57 +0200
On 9/10/07, Nigel Tao <nigel tao gnome gmail com> wrote:
/* With first{} and last{} */
static int main (string[] args) {
foreach (string arg in args) {
stdout.printf("%s is a string", arg);
first {
stdout.printf("%s is the first string", arg);
}
last {
stdout.printf("%s is the last string", arg);
}
}
return 0;
}
With this syntax, is stdout.printf("%s is a string", arg); also run on
the first and last elements? What happens if args is 1 element long,
so the first element is the last element - do all three printfs get
called?
For this and other reasons a syntax like "iffirst" resp. "iflast"
which you can use anywhere in a loop would make more sense to me. That
should make the meaning obvious and be easy to read for everyone, so I
think it's not a bad idea if it could be implemented without too much
trouble.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]