Home > Community > Forums > Custom IC SKILL > Help with Closures with skill++

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: *

 Help with Closures with skill++ 

Last post Thu, Feb 7 2013 10:48 AM by VinceV. 2 replies.
Started by VinceV 07 Feb 2013 10:03 AM. Topic has 2 replies and 618 views
Page 1 of 1 (3 items)
Sort Posts:
  • Thu, Feb 7 2013 10:03 AM

    • VinceV
    • Not Ranked
    • Joined on Thu, Feb 7 2013
    • Posts 2
    • Points 25
    Help with Closures with skill++ Reply
    Need some help with closure using skill++. The below code loads fine in interactive mode but when I run it I get the error
     E- *Error* eval: not a function-1. Not sure how to debug this, any help would be appreciated. I am using this from Allegro
    did not see much of any reference to Skill++ there so I thought I would post here since it is a general Skill++ question.
    It seems like it is counting (see the commands below the code).
     
    Thanks,
    Vince 
     
    (define (makecounters)
    (let ((vcount 0))
        (lambda ()
          (setq( vcount (vcount + 1) ))
          vcount)))
     
    (define cntBy1 (makecounters))
     
     
     
    Skill > load "test.ils"
    variable makecounters redefined
    t
    ILS-<5> 
    Skill > cntBy1
    ILS-<5> 
    E- *Error* eval: not a function - 1
    Skill > cntBy1
    ILS-<5> 
    E- *Error* eval: not a function - 2
    Skill > cntBy1
    ILS-<5> 
    E- *Error* eval: not a function - 3
    Skill > cntBy1
    ILS-<5> 
    E- *Error* eval: not a function - 4
    Skill > 
    • Post Points: 20
  • Thu, Feb 7 2013 10:39 AM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,593
    • Points 16,035
    Re: Help with Closures with skill++ Reply

    Hi Vince,

    It seems you have too many parentheses for your setq statement?  Try this:

    
    (define (makecounters)
    (let ((vcount 0))
        (lambda ()
          (setq vcount (vcount + 1) )
          vcount)))
     
    (define cntBy1 (makecounters))
    

    I tested this briefly and it seems to work correctly now.

    Regards,

    Lawrence.

    • Post Points: 20
  • Thu, Feb 7 2013 10:48 AM

    • VinceV
    • Not Ranked
    • Joined on Thu, Feb 7 2013
    • Posts 2
    • Points 25
    Re: Help with Closures with skill++ Reply

    Thanks Lawrence that resolved the issue.

     Vince 

     

    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by VinceV at 07 Feb 2013 10:03 AM. Topic has 2 replies.