need something like static counter (within a row) in Calc formula

I have a formula in LibreOffice Calc and now I find the way (if possible) to do something as

=some_function(… + super_counter() + … super_counter()… )

where “a super_counter() function” will return the incremented value for each of its occurrence in some_function(), starting at 1 (and reset for each new row in sheet).

Can be it possible without using macro?

return the incremented value each time

incremented depending on what and why + ... + ... +. For me its unclear, how the argument of some_function() should look like depending on column and row of the cell where some_function() is being used (just my gut tells me, that you may look for functions ROW() and COLUMN() to construct a proper index).

incremented depending just on the number of its occurrence in 1 row (regardless of the number of cells in which was executed, in general - =some_function() used once to simplify)

Probably doable by a few different approaches, e.g. by creating a dummy formula and use some COUNTIF(FIND(x;FORMULA(... construct. A cleaner and more portable solution may be possible, perhaps without creating a new function. Could you explain why you need this? What is it you want to achieve?

well, I haven’t experience how to create a formula in Calc.
my goal is to have something like a static variable in programming languges - but that will be reseted for each new row in sheet. for portability (which should be so I rejected idea with macros) - I think it should be some trick with Calc functions, and I called it in general some_function(), because its calls can be nested.