This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GOOPS: New syntax for `define-method'?


I'm getting mad at again and again typing things like:

  (define-method (foo (x <integer>) y)
    ...)

instead of

  (define-method foo ((x <integer>) y)
    ...)

The latter is tricky to write when you're accustomed to writing

  (define (foo x y)
    ...)

Therefore, I suggest that we change the syntax for `define-method' from

  (define-method NAME (PARAM-SPEC1 ...) BODY1 ...)

  NAME ::= SYMBOL | (setter SYMBOL)

to

  (define-method (NAME PARAM-SPEC1 ...) BODY1 ...)

In an intermediate period, we can support most of both syntaxes
simultaneously.  Note, however, that

  (define-method (setter SYMBOL) EXP1 EXP2)

is ambiguous.

According to the old syntax, EXP1 is the formal parameters of a method
on the generic function (setter SYMBOL).

According to the new syntax, EXP1 is the first body form of a method
on the generic function `setter' with specializers ((SYMBOL <top>)).

Since the latter alternative is unlikely and can be written

  (define-method (setter (SYMBOL <top>)) ...)

the old syntax interpretation can be used in the intermediate period
before the old syntax is removed.

Comments?  Opinions?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]