Skip to content
This repository was archived by the owner on Dec 29, 2018. It is now read-only.
This repository was archived by the owner on Dec 29, 2018. It is now read-only.

export-constructors doesn't export default constructor from defstruct when another constructor specified #24

Open
@fourier

Description

@fourier

defstruct in CL allows to specify several constructors. If second argument to the :constructor keyword provided, it is used as a constructor name. :constructor with no arguments creates a default constructor.
However if both BOA(By Order of Arguments) and explicit default constructor provided, the export-constructors macro exports only BOA constructor, see the session below:

CL-USER 28 > (defstruct (point (:constructor create-point (x y)) (:constructor)) x y)
POINT

CL-USER 29 > (create-point 10 20)
#S(POINT :X 10 :Y 20)

CL-USER 30 > (make-point :x 10 :y 10)
#S(POINT :X 10 :Y 10)

CL-USER 31 > (pprint (macroexpand '(cl-annot.class:export-constructors (defstruct (point (:constructor create-point (x y)) (:constructor)) x y))))

(PROGN
  (EXPORT '(CREATE-POINT))
  (DEFSTRUCT (POINT (:CONSTRUCTOR CREATE-POINT (X Y)) (:CONSTRUCTOR)) X Y))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions