Doesn't the compiler already know that the value of res is returned from the function? Therefore infers that res must be of type % ? Even in
zero? n => 1 you have the question of what is type of 1. On Mon, Oct 24, 2011 at 6:22 PM, Gabriel Dos Reis wrote: > > The algebra is full of examples where things work by a sheer amount of > luck. Consider the function rightPower in functor MonadWithUnit: > > rightPower(a: %,n: NonNegativeInteger) == > zero? n => 1 > res := 1 > for i in 1..n repeat res := res * a > res > > What should be the type of constant 1 selected at the assignment > > res := 1 > > and why? > > There are three candidates in in scope: > > 1: % > 1: NonNegativeInteger > 1: Integer > > Currently, all this works mostly by luck. > > The fix is to write > > res: % := 1 > > or > > res := 1@% > > or > > res := 1$% > > > -- Gaby > > > ------------------------------------------------------------------------------ > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@Cisco Self-Assessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/cisco-dev2dev > _______________________________________________ > open-axiom-devel mailing list > open-axiom-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/open-axiom-devel > ------------------------------------------------------------------------------ The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Cisco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev _______________________________________________ open-axiom-devel mailing list open-axiom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open-axiom-devel