Is it possible to define an *instance* method in tag-based CSP?
In a tag-based CSP page, I can define (e.g.):
<script method="Foo" language="cache" runat="server">
Is there any way to use this syntax to define an *instance* method (i.e., Method rather than ClassMethod) in the generated class?
Comments
Supposing it's possible, does it make sense? Note that it's a genuine question, a doubt I have.
What would be the instance (i.e. $this) of the method?
Enrico
That's a fair question. In my specific case, I'm trying to write a tag-based CSP page that extends %CSP.WebSocket, which involves overriding instance methods.
Turns out that it's as simple as putting classmethod="0" in your <script> tag... and then getting a helpful error message on compilation that you can't actually do that in a CSP page. 😂
On the other hand, if you use:
classmethod="##(+$Piece($STACK($STACK-3,"PLACE"),"+",2)<10)##"
Then it'll happily compile instance methods, and your successor and someone in the WRC will have probably a good laugh when your application randomly breaks in 2-10 years.

well played :)
Create a new class, say myCSP.WebSocket, that extends %CSP.WebSocket.
Add your instance method to myCSP.WebSocket class and use it as superclass of your CSP page(s).
Enrico
This is a much cleaner option, of course. :)
(I have other constraints that led me to not go this route in the first place.)
In fact, even subclassing %CSP.WebSocket or adding your instance methods class as superclass would not work because all the code you write inside a CSP page run in class methods, so you cannot call an instance method.
And this brings back my initial question:
What would be the instance (i.e. $this) of the method?
None I think, within a CSP page code there is no current instance, the "page" is not instantiated, even when using %CSP.WebSocket as superclass.
But...how are you using %CSP.WebSocket??
Something like:
<CSP:CLASS SUPER="%CSP.WebSocket">
Or what/how?
Enrico
Yes, that was how I was trying to.
Have used "%" variables to share context between a chain of sequentially executing classmethods on a CSP page.
This means enriching existing %request.Data variable, as it is already there and instrumented for Dump, or can use a different % variable name.
Solution was ultimately to just use a class and the CSPURL parameter. (Context: https://github.com/intersystems/git-source-control/pull/255 )
In a tag-based CSP page...
just use a class and the CSPURL parameter
Well, that's a change of the game! 😁
Enrico