Forth FAQ

xiaoxiao2021-03-06  14

FORTH FAQ This article is translated from comp.lang.forth frequently asked Questions (1/6): General / Misc Original M. Anton Ortl, anton@mips.complang.tuwien.ac.at Forth? What is FORTH coming? Where is FORTH? Why use Forth? Forth to outdate? Forth is still small than C language, is it fast? What are the standards for Forth? What is RFI? Does Forth have coding specifications? I have encountered trouble when the stack is managed, is it global variable? What is FORTH Interest Organization? Who is Chuck Moore? What do he do now? What is the point of view? Commercial or free software Forth system? FORTH of free software is a poor Forth? Block or file? Where can I find the c-to-forth compiler? Where can I find the Forth-to-C compiler? Is there a record type in Forth? Why use the Nen to end an IF structure? What is the string code? What is the difference between different series line encoding technologies? Has anyone written in programs that compile FORTH into a Java bytecode? Can you translate Java by node code into Forth? How does Forth do not run without an operating system? Why not use Forth to write an operating system? What is FORTH? FORTH is a stack-based, scalable, no type of language that may be most famous is its "reverse Poland" (suffix) arithmetic expression, and people who use HP calculators should be familiar with this method: Add two numbers in Forth, you need to input 3 5 instead of 3 5. In Forth, the basic program unit is "word": the word can be a named data item, a subroutine or operator. The FORTH programming is to define a new word with already existing words. FORTH statement:: Squared dup *; defines a new word Squared, its function is a square square (multiplying itself). Since all language structures are composed of words, applicants can "extend" Forth as needed to add new operators, program structures, or data types. FORTH's "kernel" contains operators for integers, addresses, characters, and Boolean values, strings, and floating point operations to choose to join. Back to FAQ How did Forth Forth come? The original meaning of FORTH is to indicate that this software is designed for the fourth generation (next generation) computer, that is, Moore features features through distributed small computers. However, the operating system restricted file name he used at that time was only less than 5 characters, so letters 'u' was removed. Until the 1970s did not expire, or use Forth's all-in-case letters, as I / O devices that only support uppercase letters were supported at that time. With the popularity of lowercase I / O equipment, this spelling method of Forth is widely accepted because it is not an abbreviation of several words.

See Rather, Colbourn, And Moore: The evolution of forth , in: History of Programming Languages ​​(Hopl-II), ACM Press / Addison-Wesley 1996. Note: FORTH is not 4GL (language for database application development) Back FORTH FORTH WAN? Why do you want to use Forth? Forth, although it has appeared early in 1970, it has become widely known in the personal computer era. Its high performance and memory economics are very attractive. These advantages have also made Forth to apply in embedded systems. It is common, including barcode reader drivers from space shuttle to federal express. Forth interactive features make new hardware testing and development flows. Incremental development, fast program trial cycle, complete interactive access to any level procedure, high "abstract level" work ability, all of which make Forth have a good reputation of high program productivity. In addition, the flexibility and scalability of the language are the main reasons for the embedded system to select Forth. Return FAQ FORTH Outdown? One of the best answers from this problem from Brad Rodriguez (Mailto: BJ@forth.org), you can find a complete version at http://www.complang.tuwien.ac.at/forth/faq/why-fth. In a word, the advantage of Forth is its understandability, short, interactive, fast, scalability, and easy to make it work on a high-level abstraction. By the way, people who put forward this issue may compare the Forth system with the latest version of Borland C for more than a decade. However, the system he used is too time, although there are also many aspects of the modern Forth system. Back FAQ is still small than the C language, is it fast? Not necessarily, if you convert a C language program to Forth, you will find that the program becomes very slow (such as using the serial coded GForth system, approximately 4-8 times, if using a typical local code compiler It is approximately 1-3 times). Similarly, you can't see the advantages of inherent code size in Forth. For details, see . However, many developments have shown that Forth is better than other languages ​​in size and / or speed. I suspect that this is the flexibility of Forth's flexibility to help programmers produce faster and / or smaller programs. Back FAQ FORTH What Standard Forth's National Standard is ANSI X3.215-1994, as an authoritative Forth standard is widely accepted internationally ("ANS FORTH"). This standard is also accepted by the International Standardization (ISO / IEC 15145: 1997). IEEE Standard 1275-1994, called "open firmware" standard, derived from Forth, has been made by Sun Microsystems, HP, Apple, IBM and other companies Compliance with the company to write boot procedures and firmware companies.

