Menu

#3643 DEFMFUN creates $NAME and $NAME-IMPL, contradicting documentation

None
closed
nobody
lisp (1)
5
2020-09-20
2020-07-20
No

The documentation of DEFMFUN claims the following:
;; If the function name NAME starts with #\$ we check the number of
;; arguments. In this case, two functions are created: NAME and
;; NAME-IMPL (without the leading $).

However, actually the leading $ is not removed. This causes
$APROPOS to leak these details to the user. Observed in Maxima 5.44.0

See https://trac.sagemath.org/ticket/30063#comment:17

$ ./sage -maxima
;;; Loading #P"/Users/mkoeppe/s/sage/sage-rebasing/local/lib/ecl/sb-bsd-sockets.fas"
;;; Loading #P"/Users/mkoeppe/s/sage/sage-rebasing/local/lib/ecl/sockets.fas"
Maxima 5.44.0 http://maxima.sourceforge.net
using Lisp ECL 20.4.24
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) apropos("gcd");
(%o1) [ef_gcd, ef_gcd-impl, ef_gcdex, ef_gcdex-impl, ezgcd, ezgcd-impl, gcd, 
            gcd-impl, gcdex, gf_gcd, gf_gcd-impl, gf_gcdex, gf_gcdex-impl, gcd]

Related

Bugs: #3970

Discussion

  • Robert Dodier

    Robert Dodier - 2020-09-13

    Here's a patch to implement the suggested change. I'll check with the author of DEFMFUN (Raymond Toy) about it. Note that one has to say make clean before make in order to remove any existing references to $FOO-IMPL functions.

    diff --git a/src/defmfun-check.lisp b/src/defmfun-check.lisp
    index f4ceb0606..9d0500200 100644
    --- a/src/defmfun-check.lisp
    +++ b/src/defmfun-check.lisp
    @@ -321,7 +321,7 @@
               (let* ((required-len (length required-args))
                      (optional-len (length optional-args))
                      (impl-name (intern (concatenate 'string
    -                                                 (string name)
    +                                                 (subseq (string name) 1)
                                                      "-IMPL")))
                      (impl-doc (format nil "Implementation for ~S" name))
                      (nargs (gensym "NARGS-"))
    
     
  • Raymond Toy

    Raymond Toy - 2020-09-16

    This change looks fine to me. I don't see any reason why the impl needs a leading $. It's an internal implementation detail that the user doesn't need to see.

     
  • Robert Dodier

    Robert Dodier - 2020-09-20
    • labels: --> lisp
    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 2020-09-20

    Fixed by commit 54a22fb. Closing this ticket, thank you for the bug report, I appreciate it.

     

Log in to post a comment.