Sat 14 May 2016 12:14:14 AM UTC, comment #3:
As I posted to Octave-Maintainers recently, I'd like to overhaul the warning system.
One of the changes would be to have an enumeration of all warnings in the Octave: namespace in an enumeration. This would mean that C code can throw warnings with a cost independent of the number of disabled IDs. That will allow more fine-grained control over which language features a user wants to be warned about (my pet peeve being automatic broadcast).
The efficiency will become more important if we allow multiple scopes, such as "this directory", "this file", "this function", "all functions called by this function" (currently called "local"), as well as global -- as suggested at bug #36743 and bug #47687.)
The enumeration would be auto-generated from warning_ids.m, and so keeping that file in sync would be easier. Of course, .m files would still use string IDs, and so could get out of sync. However, it would be simple to have a tool to grep for IDs in one but not the other.
Although anyone can make up their own IDs, user warnings shouldn't be in the Octave: namespace. I'd suggest that Octave Forge should also have its own namespace, but that may involve unnecessary incompatibility.
Note that lastwarn () is only useful if one type of warning is given. The alternative is to do what Matlab does, and list the ID when the warning is printed. Octave currently has an unused flag for verbose warnings.
|