Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #51520 > unrolled thread
| Started by | albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| First post | 2016-10-02 02:43 +0200 |
| Last post | 2016-10-02 13:55 +0200 |
| Articles | 12 — 6 participants |
Back to article view | Back to comp.lang.forth
Is {{ taken? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-10-02 02:43 +0200
Re: Is {{ taken? Paul Rubin <no.email@nospam.invalid> - 2016-10-01 18:50 -0700
Re: Is {{ taken? Doug Hoffman <glidedog@gmail.com> - 2016-10-01 21:52 -0400
Re: Is {{ taken? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-10-02 10:37 +0200
Re: Is {{ taken? Doug Hoffman <glidedog@gmail.com> - 2016-10-02 04:46 -0400
Re: Is {{ taken? hughaguilar96@gmail.com - 2016-10-02 17:18 -0700
Re: Is {{ taken? Doug Hoffman <glidedog@gmail.com> - 2016-10-01 22:17 -0400
Re: Is {{ taken? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-10-02 11:17 +0200
Re: Is {{ taken? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-10-02 10:11 +0000
Re: Is {{ taken? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-10-02 13:46 +0200
Re: Is {{ taken? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-10-02 12:04 +0100
Re: Is {{ taken? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-10-02 13:55 +0200
| From | albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2016-10-02 02:43 +0200 |
| Subject | Is {{ taken? |
| Message-ID | <nspl78$fd4$1@cherry.spenarnc.xs4all.nl> |
Lispkit is written in Pascal. To translate it to Forth,
it would help if I had nested compilation with nested
scoping.
I was already experimenting with it, now I've a reason to
add it to an upcoming release.
:: and ;; ("colon-big" and "semi-big") are like : and ; but
they allow nested definitions by defining them
between {{ and }} . Forth is then in interpreter mode and any
newly defined words there can be used in the remainder of the word.
Like so:
\-----------------------------------------------
"DEFER" WANTED
\ Sort the range FIRST to LAST (inclusive) of item compared
\ by the xt COMPARING and exchanged by the xt EXHANGING.
\ The xt's are filled in into *< and *<--> and must observe the
\ interface. All indices must be compatible with these xt's.
\ After the call we have that :
\ ``For FIRST<=I<J<=LAST I J *< EXECUTE leaves TRUE.''
:: QSORT
{{
\ Compare item N1 and N2. Return ``N1'' IS lower and not equal.
DEFER *<
\ Exchange item N1 and N2.
DEFER *<-->
\ Partition inclusive range LO HI leaving LO_1 HI_1 LO_2 HI_2.
:: PARTITION
{{
VARIABLE low VARIABLE high VARIABLE median
: order-lmh
OVER low ! DUP high !
low @ high @ + 1+ 2/ median !
high @ low @ *< IF high @ low @ *<--> THEN
high @ median @ *< IF high @ median @ *<--> THEN
median @ low @ *< IF median @ low @ *<--> THEN
;
: interchange
low @ high @ *<-->
\ Do we have a new position for our pivot?
low @ median @ = IF high @ median ! ELSE
high @ median @ = IF low @ median ! THEN
THEN
;
}}
order-lmh
BEGIN ( lo_1 hi_2 lo_2 hi_1)
BEGIN 1 low +! low @ median @ *< NOT UNTIL
BEGIN -1 high +! median @ high @ *< NOT UNTIL
low @ high @ < WHILE
interchange
REPEAT
\ Works also in case they are equal, then they point to a pivot.
>R low @ 1- high @ 1+ R>
;;
}}
IS *<-->
IS *<
( lo hi -- )
\ Sort the range LOW to HIGH inclusive observing *<
DEPTH 2 - >R
BEGIN 2DUP < IF PARTITION ELSE 2DROP THEN DEPTH R@ = UNTIL
RDROP
;;
\-----------------------------------------------
About :: and ;; I'm pretty sure. I would have used [[ ]] big
brackets but these are taken IIRC.
Are the double curly brackets still available for this purpose?
And yes, this code actually works.
And no, this facility doesn't take too much code. In fact it
fits in one screen, commented and all.
And indeed, it kind of disproves LOCAL's. If you can't use local
variables in local colon definitions, what's their use?
Groetjes Albert
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2016-10-01 18:50 -0700 |
| Message-ID | <87vaxbzfgy.fsf@nightsong.com> |
| In reply to | #51520 |
albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes:
> And yes, this code actually works.
> And indeed, it kind of disproves LOCAL's.
Yet it seems a little too clever. The standard C library version is
basically:
: qsort { base nelts size *< } ... ;
calling itself recursively after partitioning, etc.
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2016-10-01 21:52 -0400 |
| Message-ID | <57f06844$0$340$14726298@news.sunsite.dk> |
| In reply to | #51520 |
On 10/1/16 8:43 PM, Albert van der Horst wrote:
I'm a bit puzzled as to why you are concerned with {{ being "taken".
I can't get much of anything you show to compile on an ANS Forth.
\----------------------------------------------- is an error
"DEFER" and WANTED both error
:: ;; {{ }} all are not defined
I'm sure there's more. But I gave up.
Clearly you have a home brew Forth so it seems to me you shouldn't be
worried about any standardization conflicts or "taken" words.
I have just a Macintosh but it runs 2 or 3 ANS compatible Forths. None
of them can run what you posted.
Or did you intend to subsequently provide ANS definitions?
-Doug
[toc] | [prev] | [next] | [standalone]
| From | albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2016-10-02 10:37 +0200 |
| Message-ID | <nsqh09$h4j$1@cherry.spenarnc.xs4all.nl> |
| In reply to | #51527 |
In article <57f06844$0$340$14726298@news.sunsite.dk>,
Doug Hoffman <glidedog@gmail.com> wrote:
>On 10/1/16 8:43 PM, Albert van der Horst wrote:
>
>I'm a bit puzzled as to why you are concerned with {{ being "taken".
>
>I can't get much of anything you show to compile on an ANS Forth.
>
>\----------------------------------------------- is an error
No it doesn't belong to the example, it delineates the example.
>
>"DEFER" and WANTED both error
>
>:: ;; {{ }} all are not defined
They are. Sure as hell they are!
I just don't show an implementation.
How can you even think those words are supplied in your
favourite Forth, while I so clearly am proposing something new
and give and example for illustration purposes?
>
>I'm sure there's more. But I gave up.
You're supposed to take in the example, not to run it.
>
>Clearly you have a home brew Forth so it seems to me you shouldn't be
>worried about any standardization conflicts or "taken" words.
>
>I have just a Macintosh but it runs 2 or 3 ANS compatible Forths. None
>of them can run what you posted.
>
>Or did you intend to subsequently provide ANS definitions?
I consider an Rfd.
By definition it makes sense to do Rfd's if an ISO definition is not possible.
Even Hugh now understands that Rfd's to extend the language and
portable definitions of a feature are sort of mutuablly exclusive.
For Rfd's it is important that the words proposed not clash with prior art.
That's what the question is about.
Although only 6 lines of code in ciforth (and 3 lines or 100 lines in
gforth, I don't know) my head spins even thinking about a portable solution.
>-Doug
>
Groetjes Albert
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2016-10-02 04:46 -0400 |
| Message-ID | <57f0c95f$0$336$14726298@news.sunsite.dk> |
| In reply to | #51532 |
On 10/2/16 4:37 AM, Albert van der Horst wrote: > I consider an Rfd. Ok. It would have helped to see that somewhere, perhaps in the subject line. -Doug
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2016-10-02 17:18 -0700 |
| Message-ID | <2a3d0674-fe3a-4312-8afe-5510c34f1c4c@googlegroups.com> |
| In reply to | #51532 |
On Sunday, October 2, 2016 at 1:28:34 AM UTC-7, Albert van der Horst wrote: > I consider an Rfd. > By definition it makes sense to do Rfd's if an ISO definition is not possible. > Even Hugh now understands that Rfd's to extend the language and > portable definitions of a feature are sort of mutuablly exclusive. > For Rfd's it is important that the words proposed not clash with prior art. > That's what the question is about. Albert v.d.Horst --- your gratuitous attacks on me are annoying --- you're a jerk! You are the same annoying jerk you attacked me in this thread, demanding that I remove the references to my novice-package from Wikipedia, and then continued attacking me even after I complied. You repeatedly posted non-working code in this thread which you claimed that I had written --- but my code from the novice-package does work --- you were totally lying. https://groups.google.com/forum/#!topic/comp.lang.forth/qqlp1gZnVic On Monday, November 25, 2013 at 4:20:14 PM UTC-7, Bernd Paysan wrote: > Albert van der Horst wrote: > > It sounds like you have a whole machinery in place to tests rng's. > > Would you mind adding LC53 to the list? > > > > \ Comma for clarity, not a double number. > > : LC53 -5 um* -333,333,333 + nip ; > > Hm, wasn't Hugh's LC53 > > : lc53 -333333333 um* -5 um/mod drop ; > > ? Don't make Hugh look more stupid than he actually is ;-).
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2016-10-01 22:17 -0400 |
| Message-ID | <57f06e4c$0$340$14726298@news.sunsite.dk> |
| In reply to | #51520 |
On 10/1/16 8:43 PM, Albert van der Horst wrote: :: has been used by Mini-OOF for a long time. Does that mean it is "taken"? I don't know. -Doug
[toc] | [prev] | [next] | [standalone]
| From | albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2016-10-02 11:17 +0200 |
| Message-ID | <nsqjc6$hce$1@cherry.spenarnc.xs4all.nl> |
| In reply to | #51528 |
In article <57f06e4c$0$340$14726298@news.sunsite.dk>,
Doug Hoffman <glidedog@gmail.com> wrote:
>On 10/1/16 8:43 PM, Albert van der Horst wrote:
>
>:: has been used by Mini-OOF for a long time.
>
>Does that mean it is "taken"? I don't know.
I would think yes.
Mini-OOF usage is pretty wide-spread and one could
want to combine it with nesting of definitions.
Thanks for helping me here. There are other solutions.
Think of the situation with S" whose description gets an update for the
case the FILE wordset is supplied.
That would be that the definition of [ be changed to have the
new meaning as {{. That would mean an example would look like
: test
[
VARIABLE aap
VARIABLE noot
: q aap @ 5 LSHIFT ;
]
... aap ! .. aap @ ..
;
This leads to overhead, because : has to have the functionality
of :: , just in case.
Or a complicated compile, where : sets
a marker and >IN is set back whenever a [ is encountered
and test is recompiled (un unforthy solution, and in the example
a more general parse pointer is needed than the line by line
>IN ) .
Or later removing the overhead, (being a non-linked-in wordlist
header in the dictionary) by moving code in the dictionary
if there are no nested definitions. That requires that compiled
code is relocatable. Because that cannot be checked, this will
lead to obscure problems.
Or adding the NESTED wordlist temporarily to the search order.
ALSO NESTED
: test ... ;
PREVIOUS
That may be the best solution because :: basically has the functionality
of : etc.
{
I've an INLINING wordset. If you want to inline
: p[] CELLS prime-table + ;
: m[] mertens-table + ;
: mu[] mu-table + ;
you can do
INLINING \ My namespaces push, no ALSO.
: p[] CELLS prime-table + ;
: m[] mertens-table + ;
: mu[] mu-table + ;
PREVIOUS
}
>
>-Doug
Groetjes Albert
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2016-10-02 10:11 +0000 |
| Message-ID | <2016Oct2.121136@mips.complang.tuwien.ac.at> |
| In reply to | #51520 |
albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes:
>:: and ;; ("colon-big" and "semi-big") are like : and ; but
>they allow nested definitions by defining them
>between {{ and }} . Forth is then in interpreter mode and any
>newly defined words there can be used in the remainder of the word.
Not sure why you would need :: and ;; for that. Bernd Paysan and I
have discussed factoring [: and ;] into a part that does the nesting
("[{" and "}]" <2015Jul29.093553@mips.complang.tuwien.ac.at>), and a
part that does the rest (which is mostly :NONAME and ;).
>Are the double curly brackets still available for this purpose?
The parser generator Gray uses {{...}} for actions.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2016: http://www.euroforth.org/ef16/
[toc] | [prev] | [next] | [standalone]
| From | albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2016-10-02 13:46 +0200 |
| Message-ID | <nsqs1t$huu$1@cherry.spenarnc.xs4all.nl> |
| In reply to | #51537 |
In article <2016Oct2.121136@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes:
>>:: and ;; ("colon-big" and "semi-big") are like : and ; but
>>they allow nested definitions by defining them
>>between {{ and }} . Forth is then in interpreter mode and any
>>newly defined words there can be used in the remainder of the word.
>
>Not sure why you would need :: and ;; for that. Bernd Paysan and I
>have discussed factoring [: and ;] into a part that does the nesting
>("[{" and "}]" <2015Jul29.093553@mips.complang.tuwien.ac.at>), and a
>part that does the rest (which is mostly :NONAME and ;).
So have [ and ] for interpretation mode and [{ }] for
interpretation mode that allows definitions.
That makes sense.
I think [{ is better. Even if it is not standardized it
is a good thing to use the same name already in experimental
extensions.
>
>>Are the double curly brackets still available for this purpose?
>
>The parser generator Gray uses {{...}} for actions.
And they are used in Mini-oof.
Why are :: and ;; needed?
That is a good question. In fact they are not.
In my implementation all local words are in a separate hidden wordlist
and not directly visible or executable, e.g. the PARTITION of a
QSORT makes little sense outside QSORT or without filled in defer's.
If you don't need or want that the :: and ;; are superfluous.
Conclusion, we can define :: and ;; to accomplish that any local definitions
are normally invisible, only accessable via a special mechanism (wordlist),
This is optional, and using it makes only sense if there are any
local definitions so it presupposes the usage of [{
(We may need a word ADD-INVISIBLE-WORDLIST_TO-SEARCH-ORDER: to add
it to the search order, to be released with PREVIOUS , while debugging.)
>
>- anton
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | Gerry Jackson <gerry@jackson9000.fsnet.co.uk> |
|---|---|
| Date | 2016-10-02 12:04 +0100 |
| Message-ID | <nsqpis$giu$1@dont-email.me> |
| In reply to | #51520 |
On 02/10/2016 01:43, Albert van der Horst wrote:
> Lispkit is written in Pascal. To translate it to Forth,
> it would help if I had nested compilation with nested
> scoping.
> I was already experimenting with it, now I've a reason to
> add it to an upcoming release.
>
> :: and ;; ("colon-big" and "semi-big") are like : and ; but
> they allow nested definitions by defining them
> between {{ and }} . Forth is then in interpreter mode and any
> newly defined words there can be used in the remainder of the word.
>
> Like so:
>
> \-----------------------------------------------
> "DEFER" WANTED
> \ Sort the range FIRST to LAST (inclusive) of item compared
> \ by the xt COMPARING and exchanged by the xt EXHANGING.
> \ The xt's are filled in into *< and *<--> and must observe the
> \ interface. All indices must be compatible with these xt's.
> \ After the call we have that :
> \ ``For FIRST<=I<J<=LAST I J *< EXECUTE leaves TRUE.''
> :: QSORT
> {{
> \ Compare item N1 and N2. Return ``N1'' IS lower and not equal.
> DEFER *<
> \ Exchange item N1 and N2.
> DEFER *<-->
> \ Partition inclusive range LO HI leaving LO_1 HI_1 LO_2 HI_2.
> :: PARTITION
> {{
> VARIABLE low VARIABLE high VARIABLE median
> : order-lmh
> OVER low ! DUP high !
> low @ high @ + 1+ 2/ median !
> high @ low @ *< IF high @ low @ *<--> THEN
> high @ median @ *< IF high @ median @ *<--> THEN
> median @ low @ *< IF median @ low @ *<--> THEN
> ;
> : interchange
> low @ high @ *<-->
> \ Do we have a new position for our pivot?
> low @ median @ = IF high @ median ! ELSE
> high @ median @ = IF low @ median ! THEN
> THEN
> ;
> }}
> order-lmh
> BEGIN ( lo_1 hi_2 lo_2 hi_1)
> BEGIN 1 low +! low @ median @ *< NOT UNTIL
> BEGIN -1 high +! median @ high @ *< NOT UNTIL
> low @ high @ < WHILE
> interchange
> REPEAT
> \ Works also in case they are equal, then they point to a pivot.
> >R low @ 1- high @ 1+ R>
> ;;
> }}
> IS *<-->
> IS *<
> ( lo hi -- )
> \ Sort the range LOW to HIGH inclusive observing *<
> DEPTH 2 - >R
> BEGIN 2DUP < IF PARTITION ELSE 2DROP THEN DEPTH R@ = UNTIL
> RDROP
> ;;
> \-----------------------------------------------
>
>
> About :: and ;; I'm pretty sure. I would have used [[ ]] big
> brackets but these are taken IIRC.
> Are the double curly brackets still available for this purpose?
>
> And yes, this code actually works.
> And no, this facility doesn't take too much code. In fact it
> fits in one screen, commented and all.
> And indeed, it kind of disproves LOCAL's. If you can't use local
> variables in local colon definitions, what's their use?
>
My system compiles to an intermediate code before laying down executable
code so, as an experiment a few years ago, I implemented nested
definitions simply by suspending the current definition, compiling the
nested definition(s) then resuming the outer definition. That made
implementation of quotations trivial.
So I can write stuff like:
: x ... [ : y ... { a b c }
[ : z ... [ variable w ] ... ; ]
... ;
]
...
;
But I never got around to hiding y z and w from the outside world, but I
think that could easily be handled by wordlists. No need for words like
:: {{ etc.
--
Gerry
[toc] | [prev] | [next] | [standalone]
| From | albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2016-10-02 13:55 +0200 |
| Message-ID | <nsqsk0$i14$1@cherry.spenarnc.xs4all.nl> |
| In reply to | #51541 |
In article <nsqpis$giu$1@dont-email.me>,
Gerry Jackson <gerry@jackson9000.fsnet.co.uk> wrote:
<SNIP>
>
>My system compiles to an intermediate code before laying down executable
>code so, as an experiment a few years ago, I implemented nested
>definitions simply by suspending the current definition, compiling the
>nested definition(s) then resuming the outer definition. That made
>implementation of quotations trivial.
>
>So I can write stuff like:
>
>: x ... [ : y ... { a b c }
> [ : z ... [ variable w ] ... ; ]
> ... ;
> ]
> ...
>;
This is basically the same idea. One can either start compiling
at a scratch area and MOVE anything that is ready to HERE, or
one can skip over a part of the dictionary using AHEAD which
is slightly messier.
>
>But I never got around to hiding y z and w from the outside world, but I
>think that could easily be handled by wordlists. No need for words like
>:: {{ etc.
That is a strange remark in view of the fact that :: and ;; are the
way I choose to handle wordlists to hide things. The hiding is not
really adding to the functionality.
I agree that {{ is superfluous and the capability can be added
to [ , without breaking existing code.
>
>--
>Gerry
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.forth
csiph-web