Before long I have used { and } for
:NONAME ... ;
and for
: .... [: ... ;] ;
alike.
The only addition was
: { ... STATE @ .. ;
: } ... STATE ! .. ;
The sequence { .. } leaves a literal, that should not be different
from interpret or compile state, compare the notation 'A' that is
valid through interpret and compile state and leave the same literal.
Do Forth's really run into difficulties with implementing this?
Or is it only possible on rigorously simple Forth's?
Notation matters. Leibniz over Newton.
Lambda's deserves a much more compact and elegant
notation than the clunky :NONAME !
Groetjes Albert
On 1/22/23 07:39, albert wrote:
Before long I have used { and } for
:NONAME ... ;
and for
: .... [: ... ;] ;
alike.
The only addition was
: { ... STATE @ .. ;
: } ... STATE ! .. ;
The sequence { .. } leaves a literal, that should not be different
from interpret or compile state, compare the notation 'A' that is
valid through interpret and compile state and leave the same literal.
Do Forth's really run into difficulties with implementing this?
Or is it only possible on rigorously simple Forth's?
Notation matters. Leibniz over Newton.
Lambda's deserves a much more compact and elegant
notation than the clunky :NONAME !
Groetjes Albert
kForth's definitions of [: and ;]
: [: postpone [ :noname ; immediate
: ;] postpone ; ] postpone literal ; immediate
There's a statement somewhere in the standard (Forth-94/Forth-2012)
stating that standard code will not nest definitions, named or unnamed
-- probably as a concession to simple Forth systems.
Krishna
Before long I have used { and } for
:NONAME ... ;
and for
: .... [: ... ;] ;
alike.
The only addition was
: { ... STATE @ .. ;
: } ... STATE ! .. ;
The sequence { .. } leaves a literal, that should not be different
from interpret or compile state, compare the notation 'A' that is
valid through interpret and compile state and leave the same literal.
Do Forth's really run into difficulties with implementing this?
On Sunday, January 22, 2023 at 2:39:25 PM UTC+1, none albert wrote:
Before long I have used { and } for
:NONAME ... ;
and for
: .... [: ... ;] ;
alike.
The only addition was
: { ... STATE @ .. ;
: } ... STATE ! .. ;
The sequence { .. } leaves a literal, that should not be different
from interpret or compile state, compare the notation 'A' that is
valid through interpret and compile state and leave the same literal.
You could have been more explicit when stating that this is simple in traditional Forth, and some examples why you think different Forths
might have problems would have helped understanding the issues.
In e.g. iForth :NONAME is not really different from : , that is, locals
and recursion are supported, and there is compiler security.
On Sunday, January 22, 2023 at 2:39:25 PM UTC+1, none albert wrote:
Before long I have used { and } for
:NONAME ... ;
and for
: .... [: ... ;] ;
alike.
The only addition was
: { ... STATE @ .. ;
: } ... STATE ! .. ;
The sequence { .. } leaves a literal, that should not be different
from interpret or compile state, compare the notation 'A' that is
valid through interpret and compile state and leave the same literal.
You could have been more explicit when stating that this is simple in >traditional Forth, and some examples why you think different Forths
might have problems would have helped understanding the issues.
In e.g. iForth :NONAME is not really different from : , that is, locals
and recursion are supported, and there is compiler security.
For instance, locals require that the locals wordlist is first in the >search-order. Therefore ";" and some other words have to undo that
effect. A straightforward :NONAME will therefore make the locals
of the surrounding word invisible, while the point of the embedded
definition may be to export same. Also, RECURSE and MYSELF after
the :NONAME .. ; might find the wrong xt, and compiler security
may check that colon definitions are not accidentally nested and
that the compiler stack balances.
At least a subroutine-threaded compiler for sure will lay down
code for the :NONAME , and that code will be right in the middle
of the enclosing word if nothing special (markers?) is done.
Maybe there is no problem when the Forth considers data inside a
colon definition as pure data and maintains that data as lists, but
these fine points of Forth are by now 40 years old and forgotten
(by me).
-marcel--
albert@cherry.(none) (albert) writes:
Do Forth's really run into difficulties with implementing this?
Gforth has interpretation semantics for [:...;]. The overall code for >[:...;] is quite elaborate:
: (int-;]) ( some-sys lastxt -- ) >r hm, wrap! r> ;
: (;]) ( some-sys lastxt -- )
>r
] postpone ENDSCOPE third locals-list ! postpone ENDSCOPE
finish-code hm, previous-section wrap! dead-code off
r> postpone Literal ;
: int-[: ( -- flag colon-sys )
wrap@ ['] (int-;]) :noname ;
: comp-[: ( -- quotation-sys flag colon-sys )
wrap@ next-section finish-code|
postpone SCOPE locals-list off postpone SCOPE
['] (;]) :noname ;
' int-[: ' comp-[: interpret/compile: [: ( compile-time: --
quotation-sys flag colon-sys ) \ gforth bracket-colon
\G Starts a quotation
: ;] ( compile-time: quotation-sys -- ; run-time: -- xt ) \ gforth semi-bracket
\g ends a quotation
POSTPONE ; swap execute ( xt ) ; immediate
Even with the interpretation semantics for [:, there is a difference
from :NONAME: After [:...;] restores LATESTXT etc., while :NONAME does
not.
- anton
In article <2023Jan2...@mips.complang.tuwien.ac.at>,
Anton Ertl <an...@mips.complang.tuwien.ac.at> wrote:
albert@cherry.(none) (albert) writes:
Do Forth's really run into difficulties with implementing this?
Gforth has interpretation semantics for [:...;]. The overall code for >[:...;] is quite elaborate:So, it is doable. [: ... ;] looks pretty silly if you are in interpret
mode ...
10 [: 1e ;] [: -1e ;] 2dup swap [: 0e ;] A f.for expressing Knuth's man-or-boy test in Forth.
On 23/01/2023 4:41 am, Marcel Hendrix wrote:
On Sunday, January 22, 2023 at 2:39:25 PM UTC+1, none albert wrote:
Before long I have used { and } for
:NONAME ... ;
and for
: .... [: ... ;] ;
alike.
The only addition was
: { ... STATE @ .. ;
: } ... STATE ! .. ;
The sequence { .. } leaves a literal, that should not be different
from interpret or compile state, compare the notation 'A' that is
valid through interpret and compile state and leave the same literal.
You could have been more explicit when stating that this is simple in traditional Forth, and some examples why you think different Forths
might have problems would have helped understanding the issues.
In e.g. iForth :NONAME is not really different from : , that is, localsFig-Forth has compiler security in the form of CSP so even there state
and recursion are supported, and there is compiler security.
needs to be saved/restored across quotations. Then there's the branching
hack to give the illusion of 'nested'. I like Elizabeth's response to
the whole thing at the time:
"Aside from looking obscure and clever and satisfying the "[x] can do
it, why not Forth?" test, what on earth does this buy you?"
Perhaps not surprisingly this was omitted from the 'official' discussion
and comments:
http://www.forth200x.org/quotations.txt
On Monday, 23 January 2023 at 03:39:50 UTC, dxforth wrote:
On 23/01/2023 4:41 am, Marcel Hendrix wrote:
On Sunday, January 22, 2023 at 2:39:25 PM UTC+1, none albert wrote:Fig-Forth has compiler security in the form of CSP so even there state
Before long I have used { and } for
:NONAME ... ;
and for
: .... [: ... ;] ;
alike.
The only addition was
: { ... STATE @ .. ;
: } ... STATE ! .. ;
The sequence { .. } leaves a literal, that should not be different
from interpret or compile state, compare the notation 'A' that is
valid through interpret and compile state and leave the same literal.
You could have been more explicit when stating that this is simple in
traditional Forth, and some examples why you think different Forths
might have problems would have helped understanding the issues.
In e.g. iForth :NONAME is not really different from : , that is, locals
and recursion are supported, and there is compiler security.
needs to be saved/restored across quotations. Then there's the branching
hack to give the illusion of 'nested'. I like Elizabeth's response to
the whole thing at the time:
"Aside from looking obscure and clever and satisfying the "[x] can do
it, why not Forth?" test, what on earth does this buy you?"
Perhaps not surprisingly this was omitted from the 'official' discussion
and comments:
http://www.forth200x.org/quotations.txt
The answer to Elizabeth's question is :
You might have come across the idea of "name code not data" or
name code not values ( https://concatenative.org/wiki/view/Concatenative%20language/Name%20code%20not%20values )
If thats is explored further to become dont name code and dont name values >then those unnamed code becomes quotations which exist only for as long as >needed.
What does it buy you ?
Your dictionary ceases to have "extra" words created to help other
words, reducing clutter and memory when its done too.
On Monday, 23 January 2023 at 03:39:50 UTC, dxforth wrote:
On 23/01/2023 4:41 am, Marcel Hendrix wrote:
On Sunday, January 22, 2023 at 2:39:25 PM UTC+1, none albert wrote:Fig-Forth has compiler security in the form of CSP so even there state
Before long I have used { and } for
:NONAME ... ;
and for
: .... [: ... ;] ;
alike.
The only addition was
: { ... STATE @ .. ;
: } ... STATE ! .. ;
The sequence { .. } leaves a literal, that should not be different
from interpret or compile state, compare the notation 'A' that is
valid through interpret and compile state and leave the same literal.
You could have been more explicit when stating that this is simple in
traditional Forth, and some examples why you think different Forths
might have problems would have helped understanding the issues.
In e.g. iForth :NONAME is not really different from : , that is, locals
and recursion are supported, and there is compiler security.
needs to be saved/restored across quotations. Then there's the branching
hack to give the illusion of 'nested'. I like Elizabeth's response to
the whole thing at the time:
"Aside from looking obscure and clever and satisfying the "[x] can do
it, why not Forth?" test, what on earth does this buy you?"
Perhaps not surprisingly this was omitted from the 'official' discussion
and comments:
http://www.forth200x.org/quotations.txt
The answer to Elizabeth's question is :
You might have come across the idea of "name code not data" or
name code not values ( https://concatenative.org/wiki/view/Concatenative%20language/Name%20code%20not%20values )
If thats is explored further to become dont name code and dont name values then those unnamed code becomes quotations which exist only for as long as needed.
What does it buy you ?
Your dictionary ceases to have "extra" words created to help other
words, reducing clutter and memory when its done too.
What does it buy you ?
Your dictionary ceases to have "extra" words created to help other
words, reducing clutter and memory when its done too.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 475 |
Nodes: | 16 (2 / 14) |
Uptime: | 18:20:47 |
Calls: | 9,487 |
Calls today: | 6 |
Files: | 13,617 |
Messages: | 6,121,091 |