Repository navigation
Error msgs? #629
Replies: 2 comments 1 reply
|
Hi ... good find. Not reporting an error as it should is certainly a bug. I will test on your example and solve it, and provide you with a working code for display-board. By quick look at the code I see two errors in code, but I'm usure why it didn't report them. Both of these are changes that happened in last few months and that I mentioned in your issue about outdated docs. |
|
I've fixed the bug ... loop builtin didn't check if error happened in it's code block. I made some other fixes. ; Board as nested blocks (lists)
board: {
{ "_" "_" "_" }
{ "_" "_" "_" }
{ "_" "_" "_" }
}
; Display board using Rye's print and string concatenation
display-board-1: fn { } {
print " 0 1 2"
loop 3 { ::row
print row ++ ": " ++ ( board -> row -> 0 ) ++ " " ++ ( board -> row -> 1 ) ++ " " ++ ( board -> row -> 2 )
}
}
display-board-2: fn { } {
print " 0 1 2"
loop 3 { ::row
print join\with [ row ++ ":" board -> row -> 0 board -> row -> 1 board -> row -> 2 ] " "
}
}
display-board-3: fn { } {
print " 0 1 2"
loop 3 { ::row
print [ row ++ ":" board -> row -> 0 board -> row -> 1 board -> row -> 2 ]
}
}
display-board-4: fn { } {
print " 0 1 2"
for\idx board 'i { prns i ++ ":" , .print }
}
; Demo game
print "TicTacToe Demo:"
display-board-1
print "\n---------\n"
display-board-2
print "\n---------\n"
display-board-3
print "\n---------\n"
display-board-4Unfortunately, this sort of task (modifying nested structure) is where Rye is the most clumsy at ... Rye, REBOL / Lisp and all languages without "any syntax" are worse at this, because they don't have any special syntax for accessors. Something like This makes it a good challenge to think about Rye more because I want to make it usable for such tasks also ... maybe not the best to see the Rye's strengths :) ... |
Uh oh!
There was an error while loading. Please reload this page.
I'm tinkering with Rye trying to write a CLI/embeddable tic-tac-toe. My goal is to build a graphical editor for Rye. In order to do that I'll have to get more comfortable writing it in text form, since I just found it yesterday 😄 .
I've been letting Cursor take a swing at coding it, and it does OK, but I notice that the errors from the interpreter aren't super enlightening. For example, the below block looks OK:
but yields this when run:
I've tried a few different attempts at printing out the board's rows, all end with just "Failure" and no ptr back to the source or the function that is failing. I don't see a debug flag in rye's CLI options. Is there some better way to trace where an error comes from?
All reactions