See . The earlier Forth standard includes Forth-83 Standard and Forth-79 Standard, which is made by Forth Standards Team, and earlier FIG-Forth The standard is not officially released, but it is "fact standard" in many years. Forth Standards have released the Forth 79 and Forth 83 standard since 1978, and the ANS Forth documentation X3.215-1994 is released by the X3J14 Technical Committee. The most recent standard ANS Forth defines a series of core characters and gives these words to achieve a lot of freedom. The hardware range that ANS Forth can support is larger than any of the previous Forth standards, which may also be larger than any other programming language, see get the latest information. The standard copy is $ 193, but the ANS Forth draft is free (with some copyright restrictions), you can get FTP. The ANS Forth file can get . The best HTML format is . In order to add yourself to the ANS-FORTH mailing list, you can refer to different readme files, these files in ftp://ftp.u.net/vendor / Minerva / X3J14 / On. There are two unofficial websites to check with the consistency of ANS Standard Forth: • John Hayes Written test site . • Jet Thomas Written test site There is also ANS Forth FAQ , It explains the standardization process. Back FAQ What is RFI? RFI is an explanation request (a Request for Interpretation). If you find that there is unclear or unclear place in the standard text, you can send an RFI, the release standard TC (Technical Committee) will be responsible for giving an explanation. You can send the request to Greg@minerva.com by email, and the theme of writing the message is RFI. Previous RFI lists can be obtained by ftp://ftp.u.net/vendor/minerva/x3j14/queries/, also focused on the standard HTML version, . Return FAQ FORTH Is there a coding specification? Some suggestions are given in Leo Brodie's book "Thinking Forth"; these suggestions can be obtained at http://www.forth.org/forth_style.html. Forth has some of their own coding standards in each company.

Paul Bennet released his own standard . Returns a list of common problems I have trouble when you manage the stack, is it global variables? Do not. There is a better way here, that is to insist on using the stack, reorganize (reactifination), until one day you found the use of the stack. Elizabeth Rather Write: A basic technique for writing the Forth program in a comfortable and naturally, is a good stack management. This is difficult for an initialiator because other languages ​​do not require the stack, and other languages ​​achieve all things by using variables. After 25 years of teaching, I felt that beginners were very awkward, so I have developed some exercises (just like a Starting Forth book) to help them. This process is a bit like a cycling: I am panicked when I started, but suddenly one day, a switch in your mind opened, from that, it became comfortable and natural. Andrew Haley wrote: Try to write all your definitions only one line, up to two lines. Write a stack emonation for each word and draw its input and output. If you have to have a "middle" stack illustration to understand what you have done, just split your words into two at this point. In this way, you can test half of the word line on the command line, check the stack every time. Do not use Pick and Roll.. When you insist on writing a code, some rules can relax, but you must do this style at first. • Use the return stack; • Use local variables; • Use the data structure in the memory to transfer pointers on the stack; recognized areas that often encounter troubles are graphics processing. We can see how PostScript does: they are indeed using global state variables to avoid trouble, but they can only access these states through a specific word. Back FAQ list What is FortH Interest Organization? FORTH Interest Organization Forth Interest Group (Fig) was established in 1978, its purpose is to publish information, popularize the Forth language, and the earliest institution of Forth professional programmer. Forth Interest Organization currently maintains a web page http://www.forth.org/Forth.html which has a more complete introduction of the Forth language and many Forth developers' links. Back to FAQ Who is Chuck Moore? What do he do now? Chuck Moore invented the Forth language, and historical information about FORTH can see ). Recently he uses his philosophical idea to design hardware, and has been designed Several processors that can run the Forth language: Novix 4016, ShboM, Up20, Up21, F21, I21 .... He is still constantly exploring new ideas, updating him with the idea of ​​software and forth: he is Novix The achieved CMForth is very influential, and the recent development results are Color Forth and Machine Forth. Machine Forth is a simple virtual machine with only 27 instructions, which is implemented on the UP21 and subsequent processors through hardware, but also implemented on a simple local code on the 386 processor.

It differs from ANS Forth that: each stack top contains an extended Carry bit, with a register A for memory access (replacing the address pointer access memory by the top element as an address pointer). Back to a common problem list What is the point of view? Some points have caused long-term and enthusiastic arguments, and both parties participating in their own point of view have never want to listen to others, I hope you don't fall into it. Here I list some of the opposing views, as the starting point you read, so you can avoid it to the battle like them. Returns a common list of common problems or free software Forth system? "What you pay, you will get anything. Use a commercial Forth system, you can get commercial documents and support, we need a commercial system, otherwise Forth is a dead road." "I use a free software way of the Forth system has good experience. I have no money to pay for the commercial FORTH system. I want source code (some commercial systems do not provide the source code of the entire system), documentation and support for unparalleled commercial software development It is not a lack of example. There is no free software method, FORTH is a dead road. " Back to FAQ FORTH FORTH for free software? "Anyone can write a very bad Forth, then there is no documentation and support; after using such a system, no one wants to use Forth to do anything. Free Forth has ruined Forth's reputation, freedom Forth Grab the business of the developer. "Many people learn Forth for Forth, there is excellent free software Forths. Many successful languages ​​are beginning (and still) provide free software version. No free software style ( Like ADA, Eiffel and Miranda, a language cannot be popular (now there is also an ADA and Eiffel implementation of free software). "Returns a common problem list block or file? "Everyone uses files, all third-party tools are designed using files. The file is wasteful. Block leads to horizontal, unreadable code. Block makes Forth ridiculous." "We are not always It is working under the support of the operating system. We have no files on some machines. We already have a very good block editor and other tools, as well as coding standards that work together with blocks (such as shadow screens). "Return to FAQ list Where can I find the c-to-forth compiler? Parag Patel Write: We (Codegen, Inc. ) Sales C-to-fcode compiler. It actually generates IEEE-1275 Forth and operates in a token. But it produces the Forth code is really ugly. It is very difficult to produce a clear code, and it is very difficult to produce a clear code. C and the stack-based language cannot be mixed well, and I finally implemented a variable stack frame for the C language by using the FortH $ FRAME variable for local variables. Stephen Pelc Write: MPE Production C Language to the compiler of the stack machine, which generates tokenized code for the two stacks of virtual machines. This kind of code quality is good, and the space occupied by Token is better than the commercial C language compiler we test, this is the result of virtual machine design. Of course, what is needed is that the virtual machine can support local variables.

