Skip to content

Section on declaring function types with ftype is incorrect #613

Description

@VisenDev

This section says that a function may have multiple incompatible ftypes declarations.

cl-cookbook/performance.md

Lines 394 to 398 in 89018a5

Another useful declaration is a `ftype` declaration which establishes
the relationship between the function argument types and the return value type.
If the type of passed arguments matches the declared types, the return value type
is expected to match the declared one. Because of that, a function can have more
than one `ftype` declaration associated with it. A `ftype` declaration restricts

However, after investigating this claim, i'm not sure if it is accurate. The hyperspec simply says that an ftype declaration "Specifies that the functions named by function-names are of the functional type type." I couldn't find anything about multiple ftype declarations being valid.

Furthermore, when testing with sbcl, I get a warning when defining two different ftypes for the same function.

CL-USER> (declaim (ftype (function (fixnum fixnum) fixnum) minus))
(MINUS)
CL-USER> (declaim (ftype (function (float float) float) minus))
WARNING:
   The new FTYPE proclamation for COMMON-LISP-USER::MINUS
     (FUNCTION (FLOAT FLOAT) FLOAT)
   does not match the old FTYPE proclamation
     (FUNCTION (FIXNUM FIXNUM) (VALUES FIXNUM &REST T))
(MINUS)
CL-USER> 

However, neither ECL. CLISP, or ABCL gave a similar warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions