Hi Chris-
You might also find some helpful information here:
http://wiki.gotpike.org/PikeDevel/Annotations
There are one or two missing features in annotations, one of which is (I think) the lack of ability to add an annotation to a top level class (one that isn't identified by the class syntax. There might be a discussion about this in the archives; I think the conversation was left at needing to come up with an appropriate syntax for it.
Hope this is helpful!
Bill
On 2024-02-15 08:54, Chris Angelico wrote:
On Thu, 15 Feb 2024 at 23:39, Henrik Grubbström (Lysator) @ Pike (-) developers forum 10353@lyskom.lysator.liu.se wrote:
I'm trying to make good use of annotations, but all the existing ones are in cmod files, and I'm trying to work out how best to write them in Pike. My goal is to have an annotation that can be parameterized, something like this:
class Anno(string label) { inherit Pike.Annotation; @constant; }
@Anno("foobar"): void some_func() { }
The above is supposed to work.
But while this does result in the annotation itself showing up, the label on that annotation doesn't.
Try having the Anno class in a separate file.
Ah yes, now it works. Thanks. Didn't think to try that.
As long as Anno itself is added as a constant, the parameterized versions work correctly.
What's the intended way to create parameterized annotations?
This seems to be a compiler bug.
Thanks. Not a major issue since there's a workaround (and I'll usually have them in separate files anyway).
ChrisA