Skip to content

Symbols in package export are not matched against symbols in defuns #30

Open
@verdammelt

Description

@verdammelt

For example as reported by exercism.lol the submission:

(defpackage :socks-and-sexprs
  (:use :cl)
  (:export :lennys-favorite-food :lennys-secret-keyword
           :is-an-atom-p :is-a-cons-p :first-thing :rest-of-it))

(in-package :socks-and-sexprs)

;; Evaluates to some symbol (not a keyword)
(defun lennys-favorite-food () 'wild)

;; Evaluates to some keyword
(defun lennys-secret-keyword () :stuff)

;; Evaluates to T if THING is an atom, NIL otherwise
(defun is-an-atom-p (thing) (atom thing))

;; Evaluates to T if THING is a cons, NIL otherwise
(defun is-a-cons-p (thing) (consp thing))

;; Evaluates to the first part of CONS
(defun first-thing (cons) (car cons))

;; Evaluates to the 'rest' of the CONS
(defun rest-of-it (cons) (cdr cons))

Is represented as:

((DEFPACKAGE :SOCKS-AND-SEXPRS-0
   (:EXPORT :SOCKS-AND-SEXPRS-1
            :SOCKS-AND-SEXPRS-2
            :SOCKS-AND-SEXPRS-3
            :SOCKS-AND-SEXPRS-4
            :SOCKS-AND-SEXPRS-5
            :SOCKS-AND-SEXPRS-6)
   (:USE :SOCKS-AND-SEXPRS-7))
 (IN-PACKAGE :SOCKS-AND-SEXPRS-0)
 (DEFUN :SOCKS-AND-SEXPRS-8
        ((:REQUIRED NIL) (:OPTIONAL NIL) (:REST NIL) (:KEYWORD NIL) (:AUX NIL)
         (:ALLOW-OTHER-KEYS NIL))
   (:DOCSTRING NIL)
   (:DECLARE NIL)
   ('WILD))
 (DEFUN :SOCKS-AND-SEXPRS-9
        ((:REQUIRED NIL) (:OPTIONAL NIL) (:REST NIL) (:KEYWORD NIL) (:AUX NIL)
         (:ALLOW-OTHER-KEYS NIL))
   (:DOCSTRING NIL)
   (:DECLARE NIL)
   (:STUFF))
 (DEFUN :SOCKS-AND-SEXPRS-10
        ((:REQUIRED (:SOCKS-AND-SEXPRS-11)) (:OPTIONAL NIL) (:REST NIL)
         (:KEYWORD NIL) (:AUX NIL) (:ALLOW-OTHER-KEYS NIL))
   (:DOCSTRING NIL)
   (:DECLARE NIL)
   ((ATOM :SOCKS-AND-SEXPRS-11)))
 (DEFUN :SOCKS-AND-SEXPRS-12
        ((:REQUIRED (:SOCKS-AND-SEXPRS-11)) (:OPTIONAL NIL) (:REST NIL)
         (:KEYWORD NIL) (:AUX NIL) (:ALLOW-OTHER-KEYS NIL))
   (:DOCSTRING NIL)
   (:DECLARE NIL)
   ((CONSP :SOCKS-AND-SEXPRS-11)))
 (DEFUN :SOCKS-AND-SEXPRS-13
        ((:REQUIRED (:SOCKS-AND-SEXPRS-14)) (:OPTIONAL NIL) (:REST NIL)
         (:KEYWORD NIL) (:AUX NIL) (:ALLOW-OTHER-KEYS NIL))
   (:DOCSTRING NIL)
   (:DECLARE NIL)
   ((CAR :SOCKS-AND-SEXPRS-14)))
 (DEFUN :SOCKS-AND-SEXPRS-15
        ((:REQUIRED (:SOCKS-AND-SEXPRS-14)) (:OPTIONAL NIL) (:REST NIL)
         (:KEYWORD NIL) (:AUX NIL) (:ALLOW-OTHER-KEYS NIL))
   (:DOCSTRING NIL)
   (:DECLARE NIL)
   ((CDR :SOCKS-AND-SEXPRS-14))))

Note the exported symbols in the DEFPACKAGE are not matching those in the DEFUNs below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions