#Is it possible to pass extra parameters into function pointers?

1 messages · Page 1 of 1 (latest)

atomic prairie
#

E.G if there is a delegate bool public delegate bool CheckPair(int point,int pos,int scale);
public static bool Block(int point,int pos,int scale) => (point >= pos && point < pos + scale);
could another function have an extra parameter such as e.g. int noiseValue added to it?

frigid cobalt
#

no, it's strongly fixed by declaration of delegate

#

also, judging from names of example it looks like you plan to burst compile such little methods

#

if that's the case I heavily advice against it, because cost of calling function pointers is pretty high

atomic prairie
#

thats true. have noticed the heavy dip in performance delegates have

atomic prairie
frigid cobalt
#

write all your logic normally

#

also have only one entry point

#

basically, do prep work in managed context

#

pass that data to burst compiled method

atomic prairie
frigid cobalt
#

get data back

frigid cobalt
#

so write everything using all C# power (in burst compatible manner ofc)

atomic prairie
#

right i see

#

and what if i need the function(s) to be modular in a class?

frigid cobalt
#

you don't have classes in burst

atomic prairie
#

sorry i mean struct

frigid cobalt
#

I don't get the question

atomic prairie
#

public static bool Block(int point,int pos,int scale) => (point >= pos && point < pos + scale); is used to check wether a point is inside or outside a given area

#

but it would be useful if this was dynamic so i could check if something is inside a sphere etc.

#

and this is done around 500 or so times checking different points

frigid cobalt
#

then write different method for that

atomic prairie
#

yes but then how could i put this in the same native array for example

frigid cobalt
#

it heavily depends on what you are doing

#

but the way I see it

#

you are trying to force object oriented practice here

#

it might work, or it might not work depending on context

#

but you probably should just rethink design

atomic prairie
#

i see