[Flashforth-devel] Trying to make forth word SYNONYM
Brought to you by:
oh2aun
From: Tristan W. <ho...@tj...> - 2023-04-25 08:52:11
|
Hello, I'm trying to make the forth word SYNONYM (which I have renamed alias) and I am not sure what is the best way to do so in FlashForth? I first looked at https://forth-standard.org/standard/tools/SYNONYM which I tried to replicate in FlashForth below. : alias flash create immediate ' , ram does> @ state @ 0= over immed? or if execute else cf, emit then ; This worked at the console but not within a : definition. > alias copy 1+ \ gives OK > 100 copy \ places 101 on stack > : other copy ; \ adds 1 to TOS *whilst* being defined > 100 other ; \ does not result in TOS=101 "see"-ing other shows just a return statement Removing the immediate from the create : alias flash create ' , ram does> @ state @ 0= over immed? or if execute else cf, emit then ; > alias copy 1+ \ gives OK > 100 copy \ places 101 on stack > : other copy ; \ gives OK > 100 other ; \ places 101 on stack This worked at the console and within a : definition. However ' 1+ immed? and ' copy immed? are not the same, so copy is not a synonym of 1+ in all ways. Will this come back to bite me at some point? Best wishes, Tristan |