The recursion learning exercise says that ‘the recursive modifier’ can be added to a word if the compiler has trouble inferring the stack effect.
The term for a word like recursive that trails a word definition is a compiler declaration. The compiler never has trouble inferring stack effects. recursive is simply a requirement for any inline word that calls itself. Commonly this means any recursive word that takes a quotation and calls it. This is how words like map and each are ultimately defined.
I am not sure how easy this is to fix or if I am doing something wrong, but the error reporting is currently pretty bad. I just see an error like this: T{ slice-error { from 0 } { to -1 } { seq { } } } with no line numbers, no context, nothing.
This error you saw is what the compiler actually produces, it is a word.
exchange-money takes 2 values on the stack. You drop those 2 values with 2drop, then push f and use rest, which expects a sequence, drops its first element and returns its tail.
rest is partial, it errors on an empty sequence, which is the case with f.
:) Yes I am aware, I specifically made this simple example to produce a simple error. The specific error is not the problem (nor is it the actual error that prompted me to post here), the problem is that the error is displayed without any additional information, making it hard to track down where it came from.
For example, running a simple program with an error on my CLI locally, I get a stack trace, telling me that the problem originated from a word called bla :
Cannot create slice: from > to
from 1
to 0
seq f
(U) [ c-to-factor => ]
c-to-factor
(U) [ [ (get-catchstack) push ] dip call => (get-catchstack) pop* ]
(O) command-line-startup
(O) run-script
(O) bla
(O) subseq-as
(O) slice-error
(O) M\ object throw
(U) [
OBJ-CURRENT-THREAD special-object error-thread set-global
current-continuation => error-continuation set-global
[ original-error set-global ] [ rethrow ] bi
]
I would like the error reporting on here to provide some similar information.
Rename binary-search to binary-chop or something like that. Delete the .meta/generator.jl
Note this breaks the connection with the canonical problem specification, so any future introduction changes or new test cases would need to be synced manually.
The Grade School exercise is confusing. The tests are doing something uncharacteristically clever that makes it hard to tell what is expected, and the task description is vague.
It’s the only exercise that I have trouble understanding.