<2ead8c73-a3f9-4ded-80b9-96a80d06d688@100r.co>
Hello everyone :) Long time no talk, lots has happened since my last email, I'll try to make a catch up email soon. This is about an email I got this morning with a question that I don't know how to answer. Here's the question, should ,&y LDR be able to access object/y: @object &pos &x $1 &y $1 &get-x ( -- x ) ,&x LDR JMP2r @object/get-y ( -- y ) ,&y LDR JMP2r I was sent a length of code that doesn't seem to be easily refactored into something that would work without. While it is a quick fix in both uxnasm and drifblim, I found examples of code that rely on these new scopes(@object/get-y) to re-use single character variables, example: @object &pos &x $1 &y $1 &get-x ( -- x ) &l ( -- ) ,&x LDR JMP2r @object/get-y ( -- y ) &l ( -- ) ,&y LDR JMP2r If I went ahead with this change, it might break these routines. So I'd like to know your opinion on this. Goren suggested that we could do something like &&l to create &get-x/l. Let me know what you think :) Have a good one! Dll
<e368c665-3e5a-4a6f-b959-c4729023f9af@100r.co>
<2ead8c73-a3f9-4ded-80b9-96a80d06d688@100r.co>
(view parent)
Thanks everyone for the feedback, I'm glad you liked the idea, it is now merged and documented: https://wiki.xxiivv.com/site/uxntal_scope.html I've also written a new example file in a kind of pseudo Objective-Uxn style, where the state of an entire object is done through accessors and the local state is modified only by its own methods. I ported the timer example for a smalltalk-80 examples folder: https://git.sr.ht/~rabbits/uxn/tree/main/item/projects/examples/gui/timer.tal This makes use of a new thing, which has been discussed before but never implemented, being able to call local subroutines without having to type the scope's entire name each time, similarly to how you'd !print or ?print. This uses the scope delimiter character /, So instead of print/byte, when within the @print scope, you can simply /byte. It's a tiny change to the emulator that completes the handling of scope in Uxntal: https://git.sr.ht/~rabbits/uxn/commit/202ca788009978a204dbb0d6892eea89315828d5 Enjoy!