Good post. Def would say "look at the generated code". This is what i got: 
    
    
    proc fillWith(n, count: int): seq[int] =
      var s: seq[int] = @[]
      for i in countup(0, count - 1):
        s.add(n)
      
      return s
    
    proc main =
      let counter = fillWith(7, 3)
      echo counter
    
    main()
    
    
    
    N_NIMCALL(TY95007*, fillwith_95003_3831700988)(NI n0, NI count0) {
            // Define vvv
            TY95007* result0;
            TY95007* s0;
            nimfr("fillWith", "test2.nim")
    {   result0 = (TY95007*)0;
            nimln(2, "test2.nim");
            // Create vvv
            s0 = (TY95007*) newSeq((&NTI95007), 0);
            {
                    NI i_95038_3831700988;
                    NI HEX3Atmp_95051_3831700988;
                    NI T3831700988_3;
                    NI res_95054_3831700988;
                    i_95038_3831700988 = (NI)0;
                    HEX3Atmp_95051_3831700988 = (NI)0;
                    nimln(3, "test2.nim");
                    T3831700988_3 = subInt(count0, ((NI) 1));
                    HEX3Atmp_95051_3831700988 = (NI)(T3831700988_3);
                    nimln(1887, "system.nim");
                    res_95054_3831700988 = ((NI) 0);
                    {
                            nimln(1888, "system.nim");
                            while (1) {
                                    NI T3831700988_4;
                                    if (!(res_95054_3831700988 <= 
HEX3Atmp_95051_3831700988)) goto LA3;
                                    nimln(1889, "system.nim");
                                    i_95038_3831700988 = res_95054_3831700988;
                                    nimln(4, "test2.nim");
                                    // Add vvv
                                    s0 = (TY95007*) incrSeqV2(&(s0)->Sup, 
sizeof(NI));
                                    s0->data[s0->Sup.len] = n0;
                                    ++s0->Sup.len;
                                    nimln(1903, "system.nim");
                                    T3831700988_4 = 
addInt(res_95054_3831700988, ((NI) 1));
                                    res_95054_3831700988 = (NI)(T3831700988_4);
                            } LA3: ;
                    }
            }
            nimln(6, "test2.nim");
            // Assign to result. Does it allocate a new seq?
            genericSeqAssign((&result0), s0, (&NTI95007));
            goto BeforeRet;
            }BeforeRet: ;
            popFrame();
            // Return vvv
            return result0;
    }
    
    N_NIMCALL(void, main_95058_3831700988)(void) {
            TY95007* counter0;
            NimStringDesc* LOC1;
            nimfr("main", "test2.nim")
            nimln(9, "test2.nim");
            counter0 = fillwith_95003_3831700988(((NI) 7), ((NI) 3));
            nimln(10, "test2.nim");
            LOC1 = (NimStringDesc*)0;
            LOC1 = HEX24_95062_1689653243(counter0);
            printf("%s\015\012", LOC1? (LOC1)->data:"nil");
            fflush(stdout);
            popFrame();
    }
    

Reply via email to