From: Enoch <ix...@ho...> - 2013-03-31 14:41:11
|
Hello Matthias, Having given further thought to r1404 and your recent comments I think that we need to revert to the wlscope former interface to utilize this new mechanism to its fullest. Example follows and here's the kernel patch: http://pastebin.com/aSWRMU3V Regards, Enoch. \ wlscope, "wordlist scope" ( addr len -- addr' len' wid ), is a deferred word \ which enables the AmForth application to choose the wordlist ( wid ) for the \ new voc entry based on the input ( addr len ) string. The name of the new voc \ entry ( addr' len' ) may be different from the input string. Note that *all* \ created voc entry types pass through the wlscope mechanism. The default \ wlscope action passes the input string to the output without modification and \ uses get-current to select the wid. \ The following example shows how to create a library of words under a special \ wordlist (can_lib). This example also shows how to chain scope calls safely. wordlist constant can_lib get-order 1+ can_lib swap set-order \ can_lib would be searched first : can_scope ( addr len -- addr' len' wid ) 2dup 4 > if \ name length check s" can_" tuck icompare if \ name prefix check 4 - swap 4 + swap \ drop prefix from created word can_lib exit then else drop then [ ' wlscope defer@ ] literal execute ; ' can_scope is wlscope |