sourcemod icon indicating copy to clipboard operation
sourcemod copied to clipboard

Change sort optional parameters from Handle to any and update SortFunc1D/2D typedef

Open JoinedSenses opened this issue 2 years ago • 6 comments

  • Change optional parameters from Handle to any; Not seeing any particular reason why they need to exclusively be a Handle.
  • Modify the SortFunc2D typedef.
    • Remove char typedef (char cannot be coerced to any).
    • Change typeset to typedef and make the parameters any instead of int
  • Change Sort(Custom/Func)1D params from int to any

JoinedSenses avatar Apr 10 '22 21:04 JoinedSenses

any and floats aren't friends, since the float operators aren't used if a float is tagged as any. This could cause confusion when sorting float arrays.

Can you add a warning for float arrays?

peace-maker avatar May 04 '22 07:05 peace-maker

any and floats aren't friends, since the float operators aren't used if a float is tagged as any. This could cause confusion when sorting float arrays.

Can you add a warning for float arrays?

This seems like a general sp nuisance not specific to sort stuff that folks should be aware of in general, so I feel like this isn't the best place to put that info, though I don't mind adding a note I suppose.

JoinedSenses avatar May 04 '22 07:05 JoinedSenses

any and floats aren't friends, since the float operators aren't used if a float is tagged as any. This could cause confusion when sorting float arrays.

Can you add a warning for float arrays?

If they're retagged in the function prototype for comparison the correct operator will be used, no?

iirc you can pass in a float[] as any[], and in the comparison accept float type and not any

Headline avatar May 04 '22 08:05 Headline

any and floats aren't friends, since the float operators aren't used if a float is tagged as any. This could cause confusion when sorting float arrays. Can you add a warning for float arrays?

If they're retagged in the function prototype for comparison the correct operator will be used, no?

iirc you can pass in a float[] as any[], and in the comparison accept float type and not any

yep, that is also true

JoinedSenses avatar May 04 '22 09:05 JoinedSenses

My pull request at #1124 is very identical to this apart from mine having optional data param in callbacks. No idea why my PR gets ignored, but this PR could be updated to have SortFunc(1D/2D/ADTArray) without having data param as optional.

FortyTwoFortyTwo avatar Jul 26 '22 20:07 FortyTwoFortyTwo

@asherkin are you still OK with this?

KyleSanderson avatar Mar 30 '23 04:03 KyleSanderson