2,827 questions
0 votes
1 answer
59 views
Is there any way to make Groovy 4.0.x compile interfaces with static methods?
I want to make an interface with some static methods for decorating instances or adapting them to other interfaces. However, Groovy 4.0.x gives an error when trying to do this, probably because it's ...
2 votes
1 answer
109 views
Dispatching static methods on generic types
I want to achieve something like this: interface Parent { static int hi() { return 1; } } class Child implements Parent { static int hi() { return 0; } } class Child2 implements Parent { ...
1 vote
1 answer
76 views
Is there a language feature like Python's `issubclass` to cast instances of System.Type to the actual type (to access static methods w/o reflection)?
I have the following interface which contains a static method definition: public interface IUpgradableDataSource { static abstract Task<JsonElement> UpgradeSourceConfigurationAsync( ...
0 votes
2 answers
209 views
Is it possible to call a static abstract interface method from implementation of another static interface method?
The question is simply in the comment of code below By the way this code is valid only with C#-11 language version (ie: create a Net 8.0 framework project or later to test). Is the problem of code ...
1 vote
2 answers
158 views
C++ Why is it not possible to invoke functions globally without initializing new variables?
If I had to run functions in the global scope e.g. in order to populate a static container in several cpp-files, then each time such a function is invoked I would have to initialize a new variable as ...
1 vote
0 answers
34 views
Are built-in static methods bound? [duplicate]
According to the specification, are built-in Javascript static methods, like Array.from, Object.assign, console.log, etc meant to be bound or do they need to be invoked via the constructor/object? ...
0 votes
1 answer
65 views
Set data from WebSocket Server to JFrame components
I have WebSocket server: @ServerEndpoint(value = "/demoApp") public class MyWebSocketServer { @OnMessage public String onMessage (String message, Session session) throws IOException {...
2 votes
1 answer
181 views
Extract a class from a static method
Given a function which is a staticmethod of a class, is there a way to extract the parent class object from this? class A: @staticmethod def b(): ... ... f = A.b ... assert ...
-1 votes
2 answers
93 views
Why does Java allow static methods within an Inner class [duplicate]
Java shouldn't allow static methods within an inner class and yet this code compiles and runs. How is this possible? class Test{ static int j=20; public void m1() { class Inner{ ...
0 votes
1 answer
120 views
How to define a static constructor within a JS class?
How do you define a static constructor within a JS class? I managed to write something that somehow works but it requires to write a specific codepath in constructor for when an IngredientsDB object ...
-2 votes
1 answer
61 views
Well Crafted Patterns To Access Instanced Members Through Static Functions Without The Singleton?
I'm looking for a solution that would allow me to have access to a static function that would operate on instanced values without implementing a singleton. I'm not sure it's possible, I've personally ...
0 votes
1 answer
106 views
AddressSanitizer Error When Using Static Member Function as Comparator in C++ Priority Queue
I'm working with a priority_queue in C++ and encountered a problem when using a static member function as a custom comparator within a class. A reproducible example will be: #include <bits/stdc++.h&...
5 votes
2 answers
83 views
Assigning an Attribute to a @staticmethod in Python
I have a scenario where I have objects with static methods. They are all built using an outside def build_hello() as class variables. def build_hello(name: str): @staticmethod def hello_fn(): ...
1 vote
1 answer
95 views
How to provide a 'blanket implementation' of a static method for the derived class?
Consider this: struct Base { static Base make() { return {}; } }; struct Derived : public Base { // I _would_ want to have a `static Derived make()` automagically here }; One approach to the ...
0 votes
1 answer
62 views
DRY - Derived class with static methods
In Unity C#, I have a base class Baker, it's derived from ScriptableObject, and I'm deriving from it CakeBaker, BreadBaker, PieBaker. ScriptableObjects can only be created statically, using ...