Category:Evaldraw

From Rosetta Code
Revision as of 22:48, 13 August 2023 by Torbjoern (talk | contribs) (moved from redirect i think)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Language
Evaldraw
This programming language may be used to instruct a computer to perform a task.
Execution method: Compiled (machine code)
Garbage collected: No
Parameter passing methods: By value
Type safety: Unsafe
Type strength: Weak
Type checking: Static
Lang tag(s): c
See Also:


Listed below are all of the tasks on Rosetta Code which have been solved using Evaldraw.


EVALDRAW is a quirky little programming tool that can be used to make small applications and games, or even do 1D, 2D or 3D graphs, or create custom musical instruments. Evaldraw is technically a tool and not the language, however, since RSCRIPT and Evaldraw are tied together, we can consider Evaldraw a programming language in itself. From this point, this article will refer to the capabilities of RSCRIPT and Evaldraw together.

Compiler modes

  • EVAL the initially bundled compiler, developed by Ken Silverman. Had only doubles and arrays of doubles.
  • RSCRIPT added in 2010 and created by Robert Rodgers. Added support for structs, making entities to handle. Easier to translate to C.

Overview

Evaldraw has syntax similar to C.

Curly Braces

EVALDRAW supports grouping multiple statements in curly braces. They are not needed for single statements.

Semicolons

All statements, except for the last statement in a function must end with a semicolon;

Functions

Functions all return an implicit double value from the last statement in the function. Parameters passed to functions can be doubles, arrays or structs.

Statements

The following statements are supported: IF and IF-ELSE, but no SWITCH-case. A few loop statements such as the DO-WHILE, WHILE and FOR-loop Goto and label declaration is possible. Doubles can be RETURNED from functions. Loops can be exited with BREAK, or remainder of code body can be skipped with CONTINUE. ENUMs allow the programmer to give numerical constants names. Expressions can be used, and a later enum can depend on a previous enums value. Variables can be automatic or STATIC.

Case insensitive

All names and keywords are case insensitive. This can create some confusion when porting from- or to C.

All you need is 64-bit float

All variables, also those declared in structs are double. If no type is supplied, double is assumed. All functions return a double.

Arrays

Arrays that are power of two are wrapped, non power-of-two arrays set index zero if accessed out of bounds.

Pass by value or pass by ref

Doubles are passed by value, but can be passed by ref by prefixing a & symbol. All other variables, arrays and structs are passed by ref.

Builtins

There are many built in functions. The EVAL and RSCRIPT compiler modes support the following 1-param functions: ABS ACOS ASIN ATAN ATN CEIL COS EXP FABS FACT FLOOR INT LOG SGN SIN SQRT TAN UNIT And the following two param functions: ATAN2 FADD FMOD LOG MIN MAX POW

There is no concept of include statements or libraries. It is assumed evaldraw programs are small scripts to try out ideas that later will be integrated into a professional programming language such as C.