hello again, I suppose this answer addresses almost directly @Elias , I am completely aware that we have generic values, however this pops casually in mind - the reason is (I don’t remember in which channel I read it, probably on Element) that there is no chance to have in Node Factory, would dynamic variables suffer the same, what is the limitation? is a matter of design decision or something that it doesn’t seem worthy to have in vvvv?
which behaves similarly to Object, but checking for Null Object in inlets of a process node became a nightmare to me.
Tuples and NamedTuples are restricting me to use params (overloaded methods or constructors). Ideally I want to pass a number of different type parameters as __args in my constructor to mimic python’s or any other non type defined language, I thought this would be the closest one we could have.
Well the issue is, that maybe looks kind off flexible, the downside you going to have large boilerplate on getters, yes it is dynamic but you have no clue what’s inside… and is it built already? I think you already can use kind of Dictionary<string,object> or Spread<object> with OfType for this… But patchwise I think that gonna look ugly…
correct, this is what I am doing at the moment. Using object instead. But setting an inlet of a node as type of object keeps it evaluating all the time. In example, create a Cache region and pass through (from board) an input of type object. Then you will obviously see that the Cache region keeps evaluating on every single frame (still of course you connect any other specified type on you inlet).
the only way I can imagine would be possible to prevent it is if I could to set the Input default value to null. It seems that it is not. Another way it roughly worked for me - maybe accidentally was to use a nullable object? as an argument of a method in c#.
Generally you want to avoid null in this case, since you would not be able to locate the prop with OfType, issue with object is that it’s by default ‘{}’. That issue is actually first sight of what I meant by ugly patching. The obvious next step is to wrap your object with something immutable like optional or tuple but suddenly you’ll notice that you can’t cast to T since you need to first access tuple… Idk might some C# type wrapper would help this case, basically you create something immutable that is object inside but can be accessed wia T
Think it’s called ungeneric via generic façade (aka serialization hell)
Something like this:
using System;
using System.Collections.Generic;
using System.Linq;
public interface IBox { object Value { get; } }
public class Box<T>(T value) : IBox
{
public T TypedValue { get; set; } = value;
public object Value => TypedValue!;
}
public class Program
{
public static void Main()
{
var list = new List<IBox>
{
new Box<int>(42),
new Box<string>("Hello Generic"),
new Box<int>(100)
};
// Extracting only Box<int> items using Linq OfType
var intBoxes = list.OfType<Box<int>>();
foreach (var intBox in intBoxes)
{
Console.WriteLine($"Typed int math: {intBox.TypedValue * 2}");
}
// Generic fallback for any other items
foreach (var box in list)
{
Console.WriteLine($"Fallback output: {box.Value}");
}
}
}