Am Freitag, 8. November 2013, 17:39:08 schrieb Marcos Cruz: > 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 > > : $@len ( 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.
Yes, makes sense. I've added a few more of those checks to the git HEAD version, so that $+! on an uninitialized string works, too. Or $del/$ins. -- Bernd Paysan "If you want it done right, you have to do it yourself" http://bernd-paysan.de/
signature.asc
Description: This is a digitally signed message part.