Tokens can be interpreted by the compiler, or translated into a FORTH system, most of which is portable, except for the part of the target architecture. This software is charged, supporting a binary compatibility system. Back FAQ where you can find the Forth-to-C compiler? A prototype Forth-to-C compiler without technical support in . About it in Euroforth'95 Paper . Another Forth-to-C compiler is written by Rob Chapman : Timbre system. Returns a list of frequent logistics FORTH? Many packages provide data structures like Pascal's Record and C Struct, such as Forth Scientific Library () or . Return FAQ Why use the night to end an IF structure? Some people think that Forth is very awkward, while others don't think about it. Explanation by WebSter's New Encyclopedic Dictionary: 2b: Following Next After in Order ... 3D: as a necessary consequence (if you were there, then you saw theme). Forth's Then has 2B The meaning (then, then), and Pascal and other programming languages ​​reference 3D. (Then, then).

If you don't like this to use the THEN, you can define an endif alternative to the following way:: endif postpone dam; immediate Returns FAQ list What is a string code? What is the difference between different series line encoding technologies? Serial coding is a method of implementing a virtual machine interpreter, you can get a more in-depth explanation of strip coding from the following site: Write: Although JVM is a stack machine, it does not effectively compile the Forth program. Here are some reasons:, • One call method is the largest The depth of the stack must be known, see JVM SPEC, P. 111 • JVM method can only return a single object for the caller, such stack results are not possible: (N1 N2 - N3 N4) • For unsigned Nothing directly; • Catch and throw cannot be easily implemented, you need to capture exceptions through anomalum, this is not able to match the Forth model, see JVM SPEC, P. 112 • You have to expand Forth for The Java method produces the required attribute; • There is no need to make a category of the pointer; • You can't put a thing on the stack and then enforce it to another type; • You can't produce it outside the original byte size An object, this is due to safety; this is to say, you can use JVM's bytecode to generate some things like Forth, but cannot use JVM to implement Forth's stack. If you are not satisfied with this answer, you should use Jasmin to directly write JVM programs. Returns the list of common questions to translate the Java field code into Forth? Translate the Java NPC to Forth to handle many trivial things: • Garbage collection • Threads • Control structure (BRANCHES-> ANS FORTH'S seven universal control structure words) • Abnormal • Subprogram (JavaVM code does not specify a subroutine Return to its caller) • JavaVM and the standard T until Forth-83 have made the same error: it specifies the size of the type, such as JavaVM Int is always 32-bit, in order to support these must add several operators • Local Library (Without them, JavaVM can't do anything) Back FAQ how to run without an operating system? The Forth system running on the bare metal hardware is called a stand-alone system (compared to the collaborative system: collaborative system runs on one operating system). Note Do not mix the independent system with the local code system (the latter refers to the system that compiles the FORTH code into a machine code); the independent system exists in local string coding. The Forth system is starting from the beginning, which performs the functionality of the operating system (from hardware to multi-user multitasking), and the current embedded Forth system is usually independent system. Server and desktop systems are usually a collaborative system, which is to avoid a large number of devices that can be used in these systems that have been used to rewrite drivers, and it is also convenient for Forth users and other software users.

Return FAQ Why don't you use Forth to write an operating system? The stand-alone Forth system can be seen as an operating system written in the Forth language, so use Forth to write an operating system. Of course it is possible. Some people have repeatedly suggested to develop an operating system with Forth, but the opponents also list this reason: • If you are planning to write an operating system as a desktop or desktop system, we will face the same as the independent Forth system. Problem, of course, this is also a problem with any new operating system. We need to write drivers for the widely used hardware, need to write new applications for the new operating system; • To solve the application writing problem Some developers suggest that our own operating systems are compatible with an existing operating system such as Linux, including API or even ABI, but we should also develop this operating system: • If this is an exercise, The project may be too big; • If it is only for an operating system, this may not make sense, because the existing system has been working very well; • If it is to show some advantages of Forth, such as the code is particularly small, etc. It seems to have a simpler way. In order to maintain compatibility with the old operating system, these advantages may have no wig, and then, how many people really care about the size of the operating system core code? Return FAQ List Very Vigre Wisdom Technology

转载请注明原文地址:https://www.9cbs.com/read-49796.html

New Post(0)