>So I thought I would fix that Gmp.mpz(3)%2 has the type mixed. My
>first quick and dirty fix was to update the type of `% a bit by adding
>
>  tFunc(tObjIs_GMP_MPZ tInt, tObjIs_GMP_MPZ)
>
>Yes, it ignores the int%mpz and mpz%mpz permutations, but it's a
>start. Not the right one apparently, as I got the following
>warning when trying it out on Crypto.Random.
>
>The code
>
>Gmp.mpz random(int top) {
>  return Gmp.mpz(rnd_func( (int)ceil(Math.log2(top)) ), 256) % top;
>}
>
>generates
>
>Warning: Wong return type.
>Warning: Expected: { mpz = object(implements _static_modules.Gmp()->mpz) }.
>Warning: Got     : object(is _static_modules.Gmp()->mpz) | mixed.
>
>Why is there a "| mixed" in this type?

You probably need to add a tIfNot (or modifying the existing) for the
generic case so that it doesn't match.

>Is this at all the correct approach?

Looks like it.

A nicer approach would of course be to add support for LFUN-expansions
to the type system.

>Can we get nicer names than _static_modules.Gmp()->mpz?

That's just a question of modifying the master.
  • The type of... Martin Nilsson (Opera Mini - AFK!) @ Pike (-) developers forum
    • The ty... Henrik Grubbstr�m (Lysator) @ Pike (-) developers forum
      • Th... Martin Nilsson (Opera Mini - AFK!) @ Pike (-) developers forum
        • ... Henrik Grubbström (Lysator) @ Pike (-) developers forum
          • ... Martin Nilsson (Opera Mini - AFK!) @ Pike (-) developers forum

Reply via email to