[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gforth] two alternative definitions for <string.fs>
From: |
Marcos Cruz |
Subject: |
[gforth] two alternative definitions for <string.fs> |
Date: |
Fri, 8 Nov 2013 17:39:08 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
I find the dynamic strings provided by <string.fs> very useful, but
sometimes it's annoying or inconvenient to make sure the variables have
been initialized before fetching them. That's why I usually redefine two
of the provided words:
\ Safer alternatives for words of Gforth's string.fs
warnings @ warnings off
: address@hidden ( a -- len )
\ Return the length of a dynamic string variable,
\ even if it's not initialized.
@ dup if @ then
;
: $@ ( a -- ca len )
\ Return the content of a dynamic string variable,
\ even if it's not initialized.
@ dup if dup cell+ swap @ else pad swap then
;
warnings !
Just thought the idea could be useful for someone.
--
Marcos Cruz
http://programandala.net
- [gforth] two alternative definitions for <string.fs>,
Marcos Cruz <=