List manipulation enhancements

Some ideas for enhancing List manipulation partly in response to List Concatenation of different types.
Please feel free to give feedback.

List expansion operator

You would put a percent sign % before a list which would treat the list as individual arguments.

For example:

!nums: {1 2 3}
// same as
number_stuff(nums{0} nums{1} nums{2})
// or more simply
number_stuff(1 2 3)

So in your situation (post mentioned above) you could use the following:

// This would have the item type <BP_LapProgress|BP_RacingPowerup>
{%BP_LapProgress.instances %BP_RacingPowerup.instances}
// rather than
[Actor{} += BP_LapProgress.instances] += BP_RacingPowerup.instances

Which would be fairly concise and still take typing in account.

However, I’m not even sure if this would be possible - there are many hurdles with the complier that would need to be overcome to get it to work.

Thinking about it though. :madsci:

Argument based List generic types

Alternatively, we could create more sophisticated generic classes in addition to ItemType_ such as UnionArg_#1 that would make a union of the current item type and the item type of parameters. Then we could make the list add(), +, add_assign(), +=, etc. methods more sophisticated so that adding any list or object would just expand a list’s item type to include the new item type.

So you could just add any lists together as you originally expected:

// This would have the item type <BP_LapProgress|BP_RacingPowerup>
BP_LapProgress.instances + BP_RacingPowerup.instances

Which would be as concise as possible and still take typing into account.

The only issue would be accidentally adding an item type that you don’t want or expect might not be detected by the compiler.

After some more use and thought on this, I can’t immediately see the usefulness (in my own work) for constructing lists of mixed types. At least when interfacing with :ue4:, all of the engine functions that take or return lists tend to work with lists of AActor. So the general workflow is to get a list of actors and then cast down and do what you need.

I’m fine with this same workflow in :sk:, my initial problem was constructing a list with the common denominator base type. The List expansion operator looks cool and I’m sure if it were in there I’d look up this post to dazzle myself with some shorthand, but it’s not bad as-is:

[Controller{} += PC_TabletopRacing.instances] += AI_Car.instances // I know exactly what this does 

I’m trying to imagine a scenario where you could make a really cool use of lists of mixed types by calling similar methods across a variety of classes but can’t think of anything that interfaces wouldn’t also cover. I’d love to hear other thoughts on scenarios where this might shine.

1 Like