dave0 has joined #forth
dave0 has quit [Quit: dave's not here]
<badcfe> can i construct a string in a function, and return its address?
<badcfe> (without placing a name in dictionary)
<TangentDelta> Depends on the flavor of FORTH used
<tabemann_> hey guys
boru` has joined #forth
boru has quit [Disconnected by services]
boru` is now known as boru
<badcfe> i would like to take the address of the data stack top
<badcfe> this is because i have a loop that places stuff on the stack, and i would to know the count after the loop was done
<badcfe> is there a word for this?
<badcfe> i was trying to count with 0 >r begin ... while r> 1+ >r repeat r>
<badcfe> but now i rewrote it, managing to only use data stack, but it behaves weird and i dont manage to reproduce by interpreting step by step
<badcfe> : ad ( n -- D c ) 0 swap begin 10 /mod while rot 1+ swap repeat ;
<badcfe> i expected 12345 ad to give me 5 4 3 2 4 1 0 or maybe without that last zero. but what i get is an underflow on rot there
<badcfe> oh i think, as the newb i am, i forgot that while consumes the top
sts-q has quit [Ping timeout: 246 seconds]
<badcfe> that works, but now i see that i could just have used a marker-value on the stack before starting the loop
<badcfe> and then unwrapping it
sts-q has joined #forth
<badcfe> i think i have it all sorted out now ...
<badcfe> ... as long as there is a way to output raw data to stdout
<badcfe> like a binary type, is there?
<badcfe> hmm, i can use emit
<badcfe> or, can i type it?
<badcfe> seems i can. good
badcfe has quit [Quit: leaving]
gravicappa has joined #forth
birdwing has joined #forth
_whitelogger has joined #forth
birdwing has quit [Read error: Connection reset by peer]
_whitelogger has joined #forth
_whitelogger has joined #forth
dave0 has joined #forth
presiden has joined #forth
<veltas> Unsigned remainder... so what, UM/MOD ?
<veltas> It does sound like AND is what they really needed though
_whitelogger has joined #forth
Gromboli has joined #forth
john_cephalopoda has joined #forth
<john_cephalopoda> Hi
yyyyyy has joined #forth
Lord_Nightmare has quit [Quit: ZNC - http://znc.in]
dave0 has quit [Quit: dave's not here]
yyyyyy` has joined #forth
yyyyyy has quit [Ping timeout: 264 seconds]
iyzsong has quit [Quit: ZNC 1.7.5 - https://znc.in]
iyzsong has joined #forth
<crest> john_cephalopoda: hi
badcfe has joined #forth
<badcfe> does ans forth specify s>d ordering?
<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
<john_cephalopoda> badcfe: https://forth-standard.org/standard/double might be helpful.
<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]
gravicappa has quit [Ping timeout: 264 seconds]
Gromboli has quit [Quit: Leaving]
Gromboli has joined #forth
Lord_Nightmare has joined #forth
dave0 has joined #forth
john_cephalopoda has joined #forth
<john_cephalopoda> Happy New Year