On 2025-06-24 01:03, minforth wrote:Are you sure? gforth test:
[...]
For me, the small syntax extension is a convenience when working
with longer definitions. A bit contrived (:= synonym for TO):
: SOME-APP { a f: b c | temp == n: flag z: freq }
\ inputs: integer a, floats b c
\ uninitialized: float temp
\ outputs: integer flag, complex freq
  <: FUNC < ... calc function ... > ;>
BTW, why do you prefer the special syntax `<: ... ;>`
over an extension to the existing words `:` and `;`
 : SOME-APP
    [ : FUNC < ... calc function ... > ; ]
    < ... >
 ;
In this approach the word `:` knows that it's a nested definition and
behaves accordingly.
Backtrace:app<<<
On 2025-07-02 15:37, albert@spenarnc.xs4all.nl wrote:
Or it has not even know it, if [ is smart enough to compile a jump to
after ].
This can be tricky because the following should work:
create foo [ 123 , ] [ 456 ,
: bar [ ' foo compile, 123 lit, ] ;
On 2025-07-02 13:02, minforth wrote:
Am 02.07.2025 um 10:53 schrieb Ruvim:
On 2025-06-24 01:03, minforth wrote:Are you sure? gforth test:
[...]
For me, the small syntax extension is a convenience when working
with longer definitions. A bit contrived (:= synonym for TO):
: SOME-APP { a f: b c | temp == n: flag z: freq }
\ inputs: integer a, floats b c
\ uninitialized: float temp
\ outputs: integer flag, complex freq
  <: FUNC < ... calc function ... > ;>
BTW, why do you prefer the special syntax `<: ... ;>`
over an extension to the existing words `:` and `;`
  : SOME-APP
     [ : FUNC < ... calc function ... > ; ]
     < ... >
  ;
In this approach the word `:` knows that it's a nested definition and
behaves accordingly.
: APP 1 [ : func 2 ; ] func ;Â ok
app
*the terminal*:2:1: error: Invalid memory address
This is not standard, just like `<: ;>`
My question is why did you introduce `<:` and `;>` instead of extending
the `:` and `;` behavior?
Ruvim <ruvim.pinka@gmail.com> writes:
On 2025-07-02 15:37, albert@spenarnc.xs4all.nl wrote:
Or it has not even know it, if [ is smart enough to compile a jump to
after ].
This can be tricky because the following should work:
create foo [ 123 , ] [ 456 ,
: bar [ ' foo compile, 123 lit, ] ;
The benefit of defining a normal colon definition inside another colon definition eludes me, however. Maybe mutual recursion, but the need
is rare and deferred words handle that well.
On 2025-07-02 19:12, Anton Ertl wrote:
The benefit of defining a normal colon definition inside another colon
definition eludes me, however. Maybe mutual recursion, but the need
is rare and deferred words handle that well.
As I can see, the idea is that the name of a nested definition has the >limited scope — the same as a local variable, and it is not visible
outside of the containing definition.
Backtrace:foo1<<<
On 2025-07-02 15:37, albert@spenarnc.xs4all.nl wrote:
In article <1042s2o$3d58h$1@dont-email.me>,
Ruvim <ruvim.pinka@gmail.com> wrote:
On 2025-06-24 01:03, minforth wrote:
[...]
For me, the small syntax extension is a convenience when working
with longer definitions. A bit contrived (:= synonym for TO):
: SOME-APP { a f: b c | temp == n: flag z: freq }
\ inputs: integer a, floats b c
\ uninitialized: float temp
\ outputs: integer flag, complex freq
 <: FUNC < ... calc function ... > ;>
BTW, why do you prefer the special syntax `<: ... ;>`
over an extension to the existing words `:` and `;`
: SOME-APP
[ : FUNC < ... calc function ... > ; ]
< ... >
;
In this approach the word `:` knows that it's a nested definition and
behaves accordingly.
Or it has not even know it, if [ is smart enough to compile a jump to
after ].
This can be tricky because the following should work:
create foo [ 123 , ] [ 456 ,
: bar [ ' foo compile, 123 lit, ] ;
--
Ruvim
On 2025-07-03 17:11, albert@spenarnc.xs4all.nl wrote:
In article <1043831$3ggg9$1@dont-email.me>,
Ruvim <ruvim.pinka@gmail.com> wrote:
On 2025-07-02 15:37, albert@spenarnc.xs4all.nl wrote:
In article <1042s2o$3d58h$1@dont-email.me>,
Ruvim <ruvim.pinka@gmail.com> wrote:
On 2025-06-24 01:03, minforth wrote:
[...]
For me, the small syntax extension is a convenience when working
with longer definitions. A bit contrived (:= synonym for TO):
: SOME-APP { a f: b c | temp == n: flag z: freq }
\ inputs: integer a, floats b c
\ uninitialized: float temp
\ outputs: integer flag, complex freq
<: FUNC < ... calc function ... > ;>
BTW, why do you prefer the special syntax `<: ... ;>`
over an extension to the existing words `:` and `;`
: SOME-APP
[ : FUNC < ... calc function ... > ; ]
< ... >
;
In this approach the word `:` knows that it's a nested
definition and behaves accordingly.
Or it has not even know it, if [ is smart enough to compile a
jump to after ].
This can be tricky because the following should work:
create foo [ 123 , ] [ 456 ,
: bar [ ' foo compile, 123 lit, ] ;
If this bothers you, rename it in [[ ]].
Once we enhance [ ] to do things prohibited by the standard,
(adding nested definitions) I can't be bothered with this too much.
The standard does not prohibit a system from supporting nested
definitions in whichever way that does not violate the standard
behavior.
Yes, something like "private[ ... ]private" is a possible approach,
and its implementation seems simpler than adding the smarts to `:`
and `;` (and other defining words, if any).
The advantage of this approach over "<: ... ;>" is that you can
define not only colon-definitions, but also constants, variables,
immediate words, one-time macros, etc.
: foo ( F: r.coefficient -- r.result )
private[
variable cnt
0e fvalue k
: [x] ... ; immediate
]private
to k 0 cnt !
...
;
It's also possible to associated the word list of private words with
the containing word xt for debugging purposes.
--
Ruvim
In lxf I have module, private, public, end-module
your example would be
module
private
variable cnt
0e fvalue k
: [x] ... ; immediate
public
: foo ( F: r.coefficient -- r.result )
to k 0 cnt !
...
;
end-module
end-module will remove all headers from the private words in the module
I am not fond of mixing definitions inside others.
The standard does not prohibit a system from supporting nested
definitions in whichever way that does not violate the standard behavior.
It's also possible to associated the word list of private words with the >containing word xt for debugging purposes.
--
Ruvim
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 145:27:29 |
Calls: | 10,383 |
Calls today: | 8 |
Files: | 14,054 |
D/L today: |
2 files (1,861K bytes) |
Messages: | 6,417,685 |