guile-devel
[Top][All Lists]
Advanced

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

New NUM2INTEGRAL functions - unwanted polymorphism?


From: Mikael Djurfeldt
Subject: New NUM2INTEGRAL functions - unwanted polymorphism?
Date: 19 Sep 2001 22:04:41 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Hi,

I was just looking at the nice contribution of the NUM2INTEGRAL
functions.

I'm concerned with the last clause of NUM2INTEGRAL:

  else if (SCM_REALP (num))
    { /* inexact */
    
      double u = SCM_REAL_VALUE (num);
      ITYPE res = u;
      if ((double) res == u)
        return res;
      else
        scm_out_of_range (s_caller, num);
    }

Do we really want this?

Looking at the set of Scheme procedures in R5RS, none of these accept
an inexact value in place of an exact.  That behavior has caught many
bugs for me.  To me, the above behavior is being generic in an evil
way.

I'd like to remove that clause.  Comments?

BTW, personally I would like to have argument type checking and
conversion completely centralized, just tagging primitives with the
types and coercions they need.  That way, the entire massage of the
argument list, checking/dispatching on number of arguments etc could
be done in one place; GOOPS could eliminate a lot of redundant
argument checks; and compilers could call primitives directly with
native types.

However, maybe that is still a bit futuristic...

Best,
Mikael



reply via email to

[Prev in Thread] Current Thread [Next in Thread]