<MrMobius>
badcfe, it would be the same order for all the other double words. might be easier to answer that question
WickedShell has joined #forth
<badcfe>
is the order of a double word defined by and forth?
<badcfe>
i wrote a forth program that produces a pnm image with the feigenbaum fractal. after an evening of browsing around some of the pages at forth.com -- it's quit nice, but i think i have a bad assumption on f>s down-rounding and on double words having the most significant on top
<badcfe>
look, i didnt even need to use the return stack, only using data and FP, as i wrote it like the following
<badcfe>
1080 constant t 1920 constant n : linear ( n i FP a b -- FP i*{b-a}/n+a ) fover f- s>f f* s>f f/ f+ ; create rndn 1 , : rnd ( -- FP {0..1} ) rndn dup @ 1103515245 * 12345 + dup rot ! 65536 / 0x7fff and 0 d>f 32768.0e f/ ; : logistic ( FP y m -- FP y*m*{1-y} ) fover 1.0e fswap f- f* f* ; : feig_row ( n addr FP m -- ) rnd begin fdup over s>f dup f* f>s cells + 1 over +! @ 65535 < while fover logistic repeat
<badcfe>
2drop fdrop fdrop ; .( P5) cr n . 32 emit t . cr 255 . cr variable v n 1- cells allot : main t 0 do v n cells erase t i 2.4e 4.0e linear n v feig_row n 0 do v i cells + @ 8 rshift emit loop loop ; main
<badcfe>
my pseudo random generator was stolen from the man 3 rand on my gnu/linux, and i'm using gforth here. would be cool to try and compile this tho
<MrMobius>
badcfe, I wouldnt worry about making your programs standard. forth isnt like C where you want it to work on other systems. each program is it's own thing and there is no UB to worry about
<john_cephalopoda>
A bit hard to read all in one line. I suggest using a pastebin like https://bpa.st/ for pasting code.
<badcfe>
MrMobius: but maybe the forth implementation i use specifies that there is UB. how does forth normally define behavior on an uninitialized cell, non-aligned address with @, integer overflow, zero div, and such anyway?
<MrMobius>
you would need a standard in order to define behavior
<MrMobius>
whereas most forths just do whatever they want
<MrMobius>
which you cant really say for many C compilers for example
<MrMobius>
but maybe the documentation for a particular forth would address those things you mentioned
<badcfe>
so, does ans forth leave things undefined for implementers of ans forth to vary on?
<john_cephalopoda>
MrMobius: ANS is literally "American National Standard".
<badcfe>
its weird to me that nobody seems to care to be ans nice
<john_cephalopoda>
MrMobius: Sure, there are plenty of Forths out there that are not ANS-compliant, but badcfe explicitly uses an ANS forth, which offers properties defined in the ANS standard.
<MrMobius>
john_cephalopoda, right but the point is that you cant assume that basically every forth you encounter will be ANS compliant which is a reasonable thing to assume coming from a C background
<john_cephalopoda>
Yeah, that's true.
<MrMobius>
in that case maybe ANS does define UB. youd have to check
<john_cephalopoda>
Bbiab.
john_cephalopoda has quit [Quit: Leaving]
<badcfe>
if the forth community saw no value in a standard, as there is more pragmatic focus on tweaking local forths for specific constraints or goals, then who requested ans?
<MrMobius>
the forth community isnt monolithic
<badcfe>
for c, as example, there was immediate practical value on portability
<MrMobius>
im sure some people saw value in it
<MrMobius>
right
<MrMobius>
forth is closer to assembly in that way
<MrMobius>
than to C
<badcfe>
in common-lisp there was one big lisp user who requested it, i think
Gromboli has quit [Quit: Leaving]
<badcfe>
i think i should replace above "and 0" with "and s>d" to be more portable
<badcfe>
do you have some tips on how to write \ comments and ( comments ?
<badcfe>
MrMobius: i found out that there is UD in forth, namely UD. hehe
<badcfe>
MrMobius: i am sorry. this seems to be a word defined in forth.com example ; (
<cmtptr>
puns aside, there is UD in forth
<cmtptr>
it's pretty much all of it
<badcfe>
cmtptr: i already learnt that FP may use the data stack, as defined by ans, so maybe this is an example that illustrates that ans did a bad job, and that this is to blame implementors to disregard ans
<badcfe>
s/this is to blame/this is a reason for/
<cmtptr>
a signficant portion of forthers are in the camp that doesn't respect ans
<cmtptr>
and i think those would tell you your forth can do whatever it wants, hence it's all undefined behavior
<MrMobius>
( comments are usually for stack comments showing what a word does
<MrMobius>
badcfe, what im getting at is there is not much point making it "more portable"
<MrMobius>
even if that's something important in C
<MrMobius>
kind of like writing assembly in a different way to make it more portable
lispmacs[work] has quit [Remote host closed the connection]
lispmacs[work] has joined #forth
actuallybatman has quit [Ping timeout: 272 seconds]
actuallybatman has joined #forth
inode has joined #forth
gravicappa has quit [Ping timeout: 260 seconds]
<badcfe>
MrMobius: but there are other implementations of gforth, and it's nice if they can run my thingy too
boru` has joined #forth
boru has quit [Disconnected by services]
boru` is now known as boru
<badcfe>
MrMobius: all the world's not a vax
<MrMobius>
badcfe, if thats what makes you happy :)
<badcfe>
MrMobius: yeah. but maybe i could try to write a little forth, which should be feasable for the small subset of forth that i use for this.
<MrMobius>
badcfe, a lot of people go that route
gravicappa has joined #forth
X-Scale has quit [Ping timeout: 265 seconds]
X-Scale` has joined #forth
X-Scale` is now known as X-Scale
Gromboli has joined #forth
WickedShell has quit [Remote host closed the connection]