6 ms·
Question for the Forth folks in this thread. Does Forth support loadable code modules? Here's the problem I'm trying to solve (still in the tinkering stage). I
by linuxlizard 11y ago
Question for the Forth folks in this thread. Does Forth support loadable code modules?
Here's the problem I'm trying to solve (still in the tinkering stage). I have an embedded processor with small on-board SRAM but huge external address space and a NAND flash. Can't add external RAM.
http://www.atmel.com/tools/ATSAM4S-XPRO.aspx http://www.atmel.com/tools/ATSAM4S-XPRO.aspx
Would like to be able to run more code than can fit in the SRAM. With C, I was looking at the old style overlays.
https://en.wikipedia.org/wiki/Overlay_%28programming%29 https://en.wikipedia.org/wiki/Overlay_%28programming%29
Also want to be able to support downloadable code modules.
Was looking into a Tcl dialect http://wiki.tcl.tk/1363 http://wiki.tcl.tk/1363 but I keep thinking Forth would be perfect.
- nanofortnight 11y agoI can imagine implementing a direct threaded Forth, but instead of code addresses being memory locations, code addresses are a virtual address; DOCOL and NEXT swap in the appropriate segment of code into memory where necessary. This could possibly be optimised in a subroutine threaded Forth so code within each "page" wouldn't have to verify loaded segments. Implementing a dictionary insertion/optimization routine that packs related routines together to minimise swapping would be an interesting problem, and would probably most easily not be done live but ahead-of-time instead. In short: Yes, Forth can support the paging you desire if implemented that way.
- oofoe 11y agoThe traditional FORTH "overlay" is to use FORGET. You create a dummy word to serve as a marker, like ": OVERLAY ;" or something, then later, you can "FORGET OVERLAY" and load in new code to replace it. This only affects the dictionary -- the stack and heap (if any) aren't touched. The new ANS hotness is the "MARKER" word, you just say "MARKER OVERLAY" and then you can just invoke OVERLAY later and it clears things out for you. See Elizabeth Rather's comment here: http://computer-programming-forum.com/22-forth/c67f31fe1e09b166.htm http://computer-programming-forum.com/22-forth/c67f31fe1e09b...
- deleted 11y ago[deleted]
- srean 11y agoJim the minimal Tcl dialect that your link points to is a pretty interesting animal, notable in its own right. I believe its one of the few Tcls to have lambda and tail call elimination. Its author would be a familiar figure to HN readers but perhaps associated with a different tool he wrote, redis. I for one knew about Jim and knew about Redis but made the connection that they were written by the same person much later.
- linuxlizard 11y agoThe Tcl might be less of a learning curve for myself and new employees. Forth is quite different.
- brudgers 11y agoForth will might attract a different pool of candidates. That might be a good thing if the idea of programming in Forth excites more people than programing in TCL does. And my unsupported by data gut suggests that Forth is more likely to excite people than TCL.
- blacksqr 11y agoThe mainstream version of Tcl has supported lambda and tail call features for quite some time.