309 questions with no answers
1
vote
0
answers
98
views
Is it possible to bound type-level recursion?
I'm trying to construct a typed lambda calculus, something along the lines of:
struct Fun<T>(T); // actual definition elided for simplicity
struct TypeErasedExpr { /* elided for simplicity */ }
...
1
vote
0
answers
57
views
is there a python pattern that allows an attribute in a base class be an instance of the derived class?
Is there some clever way to do this that works?
class NamedElement:
def __init__(self, **kwargs):
self.name = Property(name=kwargs.get('name')) #you're going to regret this
class Property(...
0
votes
0
answers
22
views
How to resolve metaprogramming function when variable is indirectly assigned a function name?
I'm working with metaprogramming in Python and need to dynamically resolve functions. When a variable is directly assigned a function name, everything works. However, when assigned indirectly via ...
1
vote
0
answers
58
views
Why does SQL meta-programming using macro variables fail
I have an in-memory table defined as follows in DolphinDB:
t = table(2025.01.01 as date, 1 as M01, 2 as M02, 3 as M03, 4 as M04, 5 as M05, 6 as M06, 1 as M07, 2 as M08, 3 as M09, 4 as M10, 5 as M11, 6 ...
0
votes
0
answers
29
views
In DolphinDB, how to calculate stock residual return based on a table using the ols function?
I have a table “clean_factor“ where the column “y“ indicates the stock returns and the subsequent columns indicate factor exposures. How do I calculate the daily residual return of each stock with the ...
0
votes
0
answers
128
views
Can a metaclass be used as a type hint for a class instance in Python 3.12+?
The project I'm working on uses a somewhat complex typing system, I have a base class called RID which uses the metaclass RIDType. Custom RID types are classes which derive from RID:
class RIDType(...
1
vote
0
answers
67
views
How to match a Lambda function literal expression
I am trying to transform the code of literal lambda expressions in a Scala-3 macro.
I have defined a macro like this
def rCode(formal: Expr[Int => Boolean])(using Quotes): Expr[Int => Boolean] =
...
2
votes
0
answers
72
views
Templates with reference forwarding behaving unexpected
This is my example code:
#include <iostream>
#include <type_traits>
template <typename T>
void check_type(T&&) {
if constexpr (std::is_reference<T>::value) {
...
0
votes
0
answers
48
views
How to track access to class variables in a custom ORM using Python descriptors?
I'm building my own ORM in Python and ran into an issue. I want to track the access to class variables in order to know which ForeignKey is being used in each part of my code.
class IQuery(ABC):
&...
1
vote
0
answers
37
views
Is there a way in Groovy to intercept a static method call, a la invokeMethod, that would be inherited by a subclass?
I'm trying to find a way to quietly wrap the main method of a class in a try/catch block.
What I'm imagining is a static version of invokeMethod, where I can simply intercept the main method call and ...
1
vote
0
answers
116
views
Pass a string concatenation to a macro
I'm trying to generate an enum type at compile-time, based on a json file.
Following guides like https://developerlife.com/2022/03/30/rust-proc-macro/ I made this :
An external crate my_macros since ...
0
votes
0
answers
699
views
How to dynamically access keys and values of a struct in Zig?
How can one define a function that takes a struct in Zig and be able to access all the keys and values In that struct dynamically?
I have tried a couple of approaches but I kept getting compile error.
...
1
vote
0
answers
1k
views
Is it possible to change method type annotations for a class instance?
I have a class which takes in some arguments, with a method that takes and returns a namedtuple. The namedtuple itself is defined within the init based on some inputs, e.g.:
class MyClass:
def ...
0
votes
0
answers
93
views
What is the preferred / recommended rlang metaprogramming syntax to use on both sides of an assignment operator in the `dplyr::mutate()` function?
I have a question about an issue that's similar to this older question about the dplyr::filter() function, except that my example is a bit more complicated because dplyr::mutate() needs to process ...
0
votes
0
answers
42
views
Adding new files in Rails engine's lookup context
I am making a rails engine which has a themes folder , in app/apps/themes . When you install the gem in a host application , the user should have the ability to add a new theme depending on their ...