Discussion:
New warning "No generic function F present when encountering macroexpansion of defmethod."
Leslie P. Polzer
2009-11-04 10:33:03 UTC
Permalink
This newly introduced warning seems to be emitted every time
when there's a defmethod that is not preceded by a defgeneric.

But this is perfectly valid code and c2mop must[1] assume
that the implicit gf is of class standard-generic-function
without emitting a warning (which causes ASDF to stop everytime
it is encountered).

How about a compiler note instead?

Leslie


[1] http://www.lispworks.com/documentation/HyperSpec/Body/m_defmet.htm

"If (fboundp function-name) is nil, a generic function is created
with default values for the argument precedence order (each argument
is more specific than the arguments to its right in the argument
list), for the generic function class (the class standard-generic-function),
for the method class (the class standard-method), and for the method
combination type (the standard method combination type)."
--
http://www.linkedin.com/in/polzer
Pascal Costanza
2009-11-04 11:40:43 UTC
Permalink
Post by Leslie P. Polzer
This newly introduced warning seems to be emitted every time
when there's a defmethod that is not preceded by a defgeneric.
But this is perfectly valid code and c2mop must[1] assume
that the implicit gf is of class standard-generic-function
without emitting a warning (which causes ASDF to stop everytime
it is encountered).
How about a compiler note instead?
Is there a portable way to emit compiler notes? I don't immediately
find anything in the HyperSpec.

Another option is to emit the warning only when some global flag
(*warn-on-defmethod-without-defgeneric*, or so) is true. Would that be
acceptable? It should then be fine to use nil as the default.

The warning is important, IMHO, when you define your own generic
function metaclasses...


Pascal
Post by Leslie P. Polzer
Leslie
[1] http://www.lispworks.com/documentation/HyperSpec/Body/m_defmet.htm
"If (fboundp function-name) is nil, a generic function is created
with default values for the argument precedence order (each argument
is more specific than the arguments to its right in the argument
list), for the generic function class (the class standard-generic-
function),
for the method class (the class standard-method), and for the method
combination type (the standard method combination type)."
--
http://www.linkedin.com/in/polzer
_______________________________________________
closer-devel mailing list
http://common-lisp.net/cgi-bin/mailman/listinfo/closer-devel
--
Pascal Costanza, mailto:***@p-cos.net, http://p-cos.net
Vrije Universiteit Brussel
Software Languages Lab
Pleinlaan 2, B-1050 Brussel, Belgium
Leslie P. Polzer
2009-11-04 11:59:00 UTC
Permalink
Post by Pascal Costanza
Is there a portable way to emit compiler notes? I don't immediately
find anything in the HyperSpec.
There doesn't seem to be, unfortunately.
Post by Pascal Costanza
Another option is to emit the warning only when some global flag
(*warn-on-defmethod-without-defgeneric*, or so) is true. Would that be
acceptable? It should then be fine to use nil as the default.
The warning is important, IMHO, when you define your own generic
function metaclasses...
I concur. Your global switch proposal would also be perfectly
acceptable at least to me.

Leslie
--
http://www.linkedin.com/in/polzer
Tobias C. Rittweiler
2009-11-04 12:57:00 UTC
Permalink
Post by Pascal Costanza
Post by Leslie P. Polzer
This newly introduced warning seems to be emitted every time
when there's a defmethod that is not preceded by a defgeneric.
But this is perfectly valid code and c2mop must[1] assume
that the implicit gf is of class standard-generic-function
without emitting a warning (which causes ASDF to stop everytime
it is encountered).
How about a compiler note instead?
Is there a portable way to emit compiler notes? I don't immediately
find anything in the HyperSpec.
Signal a STYLE-WARNING, it's what it's for.

-T.
Attila Lendvai
2009-11-04 13:07:11 UTC
Permalink
Post by Tobias C. Rittweiler
Post by Pascal Costanza
Post by Leslie P. Polzer
How about a compiler note instead?
Is there a portable way to emit compiler notes? I don't immediately
find anything in the HyperSpec.
Signal a STYLE-WARNING, it's what it's for.
yes, and sane compilers already signal a style warning for this, while
the conflict with cl:defmethod is kinda cumbersome. needs to be dealt
with at every usage of closer mop... is it worth it?

maybe as part of a closer-mop-strict package?
--
attila
Pascal Costanza
2009-11-04 13:51:09 UTC
Permalink
Post by Attila Lendvai
Post by Tobias C. Rittweiler
Post by Pascal Costanza
Post by Leslie P. Polzer
How about a compiler note instead?
Is there a portable way to emit compiler notes? I don't immediately
find anything in the HyperSpec.
Signal a STYLE-WARNING, it's what it's for.
yes, and sane compilers already signal a style warning for this, while
the conflict with cl:defmethod is kinda cumbersome. needs to be dealt
with at every usage of closer mop... is it worth it?
OK, a style warning seems reasonable.

I will check which compilers already issue such a style warning, and
only include the warning for implementations that don't do this. If
there is a common way of disabling such style warnings, I will try to
integrate that as well, hopefully in a uniform way.
Post by Attila Lendvai
maybe as part of a closer-mop-strict package?
I'm not sure if I would want that. I think the right way is to use a
global variable, a symbol macro, or an entry in *features*. I will
check what is best.


Thanks a lot for the feedback!


Pascal
--
Pascal Costanza, mailto:***@p-cos.net, http://p-cos.net
Vrije Universiteit Brussel
Software Languages Lab
Pleinlaan 2, B-1050 Brussel, Belgium
Pascal Costanza
2009-11-04 15:22:50 UTC
Permalink
Hi,

OK, I solved this as follows:

+ I turned the warning into a style-warning.

+ I provide a symbol macro warn-on-defmethod-without-generic-function
that can be used to disable/enable that warning. By default it is set
to t, except for SBCL where it is set to nil because SBCL already
warns about this.

If you want to disable the warning locally, just wrap your code in this:

(symbol-macrolet ((warn-on-defmethod-without-generic-function nil))
...)

If you want to enable the warning locally (for whatever strange reason
you might think of ;), use t instead of nil.

You can also globally disable the warning after you loaded Closer to
MOP like this:

(define-symbol-macro warn-on-defmethod-without-generic-function nil)

I think this should make most people happy.

The changes are in the repository.

Best,
Pascal
--
Pascal Costanza, mailto:***@p-cos.net, http://p-cos.net
Vrije Universiteit Brussel
Software Languages Lab
Pleinlaan 2, B-1050 Brussel, Belgium
Loading...