Export to GitHub

pforth - issue #18

Add to math things like sin, cos, tan, sinh, etc.


Posted on Sep 18, 2012 by Happy Kangaroo

It appears that this would be done in pfcustom.c Would it be possible to create a more generic interface for extensions where we could store a string into a definition that would get compiled?

Some forths allow the creation of an assembler vocabulary. What about a C vocabulary. Allow the insertion of C code into definitions.

Comment #1

Posted on Sep 19, 2012 by Swift Panda

If you build pForth with -DPF_SUPPORT_FP then you will get the math functions you describe. The floating point extension words are implemented. For example:

3.141 0.5 f* fsin f.

printf 1.0000

Other float words that we support include:

FPICK FTANH
FTAN FSQRT FSINH FSINCOS FSIN FLOG
FLNP1 FLN FCOSH FCOS FATANH FATAN2
FATAN FASINH FASIN FALOG FACOSH FACOS
FABS F** FSWAP FROUND FROT FOVER
FNEGATE FMIN FMAX FLOOR FLOATS FLOAT+
(FLITERAL) FLITERAL FDUP FDROP
FDEPTH F@ F>D F< F0= F0<
F/ F- F+ F* F! D>F

What about a C vocabulary.

Adding a 'C' extensions would greatly complicate the building of pForth and reduce its portability. One of the biggest advantages of pForth is that it is very simple. There are better Forths that run on desktop computers with lots more features. PForth is designed to run on minimal systems and was initially designed for hardware testing and validation. So we probably won't add that.

Status: WontFix

Labels:
Type-Defect Priority-Medium