More BefunGen desc
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
In TextFunge you can optionally define a read- and writable display area.
|
||||
|
||||
```textfunge
|
||||
program example_01 : display[16, 16]
|
||||
```
|
||||
|
||||
The display has a width and a height and every field has initially the value you set in the options (the standard is space).
|
||||
|
||||
You can access the display with the `display[x, y]` command.
|
||||
|
||||
```textfunge
|
||||
display[0, 0] = 'X'; // Write 'X' to position (0,0)
|
||||
c = display[0, 1]; // Set c to the value of (0,1)
|
||||
```
|
||||
|
||||
There are also a few automatically defined constants for teh work with displays:
|
||||
|
||||
```textfunge
|
||||
DISPLAY_WIDTH // The width of the display
|
||||
DISPLAY_HEIGHT // The height of the display
|
||||
DISPLAY_SIZE // The size (width*height) of the display
|
||||
```
|
||||
|
||||
You can use the display to
|
||||
|
||||
- display information to the user without using input commands
|
||||
- gather a big amount of data from the user before execution (he has to fill the display manually)
|
||||
- use it as a big 2-dimensional array for calculations
|
||||
|
||||
> **Note:**
|
||||
> Beware that there is normally no mechanism to control access overflow.
|
||||
> So you can enter to high/low x/y values and access/modify program pieces that are not part of the display.
|
||||
> This is a way of bricking your program by writing in the area of program code
|
||||
>
|
||||
>**Tip:**
|
||||
> You can prevent this by enabling the compiler option *Prevent display overflow*.
|
||||
> But beware that tis will result in longer display access times.
|
||||
@@ -0,0 +1,37 @@
|
||||
There are a few things you should consider when creating programs with Befunge:
|
||||
|
||||
###Number ranges
|
||||
|
||||
The size of the internal numbers is dependent on the interpreter, while you can safely assume that the number is at least 16bit, everything higher is not sure.
|
||||
So for bigger programs you have to either work with smaller numbers or use interpreters which use bigger sizes.
|
||||
|
||||
> **Tip:**
|
||||
> [BefunExec](/programs/view/BefunGen) uses 64bit integer (= long values).
|
||||
|
||||
###Negative numbers
|
||||
|
||||
A real problem are negative numbers. In created programs variables are saved in the grid.
|
||||
If the interpreter does not support negative grid values you will not be able to use negative numbers.
|
||||
|
||||
But don't worry too much - most interpreters I know support negative numbers in the grid.
|
||||
|
||||
###Performance
|
||||
|
||||
BefunGen is definitely not a tool to create fast Befunge programs, it's a tool to create big ones.
|
||||
And while it optimize your program quite a bit, a manual written program will always be faster and smaller.
|
||||
|
||||
So for bigger programs you will also need an fast interpreter - otherwise the execution could take a long time
|
||||
|
||||
> **Tip:**
|
||||
> [BefunExec](/programs/view/BefunGen) is a pretty fast multi-threaded interpreter.
|
||||
|
||||
|
||||
###Program size
|
||||
|
||||
While the generated programs are strictly bound to the Befunge-93, they can become pretty big (bigger than 80x25).
|
||||
|
||||
So you have to either use a Befunge-93 interpreter which ignores the size limit (many interpreters do that)
|
||||
or use a Befunge-98 interpreter.
|
||||
|
||||
> **Tip:**
|
||||
> [BefunExec](/programs/view/BefunGen), as you probably can assume, has no "real" size limit to it.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
Here a few tricks for programming with BefunGen:
|
||||
|
||||
###Horizontal size
|
||||
|
||||
Normally a program only grows in height, the more instructions your program has the greater is the height of the generated code.
|
||||
|
||||
So it is kinda bad when you have one really long line, because the width of the program is determined by the longest line.
|
||||
So its good to try to avoid long lines for the sake of smaller - more compressed programs.
|
||||
|
||||
Here are a few common cases which compile to long single lines:
|
||||
|
||||
- Deep Nesting (e.g. multiple nested `for` loops)
|
||||
- A lot of consecutive `elsif` statements
|
||||
- `Switch` statements with a lot of cases
|
||||
- Function calls with a lot of parameters
|
||||
- Very long arrays
|
||||
- Complex "one-line" statements (e.g. multiple nested method calls)
|
||||
|
||||
Neither of these things has any real consequence - except your program having a lot of empty space.
|
||||
|
||||
###Display as array
|
||||
|
||||
If you are in need of a really big array, or of a 2 dimensional array you can use the display for that.
|
||||
|
||||
The display is an easy way of having an **global** 2dimensional array, that is easily visible to the user.
|
||||
|
||||
###Constants
|
||||
|
||||
You can without hesitation use constants in your program, they are inlined on compilation and have no performance cost at all.
|
||||
|
||||
Reference in New Issue
Block a user