Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #60741

Re: "Control structure mismatch" with simple if-else-then inSwiftForth

From "Robert L." <No_spamming@noWhere_7073.org>
Newsgroups comp.lang.forth
Subject Re: "Control structure mismatch" with simple if-else-then inSwiftForth
Date 2017-06-14 16:21 +0000
Organization Aioe.org NNTP Server
Message-ID <ohrnpu$19k3$1@gioia.aioe.org> (permalink)
References <a2c14f1a-2f79-4f3a-a56a-e99b0327785e@googlegroups.com> <ohrjii$l0k$1@dont-email.me>

Show all headers | View raw


On 6/14/2017, hum9 wrote:

> On 14.06.2017 17:22, christopherdumas@gmail.com wrote:
> > I'm new to Forth and I've recently downloaded the Free Trial of SwiftForth, which I am exceedingly happy with, because it integrates with Emacs and is one of the nicest, most dynamic and interactive languages I've used. However, there is just a tiny problem: I can't get a simple if-else-then to work in the REPL. Here is my code so far:
> > 
> > 0 2 rnd 1 = if 1+ else 2 * then       Control structure mismatch
> > 
> > It seems simple (and correct) to me. I'm sure its probably something simple that I'm missing, but there's no info on the internet on "Control structure mismatch"es. On a side note, this:
> > 
> > : TEST ( n -- ) dup 0= IF drop ELSE process THEN ;
> > 
> > seems to work, but this:
> > 
> > 7 dup 0= IF drop ELSE process THEN
> > 
> > Does not. So I'm thinking that control structures don't work unless they are in definitions? Is this correct at all? I seem to vaguely remember something about this from the GForth manual. Thanks!
> > 
> 
> Hi!
> 
> Keep stack balanced:
> 
> 0 2 rnd ( n )
> 1 = ( f )
> IF ( ) 1+ ELSE ( ) 2 * THEN
> 
> so when you do '1+' it have nothing on stack,
> when '*' have just number '2' in stack and must have two numbers.
> 
> It have a very easy remedy, so let you fix it:)
> 
> Have a nice day,
> hum9

That doesn't work at all.

IF ( ) 1+ ELSE ( ) 2 * THEN
:4: Interpreting a compile-only word
>>>IF<<< ( ) 1+ ELSE ( ) 2 * THEN

How does giving us code that is totally invalid
help us have a nice day?

You and Gavino are the ideal worshippers of Forth.

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

"Control structure mismatch" with simple if-else-then in SwiftForth christopherdumas@gmail.com - 2017-06-14 07:22 -0700
  Re: "Control structure mismatch" with simple if-else-then in SwiftForth Cecil Bayona <cbayona@cbayona.com> - 2017-06-14 09:47 -0500
    Re: "Control structure mismatch" with simple if-else-then in SwiftForth "Elizabeth D. Rather" <erather@forth.com> - 2017-06-14 08:47 -1000
      Re: "Control structure mismatch" with simple if-else-then in SwiftForth hughaguilar96@gmail.com - 2017-06-16 11:22 -0700
        Re: "Control structure mismatch" with simple if-else-then in SwiftForth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-06-16 20:31 +0200
          Re: "Control structure mismatch" with simple if-else-then in SwiftForth "Elizabeth D. Rather" <erather@forth.com> - 2017-06-16 16:29 -1000
        Re: "Control structure mismatch" with simple if-else-then in SwiftForth Cecil Bayona <cbayona@cbayona.com> - 2017-06-16 15:38 -0500
          Re: "Control structure mismatch" with simple if-else-then in SwiftForth Julian Fondren <julian.fondren@gmail.com> - 2017-06-16 18:12 -0700
          Re: "Control structure mismatch" with simple if-else-then in SwiftForth peter.m.falth@gmail.com - 2017-06-17 15:10 -0700
            Re: "Control structure mismatch" with simple if-else-then in SwiftForth "Robert L." <No_spamming@noWhere_7073.org> - 2017-06-18 00:50 +0000
  Re: "Control structure mismatch" with simple if-else-then in SwiftForth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-14 14:47 +0000
    Re: "Control structure mismatch" with simple if-else-then in SwiftForth "Robert L." <No_spamming@noWhere_7073.org> - 2017-06-14 16:16 +0000
      Re: "Control structure mismatch" with simple if-else-then in SwiftForth julian.fondren@endurance.com - 2017-06-14 09:34 -0700
      Re: "Control structure mismatch" with simple if-else-then in SwiftForth "HAA" <someone@microsoft.com> - 2017-06-16 10:20 +1000
        Re: "Control structure mismatch" with simple if-else-then in SwiftForth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-06-17 17:50 +0000
          Re: "Control structure mismatch" with simple if-else-then in SwiftForth Julian Fondren <julian.fondren@gmail.com> - 2017-06-17 12:11 -0700
  Re: "Control structure mismatch" with simple if-else-then in SwiftForth hum9 <obi65537@gmail.com> - 2017-06-14 18:12 +0300
    Re: "Control structure mismatch" with simple if-else-then inSwiftForth "Robert L." <No_spamming@noWhere_7073.org> - 2017-06-14 16:21 +0000
      Re: "Control structure mismatch" with simple if-else-then inSwiftForth Julian Fondren <julian.fondren@gmail.com> - 2017-06-14 09:37 -0700
        Re: "Control structure mismatch" with simple if-else-then inSwiftForth christopherdumas@gmail.com - 2017-06-14 10:48 -0700
  Re: "Control structure mismatch" with simple if-else-then in SwiftForth Julian Fondren <julian.fondren@gmail.com> - 2017-06-14 09:10 -0700
  Re: "Control structure mismatch" with simple if-else-then in SwiftForth The Beez <the.beez.speaks@gmail.com> - 2017-06-16 01:47 -0700
  Re: "Control structure mismatch" with simple if-else-then in SwiftForth "HAA" <someone@microsoft.com> - 2017-06-17 14:55 +1000

csiph-web