Is there a reason for SolidParticle id type to be a number?

Looking at SPS documentation I was just wondering if there is a reason for particle id to be a number? Both idx and idxInShape make perfect sense but id?

Is there a reason it has to be of a number type?

i don’t think so and it should be safe to assume we can use it as a string as well

Adding @jerome to confirm

@Deltakosh / @jerome I am happy to take a look but might have to ping some questions abound. Also… that would be “breaking change” :thinking: Would require minor adjustment in existing projects that use it as number. I don’t think it’s a big one but we should keep that in mind.

@MarkBevels
i think @Deltakosh ment that it should be safe for You to change it to a string within your project :slight_smile:
not change it in the source

Oh… I see. Still, If it is possible and safe for it to be a string, at least we should adjust the type. Otherwise type is a lie. :man_judge: Will test this locally this morning.

The particle id can be used as a String in your code as you want.
It’s an integer in the SPS because it’s historically a counter and it’s used as is in many internal and custom processes with computations or numeric comparisons made on it.
I would not recommend to change it in the SPS code unless you want to undertake a heavy refactor :wink:

Problem is type conflict. In my own project I ended up with a Map<string, number> to pair up index with id. I do consider using // @ts-ignore a bad practice and try to avoid unnecessary casting. I would be happy to try refactoring as long as everyone is happy to accept the change. Always happy to help to improve where I can. That being said, last thing we wont is someone spending days on refactoring to have change discarded because “it wasn’t worth it”. :smiley: :laughing:

So… is that’s something worth considering? @jerome / @Deltakosh

I think this little change would probably be a painful breaking change everywhere people wrote someArray[particle.id] in their code…
No idea about how many LOC and how many PG could be impacted though.

So I can’t tell wheter it’s worth it or not. Sincerely no idea…

Thanks! and fair enough. It seems risk is a bit too high. Marking your question as resolved for now.

EDIT:
fixing typos. Me no speak good English. :rofl:

2 Likes