Have multiple main_callable functions in one file #62
Replies: 1 comment 4 replies
-
This request shows great insight on your part. I have been thinking about this for a long time. You may have already noticed that several nodes in Nodezator have different signatures. For instance, This is so due to one or two of these reasons: A. the callable has different incompatible signatures; Reason A applies to callables written in C, which may have different incompatible signatures, something which Python cannot do. For instance, As for reason B, for nodes that accept many kinds of data, regardless of whether the node has 01 or more signatures, it may be useful to have "versions" with different widgets attached to them for convenience, since each widget specializes in a editing a specific kind of data. Because of that, since widgets are just convenient ways of holding and editing data, I may also make it so the user can switch widgets in a node as long as the data edited by them is compatible (for instance, a widget that edits colors could be switched by another widget that edits tuples/lists, since colors can be represented using them as well). But this will probably take sometime, because I also want to come up with some kind of add-on/plugin system so users can define and publish their own widgets as well. After all, there can be as many kinds of widgets as there are kinds of data. However, I think having multiple I think the example using pygame.Rect that the text from the link explores is a perfect example of how multiple signatures could be provided in a single file for the same main callable, which is pygame.Rect. In the pygame.Rect example I just mentioned, all nodes represent the pygame.Rect. In the image I shown at the top of this message, the different Commenting more specifically on your statement:
I understand what you are saying here, but if there are 02 or more formulas, I'd say it means there has to be some significant difference between them. For instance, here are different ways to calculate the area of a circle I grabbed from google: Area = π × r², where 'r' is the radius. Even though they all have the same purpose, they require different inputs, since they approach the problem in different ways. In the pygame.Rect example, the data required is always the same (that is, the top, left, width and height of the rect) only the format in which this data is delivered changes (using four inputs, two inputs or a single input containing the four values). In the formulas for the area of the circle shown above, the data/inputs required are different, though. The formulas are related, but they represent different operations. That is why they would be completely different nodes, they can't be main callables of the same operation, they are distinct operations. However, I acknowledge that, for the sake of organization, having to create a separate folder with a single file for each of these small operations seems too much. For that purpose, I'd accept suggestions of how this could be improved (for which we can use this discussion you created). Using the circle area formulas as an example, if we were to turn them into nodes, one thing I have in mind is to allow each of them to sit in a single file inside a category, instead of having a folder. For instance:
Then, if needed in the future, the files can be turned into folders if needed like this:
However, keep in mind that this idea or any others that may appear must be carefully analyzed before being considered/accepted because there are other factors to take into account that might make the proposed idea unfeasible, like breaking changes that would need to be introduced related to how the nodes are loaded or how the graphs are exported as pure python code. I'm just getting the ball rolling. Again, thank you for your feedback and please, if/when you have the time and at your own pace, let me know what you think about all of this. |
Beta Was this translation helpful? Give feedback.
-
There can be several different forms of a formula. They can be placed in one file, so it is easy to locate each of them.
Beta Was this translation helpful? Give feedback.
All reactions