[yast-devel] Request for new Builtin
Hi, it's ITO Friday again and I would like to add a tiny builtin to YCP. integer::range(integer n) integer::range(integer s, integer n) It produces a list with the integers from 0 or s to n-1 (as known from the Python range builtin). integer::range(3) -> [ 0, 1, 2 ] integer::range(1, 5) -> [ 1, 2, 3, 4 ] It's useful to iterate over a sequence of numbers (like with a 'for' in C), e.g.: foreach(integer i, integer::range(size(addresses)), { y2milestone("Address No %1 is %2", i+1, addresses[i]); }); This is rather clumsy without range. Comments? ciao Arvin -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Hi, Arvin Schnell wrote:
Hi,
it's ITO Friday again and I would like to add a tiny builtin to YCP.
integer::range(integer n) integer::range(integer s, integer n) [...]
Do we really need a new builtin for that? For string related functions we have String.ycp. There is also Map.ycp so I think there should be Integer.ycp with such functionality. (see SVN yast2/library/types/src) IMO builtins are the core language components, without them the language would be incomplete and some functionality could not be programmed. Everything else should be in a library. Just like in C/C++... -- Best Regards Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Fri, Jun 13, 2008 at 02:58:48PM +0200, Ladislav Slezak wrote:
Hi,
Arvin Schnell wrote:
Hi,
it's ITO Friday again and I would like to add a tiny builtin to YCP.
integer::range(integer n) integer::range(integer s, integer n) [...]
Do we really need a new builtin for that? For string related functions we have String.ycp. There is also Map.ycp so I think there should be Integer.ycp with such functionality. (see SVN yast2/library/types/src)
True, but overloading is not possible in a module. ciao Arvin -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Arvin Schnell wrote:
True, but overloading is not possible in a module.
Yeah, OK, but you can use e.g. Range(integer n) and RangeFrom(integer s, integer n). -- Best Regards Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Dňa Friday 13 June 2008 15:17:59 Arvin Schnell ste napísal:
On Fri, Jun 13, 2008 at 02:58:48PM +0200, Ladislav Slezak wrote:
Hi,
Arvin Schnell wrote:
Hi,
it's ITO Friday again and I would like to add a tiny builtin to YCP.
integer::range(integer n) integer::range(integer s, integer n)
[...]
Do we really need a new builtin for that? For string related functions we have String.ycp. There is also Map.ycp so I think there should be Integer.ycp with such functionality. (see SVN yast2/library/types/src)
True, but overloading is not possible in a module.
Well, it does not work in YCP, yes. But rest of core is ready - hint, hint ;-) Stano -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Fri, Jun 13, 2008 at 02:43:55PM +0200, Arvin Schnell wrote:
integer::range(integer n) integer::range(integer s, integer n)
It sounds good. While we are stealing from "pydoc range", we could also add integer::range(integer s, integer n, integer increment). I am happy to see you implementing builtins instead of uncovering bugs in the compiler :-) -- Martin Vidner, YaST developer http://en.opensuse.org/User:Mvidner Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Fri, Jun 13, 2008 at 02:43:55PM +0200, Arvin Schnell wrote:
Hi,
it's ITO Friday again and I would like to add a tiny builtin to YCP.
integer::range(integer n)
I have now added that one as Integer::Range in Integer.ycp. ciao Arvin -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (4)
-
Arvin Schnell
-
Ladislav Slezak
-
Martin Vidner
-
Stanislav Visnovsky