Compiling empty strings

19 views
Skip to first unread message

The Beez

unread,
Feb 18, 2015, 4:06:17 AM2/18/15
to 4th-co...@googlegroups.com
Hi 4tH-ers!

While making a library for ISO 3166-1 support, I found out there was no easy way (not even a difficult one) to compile NULL (empty) strings. Due to the way 4tH tokenizes, things like ," " cannot be supported and generate an error. The only way to do it is to compile a single space and then call -TRAILING to get rid of it. That's cumbersome and prone to error.

Thus I added a new word, called ,"" which compiles a NULL string. It's even intelligent, reusing any NULL strings that may already be present, so you won't end up with lots of useless NULL characters.

Note there is no need for S"", since "0 DUP" will just do fine. But I guess you already knew that, since we've used that one lots of time before. I also changed "NULL" in CONSTANT.4TH to (ERROR), which seems more appropriate and allows for negative values in lookup tables. If you've always used this constant AND always used "<>" and "=" to compare it you should be fine. Of course, I'm responsible for everything in SVN - but I already examined that one (BTW, I did fine ;-).

Code in SVN.

Hans Bezemer
Reply all
Reply to author
Forward
0 new messages