Re: [Vala] Suggestion: first {} and last {} operators in iteration-loops



On 9/7/07, Alberto Ruiz <aruiz gnome org> wrote:


2007/9/7, Jürg Billeter <j bitron ch>:
On Fri, 2007-09-07 at 11:51 +0200, Raphael Bosshard wrote:

Thanks for your suggestion. Special treatment for the first and/or the
last element is certainly used quite often, however I'm not sure that
first{} and last{} would fit in well enough into the syntax. I also
don't know of other programming languages providing something similar,
so it might actually be more confusing than helping like that. Maybe
there is another way to assist when you need to treat the first and/or
the last element in an iteration specially.


I think it would be better to provide negative index support for arrays
(array[-1]) and use a for loop that excludes the first and last item just in
case you need special treatment for first and last rather than extending the
language in such a strange way.


--
Un saludo,
Alberto Ruiz
_______________________________________________
Vala mailing list
Vala paldo org
http://www.paldo.org/mailman/listinfo/vala


Another solution may be to give access to the internal iterator with
eg. '_iter'. That way you at least don't need to create your own
counter. The problem is of course when iterating over a linked list or
similar where you normally don't have a counter.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]