<cmtptr>
i'm writing a thing in c right now and it's getting really cumbersome to break into multiple functions because there is so much information that needs to be share
<cmtptr>
d
<cmtptr>
so i'm thinking of creating a context structure and passing that around, because i can't use globals since it needs to be reentrant
<cmtptr>
and this got me thinking about forth, and the common practice of using globals there
<cmtptr>
what if you designed it so that what you write is sort of like a subprogram
<cmtptr>
like you define subprogram blocks
<cmtptr>
and that contains globals and functions
<cmtptr>
or forth words, rather
<cmtptr>
and within there you define your forth words which have visibility of any variables defined there
<cmtptr>
this might be easier with an example hold on
<cmtptr>
inherent non-reentrancy has always been a problem i've had with traditional forth
iyzsong has quit [Read error: Connection reset by peer]
iyzsong has joined #forth
<cmtptr>
maybe in keeping with the forth terminology (words, vocabularies, etc.) they should be called stanzas or paragraphs
WickedShell has quit [Remote host closed the connection]
<cmtptr>
and then you could make them run in parallel - those would be called costanzas. costanza: george main: ." the jerk store called, they're running out of you!" ; end-costanza
xek has quit [Ping timeout: 256 seconds]
<MrMobius>
cmtptr, if you just want to hide x, y, and part-one, you can do that with wordlists
<MrMobius>
make one for foo, define what you need, then disable it
<MrMobius>
the code is still there but the words wont be findable any more so there wont be any name conflicts
<cmtptr>
i know, but what i'm talking about isn't hiding, it's instantiation
<cmtptr>
e.g., in my example above bar can recurse and get new instances of its x, or multiple threads can execute foo and not have its x and y step all over each other
<MrMobius>
for recursion I think the standard forth answer would be to keep x and y on the stack
Zarutian_HTC has joined #forth
zolk3ri has joined #forth
dave0 has joined #forth
inode has quit [Quit: ]
dave0 has quit [Read error: Connection reset by peer]