Re: [Amforth] Forward declaration for recursive word

2018-12-05 Thread Jan Kromhout
Thanks Matthis,

It is working now.

Do you know if the construction “ TO and VALUE “ is available for amForth?

Cheers

Jan

> Op 5 dec. 2018, om 19:28 heeft Matthias Trute  het volgende 
> geschreven:
> 
> Am Mittwoch, den 05.12.2018, 13:50 +0100 schrieb Jan Kromhout via
> Amforth-devel:
>> Hello
>> 
>> 
>> I wont to use the forward declaration “forward:” to solve my
>> recursive word roll.
>> 
>> Is this use of forward: correct?
> 
> the forward declaration is for cases in which
> one word calls another one before the other
> one is defined. Something like
> 
> : foo bar ;
> : bar foo ;
> 
> 
> 
>> 
>> forward: roll
>> 
>> : roll
>>  dup 0<  \ 0<=
>>  if
>>drop
>>  else
>>swap >r 1- roll r> swap
>> then
>> ;
> 
> Replace the roll inside your definition with 
> recurse and it should work (if the
> code is correct, I did not check it)
> 
>> 
>> When I look into the definition of forward: I find the word “iplace”.
> 
> Oops. I'll update the docs.
> 
>> What is this iplace?
> 
> 
> \ copy a counted flash string to ram
> : iplace ( f-addr r-addr -- )
>> r icount $ff and ( -- f-addr' len )
>  dup r@ c! r>  ( -- f-addr' len r-addr)
>  1+ rot rot
>  2/ 1+ bounds ?do
>i @i over !
>cell+
>  loop
>  drop
> ;
> 
> Matthias
> 
> 
> 
> ___
> Amforth-devel mailing list for http://amforth.sf.net/
> Amforth-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/amforth-devel


___
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel


Re: [Amforth] Forward declaration for recursive word

2018-12-05 Thread Matthias Trute
Am Mittwoch, den 05.12.2018, 13:50 +0100 schrieb Jan Kromhout via
Amforth-devel:
> Hello
> 
> 
> I wont to use the forward declaration “forward:” to solve my
> recursive word roll.
> 
> Is this use of forward: correct?

the forward declaration is for cases in which
one word calls another one before the other
one is defined. Something like

: foo bar ;
: bar foo ;



> 
> forward: roll
> 
> : roll
>   dup 0<  \ 0<=
>   if
> drop
>   else
> swap >r 1- roll r> swap
> then
> ;

Replace the roll inside your definition with 
recurse and it should work (if the
code is correct, I did not check it)

> 
> When I look into the definition of forward: I find the word “iplace”.

Oops. I'll update the docs.

> What is this iplace?


\ copy a counted flash string to ram
: iplace ( f-addr r-addr -- )
  >r icount $ff and ( -- f-addr' len )
  dup r@ c! r>  ( -- f-addr' len r-addr)
  1+ rot rot
  2/ 1+ bounds ?do
i @i over !
cell+
  loop
  drop
;

Matthias



___
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel


[Amforth] Forward declaration for recursive word

2018-12-05 Thread Jan Kromhout via Amforth-devel
Hello


I wont to use the forward declaration “forward:” to solve my recursive word 
roll.

Is this use of forward: correct?

forward: roll

: roll
  dup 0<  \ 0<=
  if
drop
  else
swap >r 1- roll r> swap
then
;

When I look into the definition of forward: I find the word “iplace”.

When I look for this word in the dictionary I can’t find it.

Do I a search with grep -nr ‘iplace’ amforth-6.7 grep is find only

dup 1- swap @i here iplace here count ( copy to temporary ram)


What is this iplace?

Cheers,

Jan Kromhout




___
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel