Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 3191 days ago | link | parent

Most of those errors are saying it can't find a global variable named "stack". That's because when you do (= stack (newSA)), you're creating a global variable called "stack" in Arc but it's called "_stack" in Racket. In your macros, you're generating Racket code that uses the Arc variable name, so it's looking for a "stack" Racket global that doesn't exist. You can potentially fix this in your macros... but why use macros when you already have functions that do what you want? :)

  (= newSA $.newStackArray)
  (= deleteSA $.delete)
  (= pushSA $.pushStackArray)
  (= popSA $.popStackArray)
  (= fullSA? $.fullStackArray)
  (= emptySA? $.emptyStackArray)
  (= displaySA $.displayStackArray)
If you absolutely need macros, then here's a fixed version of pushSA that embeds its arguments as Arc expressions rather than Racket expressions:

  (mac pushSA (stack x)
    `( ($:lambda (stack x)
         (pushStackArray stack x))
       ,stack ,x))
  ; or...
  (mac pushSA (stack x)
    `($.pushStackArray ,stack ,x))
Fixing the others would be similar, but I picked pushSA as an example because it has two arguments.

Finally, I think this line just has a simple typo:

  typo:  (emptytSA? stack)
  fix:   (emptySA? stack)
How far does this get you? I haven't tried your code, and I don't know if this will fix all your problems, but maybe it's a start!


3 points by cthammett 3190 days ago | link

Hey thanks this works great. I just need to fix an easy bug in the C code for pop.

-----