Gforth BLOCK 0
shtps via Gforth discussion and announcements <gforth-mXXj517/[email protected]> Sat, 06 Aug 2022 11:17:47 +0000
| Newsgroups | gmane.comp.lang.forth.gforth |
|---|---|
| Message-ID | <gSG374_jclYwKelCUi2vM64fy3TUQi7XOi8w1nrqEqt42tUccbM7E9HomPOgjqF5cbVVgKApjfqNw8nkE5RvAJv3g2dwKNAJAcMho25IzsY=@protonmail.com> |
Hi, I'm relatively new to Forth and I'm wondering if I'm doing something wrong or if this is intended behavior or if this is a bug. I'm using gforth on GNU/Linux. Executing the following gives me an error message and creates an empty 0 byte file called blocks.fb: s" Hello world!" 0 block place update save-buffers bye I have attached the backtrace but it doesn't seem very helpful, all it says is invalid memory address. So I then delete the file blocks.fb and try again, but this time with block 1 instead: s" Hello world!" 1 block place update save-buffers bye and it successfully writes into the block and we can verify that it did indeed write into it by starting gforth again and executing: 1 block count type Hello world! ok So maybe block 0 will work now? I try to write into it again: s" weird..." 0 block place update save-buffers bye No errors this time, but when I start gforth again and try to read from it I don't get the expected output: 0 block count type ok So I looked at the blocks.fb file in a text editor and "weird..." was written into it correctly and after a while I've figured that the following works after starting gforth again: 1 block drop 0 block count type weird... ok To me this seems like a bug where "0 block" doesn't initialize something that "1 block" does. Either that or I'm using blocks the wrong way. Unfortunately I could not find any simple examples on how to use blocks so I'm just going off the docs and a few scraps of information on the internet that I could find. Best Regards, shtps
error.txt
(text/plain, 544 B)
Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc. Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license' Type `bye' to exit s" Hello world!" 0 block place update save-buffers bye :1: Invalid memory address s" Hello world!" 0 block place update >>>save-buffers<<< bye Backtrace: $7F4E85B882F0 throw $7F4E866DCB88 $7F4E866E1A00 $7F4E866D8000 $7F4E866D2FD0 $7F4E85B882A0 $7F4E85B885C0 open-blocks $7F4E85B886A0 get-block-fid $7F4E85B887C8 block-position $5594FF160570 $7F4E85B88998 save-buffer $0 $20