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


Groups > comp.lang.forth > #56452

Re: Define a variable only not defined.

From Alex <alex@rivadpm.com>
Newsgroups comp.lang.forth
Subject Re: Define a variable only not defined.
Date 2017-03-29 14:41 +0100
Organization A noiseless patient Spider
Message-ID <obgdcf$cjq$1@dont-email.me> (permalink)
References <252d2e3a-a277-4447-9bb0-7de4955d03d6@googlegroups.com> <60ffebaf-082e-440e-a294-d9ebb64a38cc@googlegroups.com> <0d6a701e-6d94-4880-8242-8b09ebd793ec@googlegroups.com> <ir9ahuw05px3.qz5gr8urz6n3.dlg@40tude.net>

Show all headers | View raw


On 3/29/2017 13:58, Coos Haak wrote:
> Op Wed, 29 Mar 2017 04:26:54 -0700 (PDT) schreef Faisal:
>
>> Is this can be written as forth word?
>
> : newvar	( "ccc" -- )
>         >in @ bl word find nip 0=
>         if      >in ! variable
>         else    drop
>         then
>     ;
>
> groet Coos
>

With the caveat that if it doesn't declare a variable if there is a 
pre-existing word of the same name in the search order,

: foo 2 3 ;
newvar foo
10 foo !

is likely to cause the system to fail as it tries to store 2 into 3.

-- 
Alex

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


Thread

Define a variable only not defined. Faisal <faisalm83@gmail.com> - 2017-03-29 02:39 -0700
  Re: Define a variable only not defined. minforth@arcor.de - 2017-03-29 04:20 -0700
    Re: Define a variable only not defined. Faisal <faisalm83@gmail.com> - 2017-03-29 04:26 -0700
      Re: Define a variable only not defined. Coos Haak <htrofhc@gmail.com> - 2017-03-29 14:58 +0200
        Re: Define a variable only not defined. Alex <alex@rivadpm.com> - 2017-03-29 14:41 +0100
        Re: Define a variable only not defined. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-29 13:54 +0000
          Re: Define a variable only not defined. Mikael Nordman <oh2aun@gmail.com> - 2017-03-29 12:06 -0700
            Re: Define a variable only not defined. Coos Haak <htrofhc@gmail.com> - 2017-03-29 21:30 +0200
              Re: Define a variable only not defined. Mikael Nordman <oh2aun@gmail.com> - 2017-03-29 12:53 -0700
  Re: Define a variable only not defined. "HAA" <someone@microsoft.com> - 2017-03-30 10:03 +1000
    Re: Define a variable only not defined. Julian Fondren <julian.fondren@gmail.com> - 2017-03-29 19:00 -0700
      Re: Define a variable only not defined. "Elizabeth D. Rather" <erather@forth.com> - 2017-03-29 16:35 -1000

csiph-web