metaprogramming Questions

0

Let's get straight to the point. I want to create a declarator, let's call it testable, that is the combination of our and is export, so that instead of writing our $foo is export; we would simp...
Important asked 24/5, 2020 at 15:57

3

Solved

I am wondering if it is possible to list the variables expected by a Python function, prior to calling it, in order to pass the expected variables from a bigger dict containing a lot of variables. ...
Smoothbore asked 26/3, 2013 at 13:48

9

Just a quick and simple question: in PostgreSQL, how do you list the names of all stored functions/stored procedures using a table using just a SELECT statement, if possible? If a simple SELECT is ...
Saudra asked 13/10, 2009 at 8:54

1

Solved

I have created a function that does the runtime requirement of checking for null and undefined not being true: function hasFields<T>(obj: T | T[], ...fields: (keyof T)[]): boolean { const...
Chandra asked 12/5, 2020 at 19:43

8

I know that JavaScript doesn't support macros (Lisp-style ones) but I was wondering if anyone had a solution to maybe simulate macros? I Googled it, and one of the solutions suggested using eval(),...
Recrystallize asked 11/10, 2008 at 1:15

2

Solved

I am trying to get the name of the class from within a static method within the class: class A def self.get_class_name self.class.name.underscore.capitalize.constantize end end Though this re...
Gingerly asked 6/7, 2015 at 13:11

1

Solved

I'm trying to better my understanding of meta-programming in Ruby and am confused as to what Module.included is? My current understanding is that this is a callback invoked by Ruby whenever the mod...
Ladida asked 3/5, 2020 at 22:46

1

Solved

Consider the following code: #include <iostream> struct Foo { void work() { std::cout << "foo" << std::endl; } }; typedef void function_type(void *arg); template <t...
Blaine asked 29/4, 2020 at 12:8

2

Solved

I need a meta-function that for given complete class type returns its template (e.g. f<foo<bar>>::type or f<foo<baz>>::type results in foo). Or it may return true on f<f...

4

Solved

I've got problem with creating function that for given type, if it's derived from other one do something and for all other cases do something other. My code: class BaseClass {}; class DerivedClass...
Carboniferous asked 7/2, 2017 at 8:47

6

Solved

I need to generate code for a method at runtime. It's important to be able to run arbitrary code and have a docstring. I came up with a solution combining exec and setattr, here's a dummy example:...
Rogozen asked 10/2, 2009 at 17:40

2

Solved

i was trying to list the instance variables inside a controller but came up with irb>HomeController.instance_variable_names => ["@visible_actions", "@inheritable_attributes", "@controller_pa...
Silden asked 19/5, 2011 at 16:2

4

Solved

There has to be a built in way of doing this, right? class Object def send_chain(arr) o=self arr.each{|a| o=o.send(a) } return o end end
Sorption asked 4/11, 2010 at 17:28

3

Say that I'm building up an expression with R's backquote operator bquote, and I'd like to "splice" in a list at a specific position (that is, lose the outer parenthesis of the list). For example,...
Noellenoellyn asked 20/2, 2014 at 0:23

1

Solved

I am trying to write a macro that defines multiple methods for a type hierarchy. What I am trying to achieve is a way to arbitrarely enumerate a type hierarchy, by defining an order() method for ea...
Arundinaceous asked 10/3, 2020 at 20:12

6

Solved

I'm using type() to dynamically generate classes that will ultimately be pickled. The problem is that the un-pickling process needs the definition of the class in order to re-construct the object t...
Redfin asked 25/7, 2012 at 20:57

1

Solved

The ultimate goal in the question is to construct the following unevaluated call using r's computing on the language, where list, a_name and 50L are provided from parameters. list(a_name = 50L) ...
Approver asked 8/3, 2020 at 12:53

5

Solved

I have a function that takes another function as a parameter. If the function is a member of a class, I need to find the name of that class. E.g. def analyser(testFunc): print testFunc.__name__, ...
Partheniaparthenocarpy asked 20/11, 2008 at 16:30

4

Solved

We have a recurring problem in our shop where we end up with 3 or 4 different representations of the same class/entity. A java version, an xml version, a hibernate version, a json version... you ...
Oyez asked 1/3, 2012 at 20:9

3

Solved

I have a function template which takes many different types as it's input. Out of those types only one of them has a getInt() function. Hence I want the code to run the function only for that type....
Riesman asked 7/2, 2020 at 11:14

2

Solved

Given the following function, function floop(exp) a = 5 b = 10 ex = Expr(:call, :+, 1, exp); return eval(ex); end if I then run floop(Symbol("b")) I get an error saying that b is not defi...
Berenice asked 7/2, 2020 at 1:11

5

Solved

In python you can do something like this to import a module using a string filename, and assign its namespace a variable on the local namespace. x = __import__(str) I'm wondering if there is a r...
Wilkie asked 1/9, 2010 at 1:56

2

Let's consider two functions with same names: int func(int&) { return 7; } int func(const int&) { return 5; } Let int mutableValue = 5 be defined somewhere. Is there any possibility th...
Oecology asked 24/1, 2020 at 9:44

4

I'm trying to understand what metaprogramming is general and what it is in C++ in particular. If I search for c++ metaprogramming I do get tutorials of template metaprogramming (TMP), but no explan...

3

Solved

Recently in a job interview I was asked to give the result of 100th element of a 3rd-class Fibonacci sequence(Fib(n)=Fib(n-1)+Fib(n-2)+Fib(n-3). I finished by Mathematical Induction and constructin...
Superadd asked 3/1, 2020 at 14:33

© 2022 - 2024 — McMap. All rights reserved.