Home > Community > Forums > PCB SKILL > sklint question

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 sklint question 

Last post Tue, Oct 7 2008 2:26 PM by pcbgeorge. 2 replies.
Started by pcbgeorge 07 Oct 2008 01:49 PM. Topic has 2 replies and 2192 views
Page 1 of 1 (3 items)
Sort Posts:
  • Tue, Oct 7 2008 1:49 PM

    • pcbgeorge
    • Top 500 Contributor
    • Joined on Wed, Oct 1 2008
    • Beaverton, OR
    • Posts 32
    • Points 500
    sklint question Reply

    I have just started using sklint to try to find errors or less than efficient code.  I have a couple questions to anyone that knows it's ins and outs:

    I keep getting a WARN (VAR16) telling me that the declaration of a variable has been superceeded when the variable was declared as local (using a let or prog).  Does this mean a variable in a "for" block is automatically local to that "for" block?  Or is it just an error in sklint and it should still be declared as local?

    As an example, I get the warning "declaration of variable i supercedes previous declaration when I run this snippett through sklint:

    (let (i)
      (for i 1 10
        (printf "%s\n" i)
      )
    )

    To add insult to injury, it only gives me an IQ score of 80, even though I am following programming methods!!! :)

    Thanks in Advance :)

    • Post Points: 20
  • Tue, Oct 7 2008 1:59 PM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,569
    • Points 15,600
    Re: sklint question Reply

     Hi,

     The "loop" variable in a for loop does not need to be explicitly declared in a let statement since it is implicitly declared as a local variable within the scope of the for command.  The same applies to foreach, setof, forall and exists statements.So in this case, sklint warns that the "i" in the let is not needed (or if it is used elsewhere, it is not the same as the "i" within the scope of the for command). The i in the for loop is distinct from the i of the let statement.

    In your case, you do not need to declare i in the let statement, and this should get you back towards a score of 100.

    Regards,

    Lawrence.

    • Post Points: 5
  • Tue, Oct 7 2008 2:26 PM

    • pcbgeorge
    • Top 500 Contributor
    • Joined on Wed, Oct 1 2008
    • Beaverton, OR
    • Posts 32
    • Points 500
    RE: sklint question Reply
    Thanks, Lawrence :)
    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by pcbgeorge at 07 Oct 2008 01:49 PM. Topic has 2 replies.