• Nathan (unregistered) in reply to haod
    haod:
    Anonymous:
    Anonymous:

    OMG - when will they start teaching recursion?

    Does Visual Basic even support recursion?

    Sure. Every time I see VB code I curse. Curse, curse again, recurse...

    Here's some more, then:

    http://www.microsoft.com/technet/scriptcenter/guide/sas_vbs_kove.mspx

    Cheers,

    Nathan

  • (cs) in reply to Gene Wirchenko

    Gene Wirchenko:
    Anonymous:
    OMG - when will they start teaching recursion?


    In my diploma program, they deliberately omitted it.  Given the time constraints, I might well have done the same.  I have used recursion a couple of times, but have not found it that useful for what I do.  Obviously, YMMV.

    At least, they did not teach with that stupid factorial example.

    Sincerely,

    Gene Wirchenko

    Recursion (unlike, say, iteration) is a fundamentally important construct.  It's also conceptually simple.  How can they not teach it?  It should also arise as a natural consequence of other essential teachings (for example, traversing trees is naturally recursive).

     

  • Ibiwan (unregistered) in reply to steve
    Anonymous:

    OMG - when will they start teaching recursion?



    ...as soon as they start teaching recursion!
  • EVOL_HEL (unregistered) in reply to BizTalk
    Anonymous:
    Anonymous:
    Nobody needs more than 640 KB of RAM^H^H^H^H^H^H^H^H^H^H^H^H^H 60 levels of depth!  (I count 69 not 59 Parents as well)

    And for-loops are for the typing-endurance-challenged.


    lol omg wtf pwned..
     
     you actually counted that shit up dude?

    man get to work slacker jesus christ.

     :)

    woot null captcha!


    No way did he count it up!  He wrote a recursive function to count it for him.
  • (cs) in reply to DrPizza
    DrPizza:
    Gene Wirchenko:
    Anonymous:
    OMG - when will they start teaching recursion?

    In my diploma program, they deliberately omitted it.  Given the time constraints, I might well have done the same.  I have used recursion a couple of times, but have not found it that useful for what I do.  Obviously, YMMV.

    At least, they did not teach with that stupid factorial example.

    Recursion (unlike, say, iteration) is a fundamentally important construct.  It's also conceptually simple.  How can they not teach it?  It should also arise as a natural consequence of other essential teachings (for example, traversing trees is naturally recursive).

    Conceptually simple, but many have trouble getting it straight.  Tree traversal was not something we got into.

    Sincerely,

    Gene Wirchenko


  • Andrey (unregistered) in reply to Richard Nixon
    Richard Nixon:
    Useful for what you do? And that phrase is what separates those who understand what a college degree should be about from those who are just plodding along and getting in the way. A college degree is not job training. Just because you may not use recursion often, it is a core fundamental of Computer Science and should be taught.

    If you think your "diploma program" should have only covered the set of tools you'd need to function in a job, you were looking for a certificate from ITT Tech, not an honest-to-goodness college degree.

    It's scary how people are so disgusted with the idea of learning for the sake of learning.

    sincerely,
    Richard Nixon


    Disgusted?  Hardly.  Aware of the fact that even entry-level jobs require a very specific skillset and the fact that most employers don't care for on-the-job learning?  Hell yeah.  I'm almost done with my CS degree, and sometimes it's scary how many things ARE left out for the sake of PC nonsense classes.
  • blitz303 (unregistered) in reply to GoatCheez

    Alright, I think we all need to retake a lesson in logic class.  While most here blaber on about iteration being more efficient than recursion and offer equivalent algorithms in C, few are reading the code correctly.  At first, I admit based on looking at it, the algorithm seems to warent a recursive solution, but OneMHz and W above him are right. The code reads :

      If Not objNode.Parent Is Nothing Then
    GetNestingLevel = 0
    ElseIf objNode.Parent.Parent Is Nothing Then
    GetNestingLevel = 1
    ElseIf objNode.Parent.Parent.Parent Is Nothing Then
    GetNestingLevel = 2
    etc.  What I misread and I think everyone is misreading is the Not in front of the objNode.Parent is Nothing (if you did catch it, you are probably just going on the assumption that the function is supposed to do something useful, like counting the depth of a node in a tree).  If Nothing means what I think it means (read VBspeak for NULL), then the ElseIf blocks are exectued when objNode.Parent Is Nothing (objNode.Parent == NULL).  Because objNode.Parent is Nothing, objNode.Parent.Parent is Nothing as well.  I don't really know VB too well, but assuming this to be the case, every elseif evaluates to false, so the only two blocks to ever see execution are the first and last.  Thus W's code is equivalent, and everyone else's isn't.  Please let me know if I'm wrong, which is probably the case, seeing as how so many of you want to offer recursive/iterative solutions.  Also, I don't know the true meaning of Nothing in VB, this is all based on the above assumption. 
  • (cs) in reply to blitz303
    Anonymous:
    Alright, I think we all need to retake a lesson in logic class.  While most here blaber on about iteration being more efficient than recursion and offer equivalent algorithms in C, few are reading the code correctly.  At first, I admit based on looking at it, the algorithm seems to warent a recursive solution, but OneMHz and W above him are right. The code reads :

      If Not objNode.Parent Is Nothing Then
    GetNestingLevel = 0
    ElseIf objNode.Parent.Parent Is Nothing Then
    GetNestingLevel = 1
    ElseIf objNode.Parent.Parent.Parent Is Nothing Then
    GetNestingLevel = 2
    etc.  What I misread and I think everyone is misreading is the Not in front of the objNode.Parent is Nothing (if you did catch it, you are probably just going on the assumption that the function is supposed to do something useful, like counting the depth of a node in a tree).  If Nothing means what I think it means (read VBspeak for NULL), then the ElseIf blocks are exectued when objNode.Parent Is Nothing (objNode.Parent == NULL).  Because objNode.Parent is Nothing, objNode.Parent.Parent is Nothing as well.  I don't really know VB too well, but assuming this to be the case, every elseif evaluates to false, so the only two blocks to ever see execution are the first and last.  Thus W's code is equivalent, and everyone else's isn't.  Please let me know if I'm wrong, which is probably the case, seeing as how so many of you want to offer recursive/iterative solutions.  Also, I don't know the true meaning of Nothing in VB, this is all based on the above assumption. 

    Your understanding of VB's meaning of nothing is correct.  Your understanding of how this whole obscene block of craptastic VB-ness won't work as intended (double-WTF or mistake in anonymization?  who knows) is also correct.

    However, you're a bit late.  I think your point of it only hitting the first and last blocks was originally pointed out on page 2 ...

    But, I might be wrong.
  • (cs) in reply to Sgt. Zim
    Sgt. Zim:
    Your understanding of VB's meaning of nothing is correct.  Your understanding of how this whole obscene block of craptastic VB-ness won't work as intended (double-WTF or mistake in anonymization?  who knows) is also correct.


    But do look it up anyway.  VB6's documentation for nothing, oops, Nothing was quite entertaining.

    "What are you reading?"  "Nothing."

    Sincerely,

    Gene Wirchenko

  • (cs) in reply to Gene Wirchenko
    Gene Wirchenko:
    VB6's documentation for nothing, oops, Nothing was quite entertaining.

    <clue_challenged>
      <sarcasm>
        Ack.  Good point.  I must have unconsciously gotten used to letting VB fix my capitalization for me.
      </sarcasm>
    </clue_challenged>

    Disclaimer:  nothing is to be implied or inferred by my use of <sarcasm /> tags; they are only there for those that are too clue challenged to correctly implement a sarcasm detector, or, having a sarcasm detector, do not have its sensitivity set high enough.

    Pre-post edit: Is this ability to use bbcode new to CS2?  I don't seem to remember it before.  Or, maybe it was just masked by the general WTF-ness of CS1.  Oh, yeah, I use that evil firefox thingy.
  • (cs) in reply to Bubu

    Anonymous:
    "I'm glad you're not my colleague."

    Me too ;-)

    If there is time for rewriting ugly but working code - I'm with you. It should be done.

    But we really don't know how this piece evolved - maybe there've been much more if/then/else special-clauses in the meantime - and only the one posted survived... Who knows ?

    Fact 1: it's working.
    Fact 2: Out of purely aesthetic reasons you'd demand to fix it
    Fact 3: This /only/ makes sense if you really don't have any points of more importance on your todo-list...
    Fact 4: We don't know if this piece of code is very "volatile"... If there are changes to this piece on a daily/weekly basis, I'd still leave it as it is..
    Fact 5: If this piece - thrown out of it's context - is the one-and-only-really-big-WTF in the company - then it's a superb one ;-)

    P.S. 'And, BTW, it's "surely"' - thanks for the correction... haven't been writing in english for about 17 years - so many things have slipped my memory...

    Fact 1: It doesn't work (well actually I don't have the spec, but based on the evidence this thing doesn't work)

    Fact 2: It has nothing to do with aesthetics... It has to do with maintainability (refer to Fact 1)

    Someone mentioned they could see how this would happen. It started off with well we have no more than 4 parents and a special case, on day 2 they added on 5 parents, etc... Yeah sorry I don't but it. If I thought it had only 4 parents I still would have written a loop. Or if I came in at day x (where x > 5) I would have rewritten it correctly. Shorter more "aesthetic" code is usually easier to maintain.

  • LordJaxom (unregistered) in reply to GoatCheez
    GoatCheez:
    Better question would be what DOESN'T support recursion. Recursion isn't a language feature, it's a programming method. If a language has what we all call functions, then you can recurse.


    Actually, COBOL (at least up to COBOL85) did support functions, but not recursion.
  • Bubu (unregistered) in reply to chrismcb

    "Fact 1: It doesn't work (well actually I don't have the spec, but based on the evidence this thing doesn't work)"
    Well, as much as I could extract from the beginning Statement
    "He asked the team submit what they felt were the latest and greatest code they've written" - I think that it worked... I assume it had to return "0" if it's a child-Node... "60" Otherwise ;-)... And because they surely presented some Code that worked - I think it's some /very volatile/ part of code... Like otherwise encapsulated in many "if(1=0)"-Blocks... And I assume, that there have been many other parts of "business logic" packed in this function in the meantime.

    Fact 2: It has nothing to do with aesthetics... It has to do with maintainability (refer to Fact 1)
    You are /generally/ right... for shure.
    But some special cases do exists, where one would say "WTF" at the first impression - but "I understand" when knowing the backgrounds.

    "Someone mentioned they could see how this would happen. It started off with well we have no more than 4 parents and a special case, on day 2 they added on 5 parents, etc... Yeah sorry I don't but it. If I thought it had only 4 parents I still would have written a loop. Or if I came in at day x (where x > 5) I would have rewritten it correctly. Shorter more "aesthetic" code is usually easier to maintain."

    You are right again... There are only 10b solutions - iterating or recursion. So the one and only chance, why they did it like this is IMHO that they solved it per recursion/iteration - but had to change the implementation for new business logic every 10 minutes or so... so that they fell back to "make 100 if's and if somebody wants something new in 10 minutes - something like "If there are exactly 43 parents and my objectid=12345 - then return 24 - but don't do too many checks for parents"...

    Or maybe they just wanted to ensure a sleepless night for the new IT-Manager... Something like a bad joke ;-)

  • (cs)

    How date subtraction should work may depend on your problem domain. I used to work with a bank loan application and each customer had its own set of rules how to calculate date subtraction. For example that the difference between two last day of month was always a multiple of 30, so Feb 28 - Jan 31 should be 30, even though its 28 days inbetween. We had a date math library with different methods depending on how it should be done.

  • bimbo69 (unregistered) in reply to steve
    Anonymous:

    OMG - when will they start teaching recursion?

     

    the recursion here would be another WTF.. a minor one

  • (cs) in reply to Gene Wirchenko

    Then may I ask, what was this diploma you did?

    If it didn't cover basic data structures or fundamental concepts?

     

  • bimbo69 (unregistered) in reply to DrPizza
    DrPizza:

    Then may I ask, what was this diploma you did?

    If it didn't cover basic data structures or fundamental concepts?

    KFC college ... of course ...

    ---

    captcha text = STFU !

  • Morat (unregistered) in reply to GoatCheez
    GoatCheez:

    I agree with this being a major WTF, but it does appear that it isn't as straight-forward as it appears. The line that checks the Node's ID pretty much explains why. For some reason, certain nodes with certain IDs report their nesting level differently than the non-special nodes.


    Test for the special cases first in a switch-style statement and the do the loop or recursion for the normal cases. Unless (horror) the special cases can be normal at different depths in the hierachy :O
  • (cs) in reply to adwadwawda
    Anonymous:
    Anonymous:
    Bus Raker:

    Anonymous:
    Take note: This is what happens when an employer advertises for "CS degree or equivalent". If someone doesn't have a CS degree, they better be able to show you an outstanding portfolio of past work.

    Well, if they have a CS degree, they should be hired and paid 6 figures without looking at anything.



    It used be the case in the 90s.  Anyone who knew how to turn a computer on could walk into any company and get hired on the spot.  Now, a CS degree is nearly worthless without relevant work exp in the field.
    I used to sell my assignments to other CS students.  They'd come up to me, actually crying, because they couldn't understand programming at even the most fundamental level.
     
    Paid my tuition that way.


    it's your fault this site exists.
  • (cs) in reply to tster
    tster:
    Anonymous:
    Anonymous:
    Bus Raker:

    Anonymous:
    Take note: This is what happens when an employer advertises for "CS degree or equivalent". If someone doesn't have a CS degree, they better be able to show you an outstanding portfolio of past work.

    Well, if they have a CS degree, they should be hired and paid 6 figures without looking at anything.


    It used be the case in the 90s.  Anyone who knew how to turn a computer on could walk into any company and get hired on the spot.  Now, a CS degree is nearly worthless without relevant work exp in the field.

    I used to sell my assignments to other CS students.  They'd come up to me, actually crying, because they couldn't understand programming at even the most fundamental level.
     
    Paid my tuition that way.


    it's your fault this site exists.


    His and CPound's.
  • (cs) in reply to Suffer
    Anonymous:
    Anonymous:

    Fuck, I didn't know you could get a degree in Counter Strike

    A lot of students graduate that don't know the most basic programming principles, but they do have a *lot* of creativity in solving programming problems in the most unimaginable ways. Some of them aren't even really interested in writing software (and they are the ones that get employed at a company, start writing their enterprisy application from crap, eh scratch, and afterwards we have the joy of maintaining it).

    Plus the whole load of elderly people that write their super duper software in Access and then try finding a professional to maintain and extend it (by sending us letters reading "Skills needed: MS Access, VB Script, blahblah more stuff that isn't relevant).

    Plus all the say.. 28+ year olds that don't even know OO exists, yet they try to mimic it vaguely by using an "ancestor" once in a while.

    I'm in hell.


    Okay, so you claim the recent graduates (say 21-22?) don't know basic programming principles, and also the old farts (28+ LOL) don't know OO exists.  Wow, you must be that PERFECT age of 23-27???  That brillant age group that singlehandedly invented OO, recursion, and The Interwebs??? LOL the WTF is YOU.  Get a clue, freak, I know people over 40 that were doing OO whilst you were busy soiling your diapers, and could still pwn you in that and CS.

    I'm tired, so I don't read all posts before I quote this... But... If the post you quoted wasn't meant to be ironic, I'll be... Dunno, really, but I'd be very surprised... And that exact figure of 28 should be a giveaway too... Or? WTF???

    Hang on... Was YOUR quote also to read ironically? WTF!!!
  • (cs) in reply to Marcelo
    Anonymous:
        Having a Degree means nothing. At the most, it means that if you are and idiot, you are an gradutated idiot.

    I haven´t got a degree and I code circles around most gradutated devs around. Been doing this for the last 12 years too.

    No one else found this funny :)
  • (cs) in reply to John Hensley
    Anonymous:
    Take note: This is what happens when an employer advertises for "CS degree or equivalent". If someone doesn't have a CS degree, they better be able to show you an outstanding portfolio of past work.

    Horse pucky!  I do not have a CS degree and can code rings around some of my peers that do.
  • John (unregistered)

    If looping was a flathead screwdriver, and recursion was a phillips head screwdriver; this developer used a hammer.

  • Tim, or Tim (unregistered)

    I once wrote an iterative code block to return the depth of a node in a B-tree.  Once.

  • Tim, or Tim (unregistered) in reply to gizmo

    Computer Science degrees ensure that the code block above is written the exact same way, but with lots more comments.  Why, I could rewrite this using Java Struts, Actuate, BIRT, a couple of beans, MONO, C#, an ActiveX control and some model cement glue and I don't have a CS degree...

  • (cs) in reply to beliar
    beliar:
    Anonymous:

    I find it interesting that everyone is making a lot of assumptions about how this is "supposed" to work when they re-write it.

    Maybe the tree is not allowed to go more than 60 levels deep.  Maybe a circular loop of somekind *is* allowed.  If that's the case, then we've got a lot of people writing infinite loops here.

    Public Function GetNestingLevel(objNode As Node, maxRecursion as Integer, RecursionLevel as Integer)
        If RecursionLevel < maxRecursion Then
              RecursionLevel = RecursionLevel +1
             <All other Code>
        End If
    End Function

    (I hope the VB-Code is correct, i haven't wrote VB-Code for years)

    No problem with that...

    I'll do you one better...


    Public Function GetNestingLevel(<Parameter list>)
    <Body of the entire function>
    End Function

    That was easy. Fall into the GAP.

  • (cs) in reply to GoatCheez
    GoatCheez:

    Better question would be what DOESN'T support recursion. Recursion isn't a language feature, it's a programming method. If a language has what we all call functions, then you can recurse.

    That's not true. It needs some support on the language side (specifically, it needs a stack, or else some sort of RISC-y register windowing thing), and historically some languages didn't support it. (Don't think qbasic did).

  • (cs) in reply to IRRePRESSible
    Anonymous:
    ElseIf objNode.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent Is Nothing Then


    You know, when you stare at it long enough, it stops looking like code.
  • SeHE (unregistered) in reply to Maxim

    Better question would be what DOESN'T support recursion. Recursion isn't a language feature, it's a programming method. If a language has what we all call functions, then you can recurse.

    But if the programmer doesn't support the language feature... then you can only CURSE

  • SeHE (unregistered) in reply to YourName

    If you are using a compiler that has achieved self-awareness, you sir are using a much better compiler than I.

    I recall someone telling me that some C++ (Edison?) compiler acutally sais:

    "The compiler was unable to detect any of your errors"

    instead of the more usual

    "Compiled with 0 errors and 0 warnings"

    Compilers may be getting there :)

  • SeHE (unregistered) in reply to Bruce Hoult

    And there is nothing simple about iteration okay so what is complex about doing the same thing again

  • Lorad (unregistered) in reply to Xocomil

    The function does not even work because of the

    "If Not objNode.Parent is Nothing" - if there is a parent return 0. If there is no parent then thing is going to throw an exception. So all that code and it either returns 0 or throws an exception or causes an error if VB6.

  • Alex (unregistered) in reply to Manni
    Manni:

    But yeah, VB goes out of stack space pretty easily when you're talking about recursion. Use it for integers and stuff, not for objects being passed ByVal.

     

    Objects passed ByVal are reference pointers, which makes the parameters essentially just.... Integers!  ;-)

  • DreamingAngel (unregistered) in reply to Bus Raker

    Boy, looks like I have stepped into the wrong site! The reading was definetly interesting though, thanks all!! Why again is this site named living with parents????

  • (cs) in reply to Ranma64

    Ranma64:

    10 PRINT "CAN ANCIENT BASIC RECURSE"
    15 REM I THINK YOU COULD ARGUE THIS IS RECURSION WITH NO STACK
    20 GOTO 20

     

     

    what happened if BASIC was typed in lower case?

  • (cs) in reply to bimbo69
    Anonymous:
    Anonymous:

    OMG - when will they start teaching recursion?

     

    the recursion here would be another WTF.. a minor one

    May I ask why? recursion would lead to an easy to read and trivial to debug code here.

  • (cs) in reply to Gunther VB
    Anonymous:

    Plus all the say.. 28+ year olds that don't even know OO exists, yet they try to mimic it vaguely by using an "ancestor" once in a while.

    I'm in hell.



    28, and that was the focus of my entire Computer Science degree--OOP using C++.

    Of course, right after I graduated they switched to Java, which would've been far more useful to me in the long run.  That's the problem with universities; they can't keep up with the pace of modern technology.  My networking class used Novell Software on a Windows 3.1 computer, and my Java class was trying to run JDeveloper on Pentium 75s.  It was baaaaaad....
  • (cs) in reply to dhromed
    dhromed:
    Anonymous:
    ElseIf objNode.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent. _
    Parent.Parent.Parent.Parent.Parent.Parent.Parent Is Nothing Then


    You know, when you stare at it long enough, it stops looking like code.


    That is apPARENTly so...

  • Kuba (unregistered) in reply to GoatCheez
    GoatCheez:
    Anonymous:
    Anonymous:
    OMG - when will they start teaching recursion?

    Does Visual Basic even support recursion?

    Better question would be what DOESN'T support recursion. Recursion isn't a language feature, it's a programming method. If a language has what we all call functions, then you can recurse.

    You generalize and what you said doesn't even apply to C. On Z8 Encore! (an 8 bit micro from Zilog), their C compiler supports static frames (for speed). If your project has static frames enabed, then no recursion is possible since once you enter a function, the frame that holds all the automatics (parameters and locals) has already been allocated at a fixed position by the linker, which analyzes the call tree to determine what can overlap with what else. In such a case, you have to declare the function as recursive in order to have it use dynamic (stack-allocated) frames. Like this:

    void test1(unsigned int n) {
      if (n) test1(n-1);
    }
    
    void recursive test2(unsigned int n) {
      if (n) test2(n-1);
    }
    

    The first one will give a linker warning (a WTF in itself -- should be an error) if you use static frames, the second one won't (and will actually work).

    TRWTF is that Zilog's tools don't do any tail-recursion detection/optimization :( Heck, they occasionally generate incorrect assembly for quite "benign" code. But hey! - the tools are free as in beer... sobs...

    Cheers!

  • (cs) in reply to BlueRose

    Stupid errors...

Leave a comment on “Living With Parents”

Log In or post as a guest

Replying to comment #:

« Return to Article