retroforth/package/unsupported/allow-underscores-in-names.forth
crc 1e3c96b298 move old extensions to package/unsupported
FossilOrigin-Name: ded56b1d1a13b6e2d7e4f74e634e67c3ec04ec691b9446863c9447b01f0cb455
2020-09-11 18:36:38 +00:00

30 lines
850 B
Forth

## Fix Annoyances
Underscores in names (especially variables and constants) are a
problem as the string processor (`prefix:'`) replaces them with
a space. The other prefixes do not do this, which leads to bugs.
Consider:
'test_data var
#10 !test_data
`test_data` is not found as the real name is `test data`, so it
silently maps the address to 0.
As a solution, this replaces `d:add-header` with an new version
that implementation that remaps any spaces back to underscores
prior to creating the header.
~~~
{{
:fields @Dictionary , (link) , (xt) , (class) ;
:invalid-name? dup ASCII:SPACE s:contains-char? ;
:rewrite [ ASCII:SPACE [ $_ ] case ] s:map ;
:entry here &call dip !Dictionary ;
[ [ fields invalid-name? &rewrite if s, (name) ] entry ]
}}
#1793 &d:add-header store
&d:add-header n:inc store
~~~