generic-programming

Datatype-generic programming libraries for Scala

I'm looking for a Scala library allowing for datatype-generic programming (like Scrap Your Boilerplate, for example). A list of libraries with appropriate links and short descriptions for each one would be a perfect answer. ...

C# Extension Method on Type With Generic Type Argument

I’m looking at ways to improve the consistency, brevity, and readability of some code in the application I’m working on. The starting code looked something like this: context.GetGraphType<Bar>().Subscribe<Fizz>( (instance, evt) => e.Execute((Bar)instance.Instance) ); There are a number of nearly identical lines of code like the ...

What do you feel is over-generalization?

Having spent some time playing around in Haskell and other functional languages, I've come to appreciate the simplicity of design that comes from describing problems in general terms. While many aspects of template programming can be far from simple, some uses are common enough that I don't think they're an impediment to clarity (especia...

C# generic How to define that T is Base<Tp> : where Tp : Base<Tp> and Call Base<Tp> method

Hi! I have confusing situation. Base Generic Type and successor public abstract class BaseType<TEntity> : where TEntity : BaseType<TEntity> public class AnyType : BaseType<AnyType> It looks like a generic loop))) I need Method like public void Method<T>(T data) { if(typeof(T).IsSubclassOf(BaseType<????>)) convert data to BaseType<...

Scrap Your Boilerplate in f#

I've used the Scrap Your Boilerplate and Uniplate libraries in the Haskell programming language, and I would find that form of generic programming over discriminated unions to be really useful. Is there an equivalent library in the f# programming language? ...

void return value from a function used as input to a templated function is seen as a parameter.

Say you have some target class with some methods on it: class Subject { public: void voidReturn() { std::cout<<__FUNCTION__<<std::endl; } int intReturn() { std::cout<<__FUNCTION__<<std::endl; return 137; } }; And a Value class (similar in concept to Boost.Any): struct Value { Value() {} Value( Value const & orig ) {} temp...

Inheritance in generic types

Can anyone help me in using Where for generic types? I was trying to create a function which does ST with a number of type double or int, so I said it should be generic function. But when I try to assign a value to variables of that generic type, I can't because it's not a numerical type. Also, I can't use Where to inherit generic type f...

AS3 Remove element from array (of objects) generically

Hi All, Is there a way to generically remove an object from an array? (maybe not using array.filter or creating a new array) Example: var arr:Array= new Array(); //create dummy objs for (var i:uint=0; i < 10; i++){ var someObject:SomeClassObject = new SomeClassObject(); someObject.Name ="Amit"+ i; ...

Optimal way to pass system values to javascript

What is the most effective way to pass object and category ids or other system variables which shouldn't be presented to the user, from server to the browser? Let's say I have a list of items where I can do something with each of them by javascript, for example show tooltip html or add to favorites by ajax, or display on a map. Where is...

Generic programming v.s. Metaprogramming...

What exactly is the difference? It seems like the terms can be used somewhat interchangeably, but reading the wikipedia entry for Objective-c, I came across: In addition to C’s style of procedural programming, C++ directly supports certain forms of object-oriented programming, generic programming, and metaprogramming. in r...

How to clone multiple inheritance object?

I have defined a Cloneable interface: struct Cloneable { virtual Cloneable * clone(void) const = 0; } I have also some other interface classes (content not relevant to issue): struct Interface { }; struct Useful_Goodies { }; I have created a leaf object which inherits from the above classes: struct Leaf : public Cloneable, publ...

Delegates in Java like in .NET

Hi, I need some advise regarding approach in Java, as the delegates are bit different than .NET one. I wold like to create some interfaces that has the same name and same method name but only thing that differ them is number of parameters. Something like Actions in .NET Some code samples. What works for now is the abstract class imp...