Ticket #245 (new defect)

Opened 1 year ago

Generic functions: how implicit is nextMethod?

Reported by: lth Assigned to: lth
Type: defect Priority: major
Milestone: Component: Spec
Version: 4 Keywords:
Cc: brendan

Description

The function value nextMethod is passed to every generic methods as an implicit first argument and allows the method to call the next most specific method (if there is one).

How explicit should this argument be? Should it show up in arguments?

My view is that since generic methods are created declaratively the insertion of nextMethod should be treated simply as a source-level rewrite; the appearance of nextMethod in the argument list should be documented; and the parameter should show up in arguments. This all emphasizes the fact that this parameter is not magic. It also emphasizes that nextMethod is a value that can be captured and passed around and invoked; it does not have dynamic scope. It really does capture the list of applicable methods.

(Note that compilers can analyze the bodies of generic methods and detect when nextMethod is not callled, and can pass null instead, if this suits them.)

If/when we add a procedural interface to generic functions, it will be handy for the programmer to be able to specify new names for this parameter, for example; a procedural interface would probably require this parameter to be explicit. So requring it to be explicit now is, if not future-proof, at least thinking toward the future.

Attachments

Note: See TracTickets for help on using tickets.