RemedyBG»Forums
42 posts
Feature Suggestion: Loop syntax in the Watch window...
Edited by Opoiregwfetags on

Hi, I have a crazy idea. Sometimes you have an array of structs, and want to see which elements of the array have a certain flag set, or something more complex, like which elements of your array of rectangles have an area greater than 30. When that happens, you have to mentally calculate the area for each element, and if the struct has enough variables, you often have to expand each struct manually... So, my proposal is that you could use the syntax in the following examples in the Name part of the Watch window:

entities[__index].isDead, 16

This name would expand to a list of 16 items (shown like an array of 16 elements), and show the result on the value side of each item.

rectArray[__index].width*rectArray[__index].height > 30, numRects

This would display true or false (1 or 0) on the Value column for each item.

__index would be a pseudo variable that would become the number of the index at each iteration, from 0 to num_elements-1. On the back-end, this could simply be equivalent to copy-pasting your expression many times with a different __index constant...

Matrices could easily support this, too, since they're just arrays. If you wanted to visualize the addition of two matrices together, you'd do: matrix1[__index] + matrix2[__index], mtx

I also see how accepting this idea might feel like the entrance to a rabbit-hole of features to add more power to these kind of expressions, like "Oh, I wana do this loop thing but I have a linked list instead of an array, so can we, like, add a way to define and call functions and allow recursion and stuff?". That's too much. (Actually, the main thing you'd need for this is "just" need the ability to declare and set custom pseudo variables, but to me it wouldn't be worth the complexity). But just the simple loop seems reasonable. It doesn't even require much new syntax since it looks like the normal array syntax, and I feel like it would be very useful and cool.

Let me know what you guys think about this.

42 posts
Feature Suggestion: Loop syntax in the Watch window...
Edited by Opoiregwfetags on

By the way, if we end up having an image viewer option for the watch data, I think these two features would combine nicely. It would allow to visualize a specific member variable in all the structs in a 1D array as a row of pixels going from black to white, which might be useful in some situations; and it would also allow the same kind of visualization of 2D arrays, although I can see myself using those less often. Maybe that would get slow, since basically you'd have 1 expression per pixel, but you could just be responsible and limit the number of pixels.

265 posts / 1 project
None
Feature Suggestion: Loop syntax in the Watch window...

The plan is to extend the formatters to allow specifying one or more subexpressions relative to the base value of an iterable expression. I think this might fit with what you are looking for (if not, let me know).

In your example, this would look like

  entities, 16 { $.isDead }

with the result, in the watch window, looking like:

Name Value
entites, 16 { $.isDead} *

where * is the following, nested, table:

.isDead
true
false
...
true

Your second example would look like

  rectArray, numRects { $.width * $.height > 30 }

You'll also be able to specify the column names as part of the expression. Something like,

  entities, 16 { dead: $.isDead, alive: !$.isDead }

Also note that this would also work the same for linked lists (once the ll format specifier is implemented).

BTW, this feature is the entire reason that I'm working on an extended watch window view that I alluded to in your previous suggestion on an image "formatter". In other words, expect this feature sooner rather than later :)

Thanks!

42 posts
Feature Suggestion: Loop syntax in the Watch window...
Edited by Opoiregwfetags on
Replying to x13pixels (#25871)

Sounds good. I'm eager to see the new watch features you're working on. Your version wouldn't allow certain things like adding two arrays together, or combining values from two arrays of different types (like if you have an array of entities and an array of bits that say which entity slots are occupied or something... SOA kinda stuff...) but I myself wouldn't care much about the absence of these features, since those cases are the exception rather than the rule. I guess when you release those features, if after a while of using them I feel like I miss this __item pseudo variable thing, I'll make a new suggestion about it.

I really like the idea of being able to add multiple values in a row.

PS: Actually, if you just allow accessing the address of $ by putting a & before it, you would then magically have an equivalent of my __item thing if you do this:

(u8 *)0, size {sum: array1[&$] + array2[&$]}

Syntactically it makes logical sense... Would you consider allowing this?

Thanks for your response.

265 posts / 1 project
None
Feature Suggestion: Loop syntax in the Watch window...
Replying to Opoiregwfetags (#25873)

The expression "&$" will work as expected, yes. If it turns out that the form you described with "(u8*)0,size" is used often enough (nice idea btw), we could come up with some syntactic sugar or pseudo-variable to make it easier to type / remember.

42 posts
Feature Suggestion: Loop syntax in the Watch window...
Replying to x13pixels (#25874)

Awesome!