Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #57272 > unrolled thread
| Started by | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| First post | 2017-04-13 22:46 -0700 |
| Last post | 2017-04-14 21:24 -0400 |
| Articles | 20 on this page of 57 — 11 participants |
Back to article view | Back to comp.lang.forth
[Random] Escape the trolls Julian Fondren <julian.fondren@gmail.com> - 2017-04-13 22:46 -0700
Re: [Random] Escape the trolls NN <november.nihal@gmail.com> - 2017-04-14 10:53 -0700
Re: [Random] Escape the trolls Julian Fondren <julian.fondren@gmail.com> - 2017-04-14 11:26 -0700
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-14 15:30 -0400
Re: [Random] Escape the trolls Julian Fondren <julian.fondren@gmail.com> - 2017-04-14 12:45 -0700
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-14 16:02 -0400
Re: [Random] Escape the trolls NN <november.nihal@gmail.com> - 2017-04-14 13:13 -0700
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-14 16:18 -0400
Re: [Random] Escape the trolls NN <november.nihal@gmail.com> - 2017-04-14 13:25 -0700
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-14 16:49 -0400
Re: [Random] Escape the trolls Alex <alex@rivadpm.com> - 2017-04-14 21:59 +0100
Re: [Random] Escape the trolls josv@planet.nl - 2017-04-15 04:09 -0700
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-15 12:45 -0400
Re: [Random] Escape the trolls Coos Haak <htrofhc@gmail.com> - 2017-04-15 18:50 +0200
Re: [Random] Escape the trolls NN <november.nihal@gmail.com> - 2017-04-15 15:45 -0700
Re: [Random] Escape the trolls hughaguilar96@gmail.com - 2017-04-14 14:46 -0700
Re: [Random] Escape the trolls Julian Fondren <julian.fondren@gmail.com> - 2017-04-14 15:35 -0700
Re: [Random] Escape the trolls hughaguilar96@gmail.com - 2017-04-14 16:24 -0700
Re: [Random] Escape the trolls Alex <alex@rivadpm.com> - 2017-04-15 00:34 +0100
Re: [Random] Escape the trolls Alex <alex@rivadpm.com> - 2017-04-15 00:36 +0100
Re: [Random] Escape the trolls hughaguilar96@gmail.com - 2017-04-14 20:58 -0700
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-15 00:24 -0400
Re: [Random] Escape the trolls hughaguilar96@gmail.com - 2017-04-14 21:40 -0700
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-15 02:32 -0400
Re: [Random] Escape the trolls anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-15 07:50 +0000
Re: [Random] Escape the trolls anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-15 08:15 +0000
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-15 13:10 -0400
Re: [Random] Escape the trolls Coos Haak <htrofhc@gmail.com> - 2017-04-15 19:27 +0200
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-15 14:25 -0400
Re: [Random] Escape the trolls anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-17 14:05 +0000
Re: [Random] Escape the trolls "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-16 01:42 +0000
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-15 21:51 -0400
Re: [Random] Escape the trolls "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-16 02:10 +0000
Re: [Random] Escape the trolls Coos Haak <htrofhc@gmail.com> - 2017-04-16 14:29 +0200
Re: [Random] Escape the trolls "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-16 13:58 +0000
Re: [Random] Escape the trolls anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-16 16:11 +0000
Re: [Random] Escape the trolls "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-16 22:18 +0000
Re: [Random] Escape the trolls Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2017-04-17 07:54 +0100
Re: [Random] Escape the trolls "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-17 23:32 +0000
Re: [Random] Escape the trolls "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-17 23:33 +0000
Re: [Random] Escape the trolls Julian Fondren <julian.fondren@gmail.com> - 2017-04-14 22:33 -0700
Re: [Random] Escape the trolls Julian Fondren <julian.fondren@gmail.com> - 2017-04-14 22:52 -0700
Re: [Random] Escape the trolls anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-15 07:52 +0000
Re: [Random] Escape the trolls Alex <alex@rivadpm.com> - 2017-04-15 11:20 +0100
Re: [Random] Escape the trolls anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-15 11:53 +0000
Re: [Random] Escape the trolls Alex <alex@rivadpm.com> - 2017-04-15 19:10 +0100
Re: [Random] Escape the trolls anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-17 14:19 +0000
Re: [Random] Escape the trolls Bernd Linsel <bl1@gmx.com> - 2017-04-15 20:21 +0200
Re: [Random] Escape the trolls Alex <alex@rivadpm.com> - 2017-04-15 20:33 +0100
Re: [Random] Escape the trolls Bernd Linsel <bl1@gmx.com> - 2017-04-16 11:50 +0200
Re: [Random] Escape the trolls anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-16 14:22 +0000
Re: [Random] Escape the trolls anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-16 14:47 +0000
Re: [Random] Escape the trolls hughaguilar96@gmail.com - 2017-04-15 16:55 -0700
Re: [Random] Escape the trolls hughaguilar96@gmail.com - 2017-04-15 17:03 -0700
Re: [Random] Escape the trolls Alex <alex@rivadpm.com> - 2017-04-15 11:37 +0100
Re: [Random] Escape the trolls Julian Fondren <julian.fondren@gmail.com> - 2017-04-14 16:51 -0700
Re: [Random] Escape the trolls rickman <gnuarm@gmail.com> - 2017-04-14 21:24 -0400
Page 1 of 3 [1] 2 3 Next page →
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2017-04-13 22:46 -0700 |
| Subject | [Random] Escape the trolls |
| Message-ID | <34338c58-a550-47e6-ae8f-ed33234a7792@googlegroups.com> |
title&idea from https://www.reddit.com/r/dailyprogrammer/comments/4vrb8n/weekly_25_escape_the_trolls/
A simple terminal game.
This is (deliberately) not very cleverly or generically coded. If
you'd like something more like a framework for games like this than a
single game like this, look up "jRPG mockups and level design" or
"creating a maze game":
https://groups.google.com/d/topic/comp.lang.forth/Dw7ej3lZHCc/discussion
https://groups.google.com/d/topic/comp.lang.forth/01u6lEi7zMY/discussion
---
\ dependencies:
\ CHOOSE ( n1 -- n2 ) where n2 is randomly selected from [0,n1)
\ 1 cells constant CELL
64 constant -maze
64 constant |maze
-maze |maze * constant /maze
: | ( "line" -- )
0 parse tuck here swap dup allot move
-maze swap - here swap dup allot bl fill ;
create maze
| #####################################
| # # # # # # #
| # # ##### # ### ##### ### ### ### # #
| # # # # # # # # # #
| ##### # ##### ##### ### # # # ##### #
| # # # # # # # # # # #
| # # ####### # # ##### ### # ##### # #
| # # # # # # # # # #
| # ####### ### ### # ### ##### # ### #
| # # # # # # # # # #
| # ### ### # ### # ##### # # # #######
| # # # # # # # # # # # #
| ####### # # # ##### # ### # ### ### #
| # # # # # # # # # #
| # ### # ##### ### # ### ### ####### #
| # # # # # # # # # #
| # # ##### # ### ##### # # ####### # #
| # # # # # # # # # # #
| # ##### # # # ### ##### ##### # #####
| # # # # # # # # # #
| # # ### ### ### ##### ### # ##### # #
| # # # # # # #
| #X###################################
here /maze over maze - - dup allot bl fill
variable player
maze -maze + 1 + player !
: troll, ( -- )
begin
maze /maze -trailing dup -maze / choose -maze * maze +
-maze -trailing choose +
dup c@ bl =
over player @ <> and
until dup , [char] T swap c! ;
create trolls troll, troll, troll,
: what-troll ( a -- a' )
trolls 3 cells bounds do
dup i @ = if drop i leave then
cell +loop ;
: off ( a-troll -- )
bl over @ c! 0 swap ! ;
: stagger ( n-dir a-troll -- )
2dup @ +
dup player @ = if cr ." A troll has found you!" abort then
c@ bl = if
bl over @ c!
tuck +!
@ [char] T swap c!
else 2drop then ;
: meander ( -- )
trolls 3 cells bounds do i @ if
4 choose case
0 of 1 endof
1 of -1 endof
2 of -maze endof
3 of -maze negate endof
endcase i stagger
else drop then cell +loop ;
/maze buffer: output
: .maze ( -- )
maze output /maze move
[char] @ player @ maze - output + c!
output /maze -trailing bounds do
i -maze -trailing cr type
-maze +loop ;
: peek ( n-dir -- c ) player @ + c@ ;
: peer ( n-dir -- c )
2* player @ + dup maze < if drop [char] # else c@ then ;
: shove ( n-dir -- )
dup player @ + bl swap c!
dup player +!
player @ + [char] # swap c! ;
: chars( ( "cc" -- cc )
[char] ) parse drop count 8 lshift swap c@ or
POSTPONE literal ; immediate
: step ( n-dir -- )
dup peek 8 lshift over peer or case
chars( ) of player +! endof
chars( #) of player +! endof
chars( # ) of shove endof
chars( X) of player +! endof
chars( X ) of cr ." You've escaped!" bye endof
chars( T) of
cr ." You fool! The troll devours you."
key abort endof
chars( T ) of
cr s\" The troll: \"oh! excuse me.\"" type key drop
dup player +! negate player @ bl over c! what-troll +! endof
chars( #T) of
dup 2* player @ + what-troll off
shove page .maze
cr ." You crush the troll behind the wall."
key drop endof
endcase ;
: play ( -- )
begin meander page .maze key case
[char] h of -1 step endof
[char] j of -maze step endof
[char] k of -maze negate step endof
[char] l of 1 step endof
27 ( ESC ) of abort endof
endcase again ;
[toc] | [next] | [standalone]
| From | NN <november.nihal@gmail.com> |
|---|---|
| Date | 2017-04-14 10:53 -0700 |
| Message-ID | <2954df4e-7734-40fb-a025-62fa717ec1dc@googlegroups.com> |
| In reply to | #57272 |
Hi Julian, When I compile I find there are values left on the stack. I traced it back to troll, Can you tell me if this behaviour happens on yours too and not because I am using win32forth ? Other than that it works. Thanks for the game NN
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2017-04-14 11:26 -0700 |
| Message-ID | <a21421a5-9168-4083-859f-885dc4f480f9@googlegroups.com> |
| In reply to | #57297 |
On Friday, April 14, 2017 at 12:53:22 PM UTC-5, NN wrote:
> Hi Julian,
>
> When I compile I find there are values left on the stack. I traced it back to troll,
>
> Can you tell me if this behaviour happens on yours too and not because I am using win32forth ?
No, that happens for me as well when I INCLUDE the source.
I'd been testing in a way that cleared the stack, unfortunately.
Corrected TROLL,
: troll, ( -- )
begin
maze /maze -trailing nip -maze / choose -maze * maze +
-maze -trailing choose +
dup c@ bl = over player @ <> and
if dup , [char] T swap c! exit then
drop again ;
Somehow only gforth noticed the stack underflow in MEANDER
Fixed by removing the ELSE DROP in the last line:
: meander ( -- )
trolls 3 cells bounds do i @ if
4 choose case
0 of 1 endof
1 of -1 endof
2 of -maze endof
3 of -maze negate endof
endcase i stagger
then cell +loop ;
> Other than that it works.
> Thanks for the game
>
> NN
The bug that lets you break out of the maze, I'm leaving in :)
Please feel free to modify it to make it more interesting.
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2017-04-14 15:30 -0400 |
| Message-ID | <ocr7qq$v53$1@dont-email.me> |
| In reply to | #57300 |
On 4/14/2017 2:26 PM, Julian Fondren wrote: > On Friday, April 14, 2017 at 12:53:22 PM UTC-5, NN wrote: >> Hi Julian, >> >> When I compile I find there are values left on the stack. I traced it back to troll, >> >> Can you tell me if this behaviour happens on yours too and not because I am using win32forth ? > > No, that happens for me as well when I INCLUDE the source. > I'd been testing in a way that cleared the stack, unfortunately. > > Corrected TROLL, > > : troll, ( -- ) > begin > maze /maze -trailing nip -maze / choose -maze * maze + > -maze -trailing choose + > > dup c@ bl = over player @ <> and > if dup , [char] T swap c! exit then > drop again ; > > Somehow only gforth noticed the stack underflow in MEANDER > Fixed by removing the ELSE DROP in the last line: > > : meander ( -- ) > trolls 3 cells bounds do i @ if > 4 choose case > 0 of 1 endof > 1 of -1 endof > 2 of -maze endof > 3 of -maze negate endof > endcase i stagger > then cell +loop ; > >> Other than that it works. >> Thanks for the game >> >> NN > > The bug that lets you break out of the maze, I'm leaving in :) > > Please feel free to modify it to make it more interesting. Not sure what I'm doing wrong. When I try to compile the updated code Win32Forth 6.15.03 crashes while compiling the word "step". Well, I added debugging statements to narrow down the problem piece-wise and the problem seems to be that s\" is not defined in Win32Forth and I guess the rest of the line somehow is crashing Win32Forth. When I type in a definition with that code Win32forth simply complains that s\" is not found. Any ideas? -- Rick C
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2017-04-14 12:45 -0700 |
| Message-ID | <892a9e40-5e94-4d9d-a883-b07b4f852e26@googlegroups.com> |
| In reply to | #57306 |
On Friday, April 14, 2017 at 2:30:30 PM UTC-5, rickman wrote: > Not sure what I'm doing wrong. When I try to compile the updated code > Win32Forth 6.15.03 crashes while compiling the word "step". > > Well, I added debugging statements to narrow down the problem piece-wise > and the problem seems to be that s\" is not defined in Win32Forth and I > guess the rest of the line somehow is crashing Win32Forth. When I type > in a definition with that code Win32forth simply complains that s\" is > not found. > > Any ideas? Maybe NN has a newer version of Win32Forth, or he removed the S\" without mentioning it. S\" is a Forth-200x word: http://forth-standard.org/standard/core/Seq It's only used once though, and only for internal " quotes. So you can just replace this line: cr s\" The troll: \"oh! excuse me.\"" type key drop with this line: cr ." The troll: 'oh! excuse me.'" key drop
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2017-04-14 16:02 -0400 |
| Message-ID | <ocr9m3$5k5$1@dont-email.me> |
| In reply to | #57307 |
On 4/14/2017 3:45 PM, Julian Fondren wrote: > On Friday, April 14, 2017 at 2:30:30 PM UTC-5, rickman wrote: >> Not sure what I'm doing wrong. When I try to compile the updated code >> Win32Forth 6.15.03 crashes while compiling the word "step". >> >> Well, I added debugging statements to narrow down the problem piece-wise >> and the problem seems to be that s\" is not defined in Win32Forth and I >> guess the rest of the line somehow is crashing Win32Forth. When I type >> in a definition with that code Win32forth simply complains that s\" is >> not found. >> >> Any ideas? > > Maybe NN has a newer version of Win32Forth, or he removed the S\" > without mentioning it. S\" is a Forth-200x word: > http://forth-standard.org/standard/core/Seq Heck, it's a Forth 2012 word. I'm not sure what Forth 200x means. Wasn't that the name for the 2012 standard before it was released since they didn't know what year it would be out? Or is that the next version where the decade would be unsure? > It's only used once though, and only for internal " quotes. So you can > just replace this line: > > cr s\" The troll: \"oh! excuse me.\"" type key drop > > with this line: > > cr ." The troll: 'oh! excuse me.'" key drop Yeah, but I'd like to understand why Win32Forth crashed. I prefer tools that don't crash with simple errors. I'd also like to figure out if there is something missing from my version of Win32Forth. I think 6.15.03 is new enough to not be missing words. -- Rick C
[toc] | [prev] | [next] | [standalone]
| From | NN <november.nihal@gmail.com> |
|---|---|
| Date | 2017-04-14 13:13 -0700 |
| Message-ID | <ecbe8491-988e-4f14-9932-506b0041e4f9@googlegroups.com> |
| In reply to | #57307 |
I am using Win32forth 6.15.04 Build 4 I made 2 changes added : choose random ; at the start and changed s\" The troll: \"oh! excuse me.\"" to s" The troll: 'oh! excuse me.'" And yes its fun to break out of the maze. A hidden feature :) NN
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2017-04-14 16:18 -0400 |
| Message-ID | <ocralc$8bd$1@dont-email.me> |
| In reply to | #57313 |
On 4/14/2017 4:13 PM, NN wrote: > I am using Win32forth 6.15.04 Build 4 > > I made 2 changes > > added > > : choose random ; > > at the start > > and changed > > s\" The troll: \"oh! excuse me.\"" > > to > > s" The troll: 'oh! excuse me.'" > > And yes its fun to break out of the maze. A hidden feature :) So S\" is not in 6.15.04 either, eh? I wonder why? This is the first Forth 2012 word I've not found in Win32Forth although my not finding it doesn't mean a lot, lol. -- Rick C
[toc] | [prev] | [next] | [standalone]
| From | NN <november.nihal@gmail.com> |
|---|---|
| Date | 2017-04-14 13:25 -0700 |
| Message-ID | <632a018f-b830-4aa0-a96c-758d2cf3a1b3@googlegroups.com> |
| In reply to | #57315 |
s\" is not there because it hasnt been implemented. This is forth you can always write your own _
I also changed play ==>
: play ( -- )
begin meander page .maze key case
[char] g of -1 step endof
[char] b of -maze step endof
[char] y of -maze negate step endof
[char] h of 1 step endof
27 ( ESC ) of abort endof
endcase again ;
because i find
Y
G + H
B
easier to use ...
NN
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2017-04-14 16:49 -0400 |
| Message-ID | <ocrcfr$epp$1@dont-email.me> |
| In reply to | #57319 |
On 4/14/2017 4:25 PM, NN wrote: > s\" is not there because it hasnt been implemented. This is forth you can always write your own _ I know it hasn't been implemented in Win32Forth. That's what I'm wondering about. I would hazard a guess that there is an equivalent word and S/" just hasn't been added since it would just be a synonym. I haven't found it yet though. -- Rick C
[toc] | [prev] | [next] | [standalone]
| From | Alex <alex@rivadpm.com> |
|---|---|
| Date | 2017-04-14 21:59 +0100 |
| Message-ID | <ocrd17$geb$1@dont-email.me> |
| In reply to | #57322 |
On 4/14/2017 21:49, rickman wrote:
> On 4/14/2017 4:25 PM, NN wrote:
>> s\" is not there because it hasnt been implemented. This is forth you
>> can always write your own _
>
> I know it hasn't been implemented in Win32Forth. That's what I'm
> wondering about. I would hazard a guess that there is an equivalent
> word and S/" just hasn't been added since it would just be a synonym. I
> haven't found it yet though.
>
You could adapt this. It also supports \unnnn for Unicode point nnnn.
-400 constant throw_malestr
create esc-table ( table of translations for a..z )
7 c, \ \a bel (alert)
8 c, \ \b bs (backspace)
'c' c, \ \c
'd' c, \ \d
27 c, \ \e esc (escape)
12 c, \ \f ff (form feed)
'g' c, \ \g
'h' c, \ \h
'i' c, \ \i
'j' c, \ \j
'k' c, \ \k
10 c, \ \l lf (line feed)
'm' c, \ \m
10 c, \ \n ( CRLF, \r\n )
'o' c, \ \o
'p' c, \ \p
'"' c, \ \q " (double quote)
13 c, \ \r cr (carriage return)
's' c, \ \s
9 c, \ \t ht (horizontal tab}
'u' c, \ \u (becomes UTF-8)
11 c, \ \v vt (vertical tab)
'w' c, \ \w
'x' c, \ \x (becomes hex)
'y' c, \ \y
0 c, \ \z nul (no character)
\ Convert a number to a UTF-8 string and append to
\ a counted string
8 import: WideCharToMultiByte
: addUTF-8 \ {: w^ n dest -- :}
dup>r sp@ cell+ >r >r
0 0 4 r> count +
-1 r> 0 cp_utf8
WideCharToMultiByte
dup 0= throw_malestr ?throw
1- r> c+! drop ;
\ Extract an n-digit hex number in the given base from the
\ start of the string, returning the remaining string
\ and the converted number.
: extract-hex ( c-addr len n -- c-addr' len' u )
base@ >r hex
>r 0 0 2over r@ < throw_malestr ?throw ( input string too short )
r@ >number throw_malestr ?throw ( not hex characters )
2drop r> swap >r /string r>
r> base! ;
: addEscape ( c-addr len dest -- c-addr' len' )
>r dup 0= throw_malestr ?throw ( input string too short )
over c@ case
'n' of
crlf$ count r> +place endof
'm' of
crlf$ count r> +place endof
'x' of
1 /string 2 extract-hex r> c+place exit endof
'u' of
1 /string 4 extract-hex r> addUTF-8 exit endof
dup dup 'a' 'z' between if
'a' - esc-table + c@
then r> c+place
endcase 1 /string ;
: unescape-str ( c-addr len dest -- c-addr' len' )
dup>r 0 swap c! \ zero destination
begin dup \ -- caddr len ; R: -- dest
while
over c@ '"' <> \ check for terminator
while
over c@ dup
'\' = if \ deal with escapes
drop 1 /string r@ addEscape
else \ normal character
r@ c+place
1 /string
then
repeat then 1 /string r>drop ;
: parse\" ( "ccc" -- c-addr l )
source-remain tuck
buf-allot dup>r unescape-str nip
- >in +!
r> count ;
: s\" ( -- )
parse\"
compiles> ( -- c-addr len ) drop
parse\" postpone sliteral ;
--
Alex
[toc] | [prev] | [next] | [standalone]
| From | josv@planet.nl |
|---|---|
| Date | 2017-04-15 04:09 -0700 |
| Message-ID | <6fd87102-742a-4057-b2de-7a6678f22333@googlegroups.com> |
| In reply to | #57315 |
Hi,
In version 6.15.04:
fload est.f ok
see s\"
: S\" PARSE\" STATE @
IF SLITERAL
ELSE DUP CHARS ALLOCATE THROW SWAP 2>R 2R@ CMOVE 2R>
THEN ; IMMEDIATE ok
\s Jos
On vrijdag 14 april 2017 22:18:47 UTC+2 rickman wrote:
> On 4/14/2017 4:13 PM, NN wrote:
> > I am using Win32forth 6.15.04 Build 4
> >
> > I made 2 changes
> >
> > added
> >
> > : choose random ;
> >
> > at the start
> >
> > and changed
> >
> > s\" The troll: \"oh! excuse me.\""
> >
> > to
> >
> > s" The troll: 'oh! excuse me.'"
> >
> > And yes its fun to break out of the maze. A hidden feature :)
>
> So S\" is not in 6.15.04 either, eh? I wonder why? This is the first
> Forth 2012 word I've not found in Win32Forth although my not finding it
> doesn't mean a lot, lol.
>
> --
>
> Rick C
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2017-04-15 12:45 -0400 |
| Message-ID | <octih5$etc$1@dont-email.me> |
| In reply to | #57363 |
On 4/15/2017 7:09 AM, josv@planet.nl wrote: > Hi, > In version 6.15.04: > > fload est.f ok > see s\" > : S\" PARSE\" STATE @ > IF SLITERAL > ELSE DUP CHARS ALLOCATE THROW SWAP 2>R 2R@ CMOVE 2R> > THEN ; IMMEDIATE ok I guess maybe I need to update to 6.15.04. I haven't done that because I have production code that I don't want to break. But it isn't using much other than serial port I/O, a windows call to put data in the paste buffer and socket calls. Not likely for any of that to break I think. Under 6.15.03 source directories I don't find est.f. Is that new to 6.15.04 or do I need to type the above code into a new file? -- Rick C
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <htrofhc@gmail.com> |
|---|---|
| Date | 2017-04-15 18:50 +0200 |
| Message-ID | <tncku7yzw81p.1kuudfktj0yls.dlg@40tude.net> |
| In reply to | #57363 |
Op Sat, 15 Apr 2017 04:09:12 -0700 (PDT) schreef josv@planet.nl: > Hi, > In version 6.15.04: > > fload est.f ok I have version 6.15.04 but can't find est.f anywhere. groet Coos
[toc] | [prev] | [next] | [standalone]
| From | NN <november.nihal@gmail.com> |
|---|---|
| Date | 2017-04-15 15:45 -0700 |
| Message-ID | <09473838-605d-417c-83de-365bbf96759f@googlegroups.com> |
| In reply to | #57377 |
On Saturday, 15 April 2017 17:50:59 UTC+1, Coos Haak wrote: > Op Sat, 15 Apr 2017 04:09:12 -0700 (PDT) schreef josv@planet.nl: > > > Hi, > > In version 6.15.04: > > > > fload est.f ok > > I have version 6.15.04 but can't find est.f anywhere. > > groet Coos I found .\Win32forth\src\lib\EscapedStrings.f , however its not included in extend.f and so not loaded by default. S\" is defined within that file. NN
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2017-04-14 14:46 -0700 |
| Message-ID | <277cc39a-0df3-4458-9cea-b20e2307b6c9@googlegroups.com> |
| In reply to | #57307 |
On Friday, April 14, 2017 at 12:46:01 PM UTC-7, Julian Fondren wrote:
> On Friday, April 14, 2017 at 2:30:30 PM UTC-5, rickman wrote:
> > Not sure what I'm doing wrong. When I try to compile the updated code
> > Win32Forth 6.15.03 crashes while compiling the word "step".
> >
> > Well, I added debugging statements to narrow down the problem piece-wise
> > and the problem seems to be that s\" is not defined in Win32Forth and I
> > guess the rest of the line somehow is crashing Win32Forth. When I type
> > in a definition with that code Win32forth simply complains that s\" is
> > not found.
> >
> > Any ideas?
>
> Maybe NN has a newer version of Win32Forth, or he removed the S\"
> without mentioning it. S\" is a Forth-200x word:
> http://forth-standard.org/standard/core/Seq
These ANS-Forth experts seem to know almost nothing about ANS-Forth! Code that is trivial to write in ANS-Forth they expect the compiler-writer to provide to them as a non-standard extension.
My novice-package is written in ANS-Forth. I have S| available. It is defined like this:
: s| ( -- ) \ runtime: -- adr cnt
[char] | postpone string ;
immediate
This allows me to write:
: test s| The troll: "Oh! excuse me." | type ;
I've had this since 2010 --- it was trivial --- I find it quite humorous that Julien Fondren, who aspires to be appointed to the Forth-200x committee, is incapable of writing trivial ANS-Forth code.
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2017-04-14 15:35 -0700 |
| Message-ID | <8196989c-d2dc-4b12-98c1-9e84ec2781e1@googlegroups.com> |
| In reply to | #57328 |
On Friday, April 14, 2017 at 4:46:18 PM UTC-5, hughag...@gmail.com wrote:
> These ANS-Forth experts seem to know almost nothing about ANS-Forth! Code that is trivial to write in ANS-Forth they expect the compiler-writer to provide to them as a non-standard extension.
S\" is a very widely implemented standard extension that is also
pretty easy to implement on the Forths I've found that lack it.
So to the question, why would you rather use S\" than a custom parsing
word, some answers are:
1. because I expect S\" to already be available
2. because S\" is not just a way to get strings with " in them. It's
also a way to get strings with \r\n in them, for networking protocols,
or \x1B , for terminal escape codes.
3. because it's easier to teach hilighting code editors about S\" than
about several nonce parsing words.
4. because going with S\" allows you to have *anything* in a string.
It would be more irritating to use S| and then have to change up the
word when that particular string grows a need to have an internal |
character. Even when the delimiter is parsed out itself, it's still
irritating to have to change it and scan the string to make sure that
the new delimiter is OK. I don't think that MIME multipart dividers
are that impressive a technology.
Then there's the question as to why, after using S\" merely for an
embedded double-quote, would anyone change the string rather than
write a parsing word in the case that S\" is unavailable. Here some
reasons are:
1. changing the string is an option -- it's not important at all that
I chose " initially
2. it's the faster change to make. You have code with S\" --> you delete
the \ then replace the \" with ' --> you're done. The distance
between A and B is shorter than the distance between A and C, so we
choose to walk to B. Because you're an insufferable idiot, I'll remind
you that "You have NOVICE FORTH loaded and S| already available" is a
point D with its own distances to consider, and I would never be so
rude as to assume that this particular circumstance applies to anyone.
> I've had this since 2010 --- it was trivial --- I find it quite humorous that Julien Fondren, who aspires to be appointed to the Forth-200x committee, is incapable of writing trivial ANS-Forth code.
Hugh: *sees a solution that isn't to his personal preference*
Hugh: EVERYONE LOOK! I found a solution that's *wrong*! Are you all
believers in Straight Forth yet?! Look at this horrifically
erroneously code! These jerks can't even do something this simple
without *screwing it up*!
Hugh: *sees someone use a Forth-94 word instead of a Forth-2012 word*
Hugh: EVERYONE LOOK! I have citational evidence that people who use
ANS Forth are utterly incapable of writing parsing definitions!
: chars( ( "cc" -- cc )
[char] ) parse drop count 8 lshift swap c@ or
POSTPONE literal ; immediate
Hugh: huh--what? no that doesn't count as a parsing definition. I
would write a *different* word for the purpose Julius von Fondren has
here so really this is yet another example of someone *being wrong*.
If you ever think someone's taking you seriously, I promise you that
the poor victim is only hoping that affirmative grunts and nods are
the fastest way of escaping your 'spittle radius' without you giving
chase.
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2017-04-14 16:24 -0700 |
| Message-ID | <56bd7816-4d6e-492a-830e-13eb5475a11a@googlegroups.com> |
| In reply to | #57331 |
On Friday, April 14, 2017 at 3:35:55 PM UTC-7, Julian Fondren wrote: > On Friday, April 14, 2017 at 4:46:18 PM UTC-5, hughag...@gmail.com wrote: > > These ANS-Forth experts seem to know almost nothing about ANS-Forth! Code that is trivial to write in ANS-Forth they expect the compiler-writer to provide to them as a non-standard extension. > > S\" is a very widely implemented standard extension that is also > pretty easy to implement on the Forths I've found that lack it. It may be easy to implement, but you haven't done so --- you are waiting for somebody smart to implement it for you. I don't know what S\" does --- if anybody knows what this does and can describe it, I will try to write it --- if anybody has already written it, and their code is ANS-Forth, I'll put it in the novice-package.
[toc] | [prev] | [next] | [standalone]
| From | Alex <alex@rivadpm.com> |
|---|---|
| Date | 2017-04-15 00:34 +0100 |
| Message-ID | <ocrm4l$ftb$1@dont-email.me> |
| In reply to | #57333 |
On 4/15/2017 00:24, hughaguilar96@gmail.com wrote: > On Friday, April 14, 2017 at 3:35:55 PM UTC-7, Julian Fondren wrote: >> On Friday, April 14, 2017 at 4:46:18 PM UTC-5, hughag...@gmail.com >> wrote: >>> These ANS-Forth experts seem to know almost nothing about >>> ANS-Forth! Code that is trivial to write in ANS-Forth they expect >>> the compiler-writer to provide to them as a non-standard >>> extension. >> >> S\" is a very widely implemented standard extension that is also >> pretty easy to implement on the Forths I've found that lack it. > > It may be easy to implement, but you haven't done so --- you are > waiting for somebody smart to implement it for you. > > I don't know what S\" does --- if anybody knows what this does and > can describe it, I will try to write it --- if anybody has already > written it, and their code is ANS-Forth, I'll put it in the > novice-package. > Here's a challenge. Read the spec & write it without having others do your homework. http://forth-standard.org/standard/file/Sq See if you can do it without requiring 2500 lines of novice package to be included first. We'll wait. -- Alex
[toc] | [prev] | [next] | [standalone]
| From | Alex <alex@rivadpm.com> |
|---|---|
| Date | 2017-04-15 00:36 +0100 |
| Message-ID | <ocrm7m$ftb$2@dont-email.me> |
| In reply to | #57334 |
On 4/15/2017 00:34, Alex wrote: > On 4/15/2017 00:24, hughaguilar96@gmail.com wrote: >> On Friday, April 14, 2017 at 3:35:55 PM UTC-7, Julian Fondren wrote: >>> On Friday, April 14, 2017 at 4:46:18 PM UTC-5, hughag...@gmail.com >>> wrote: >>>> These ANS-Forth experts seem to know almost nothing about >>>> ANS-Forth! Code that is trivial to write in ANS-Forth they expect >>>> the compiler-writer to provide to them as a non-standard >>>> extension. >>> >>> S\" is a very widely implemented standard extension that is also >>> pretty easy to implement on the Forths I've found that lack it. >> >> It may be easy to implement, but you haven't done so --- you are >> waiting for somebody smart to implement it for you. >> >> I don't know what S\" does --- if anybody knows what this does and >> can describe it, I will try to write it --- if anybody has already >> written it, and their code is ANS-Forth, I'll put it in the >> novice-package. >> > > Here's a challenge. Read the spec & write it without having others do > your homework. > > http://forth-standard.org/standard/file/Sq > > See if you can do it without requiring 2500 lines of novice package to > be included first. We'll wait. > My error pasting; it's http://forth-standard.org/standard/file/Seq -- Alex
[toc] | [prev] | [next] | [standalone]
Page 1 of 3 [1] 2 3 Next page →
Back to top | Article view | comp.lang.forth
csiph-web