Is this a recursive call?

Startbeitrag von Alexandre Leclerc am 12.02.2010 18:24

Hi All,

In WD14 I have a compiler error saying that the following code is a recursive call. I would like to have your opinions on this. I can't figure out why this is a recursive call.

For me it looks like different objects and a standard "cascading" property assignation.


CBase is class
m_tabMyClasses is array of CBase
PRIVATE
m_sValue is string
END

PROCEDURE p_sNew_proprety()
RESULT m_sValue

PROCEDURE p_sNew_proprety(Value)
m_sValue = Value

FOR i = 1 _TO_ ArrayCount(m_tabMyClasses)
m_tabMyClasses.p_sNew_proprety = Value // recursive call error here
END


Thanks for any help so that I understand my error.

Best regards.

Antworten:

Alexandre,
this part looks recursive to me. I don't know if this is allowed

CBase is class
m_tabMyClasses is array of CBase
END

von Arie - am 12.02.2010 18:34
Hi Arie,

Well, from what I know in other programming languages this is a forward declaration which is alright. (You can add "dynamic" in the declaration but this will not change the problem.)

Thank you for your input.

von Alexandre Leclerc - am 12.02.2010 18:51

Hi Alexandre,

this IS a classic case of recursive call.

- You've got an array of classes - mTabMyClasses[..]

- next you create a procedure - p_sNew_proprety // shouldn't this one be called 'property'?

- btw: creating the procedure a second time is a posting typo, isn't it ?

- and now, WITHIN that procedure you're starting a FOR-TO-END loop and each time you're calling that procedure (= itself !) once again! This is called recursion.

Kind regards,
Guenter


von Jimbo - am 14.02.2010 08:26
Hi Guenter,

In fact this is a class property. This is why I don't see a recursive call problem there.

I must say that to bypass this compiler error I simply gave up using a property and simply made a class member (procedure). In that case the compiler is not complaining about any recursive call. I was surprised because it's the same, but not allowed in a property.

Best regards,
Alexandre

von Alexandre Leclerc - am 16.02.2010 16:12
Hi Alexandre

the problem is that in the second case, the compiler doesn't give the message, not that it's not recursive anymore...

And recursivity is officially NOT supported in wlanguage, due to the crash occurring after (last time I check) 600 stacked calls

Best regards


von Fabrice Harari - am 16.02.2010 20:34
Hi Fabrice, Guenter and Arie,

Thank you for your comment Fabrice. The "stacked calls" wording just tilted my mind. I just got it. I've never "see" recursion like that, but indeed it is recursion: "stacked calls".

A solemn warning to be vigilant. It is strange how sometimes we can see something clearly and at the same time be blind to the exact same thing presented under a different form.

Thank you for all your comments. They were all of help.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 16.02.2010 21:42
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.