Example error:
;The procedure car has been called with 4 arguments; it requires exactly 1 argument. ;To continue, call RESTART with an option number: ; (RESTART 1) => Return to read-eval-print level 1.
The usual problem is passing a Gunk procedure out to an ordinary higher-order Scheme procedure, e.g. map. The simulator tells you when it decides that it must use an ordinary procedure. You can check the warnings to see if any of them are higher order.
There is one other case which is a bit unfortunate, but avoidable. Some primitive procedures in non-operator position are integrated because of the usual-integrations declaration. Currently HLSIM does not realize that the primitive procedure needs to be cps-converted too. It treats it like any other literal, e.g. 42.
There are very few of these procedures which are useful like this, but car is one of them. Example Gunk program:
(define (make-point x y) (list x y)) (define point-x car)
When you call point-x you will get the error above. One fix is to -convert:
(define (point-x pt) (car pt))
I could make cps do this transformation automatically in the case of car but it would cause different references to car to no longer be eq?.
Another fix is to define the data-structure (point-x etc.) as an ordinary Scheme program, i.e. in a separate file and load that file with load rather than simulation.load. I prefer the -conversion fix.