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


Groups > comp.lang.forth > #8512

Re: dot-quote implementation question

From "Rod Pemberton" <do_not_have@noavailemail.cmm>
Newsgroups comp.lang.forth
Subject Re: dot-quote implementation question
Date 2011-12-31 05:52 -0500
Organization Aioe.org NNTP Server
Message-ID <jdmpe1$kcb$1@speranza.aioe.org> (permalink)
References (12 earlier) <f4e32f99-7fc0-4839-9336-09c970930129@f33g2000yqh.googlegroups.com> <jdh8se$sae$1@speranza.aioe.org> <dd825268-f575-4665-ba8d-bd6297b89455@z12g2000yqm.googlegroups.com> <jdkvtq$r0f$1@speranza.aioe.org> <724b7ee6-9199-4566-b504-c8b90203cd4d@d8g2000yqk.googlegroups.com>

Show all headers | View raw


"BruceMcF" <agila61@netscape.net> wrote in message
news:724b7ee6-9199-4566-b504-c8b90203cd4d@d8g2000yqk.googlegroups.com...
> On Dec 30, 1:31 pm, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
> wrote:

> So, you are going to leave the CFA as DOVAR.

I'm going to attempt to ...

> How precisely
> does that result in a call to the does segment?

It doesn't.

> You don't have a working DOES>
> unless the does segment gets executed.

It should.

> That requires the address of the does segment
> to be stored in the CREATEd word.

It is.


CONSTANT, which uses DOES>, does this:

DOVAR   ( CFA )
<comma'd constant>       ( 1st PF )
... ( optional compiled addresses )
DODOES
DOES> address
... ( optional compiled addresses )
EXIT

DOVAR executes placing the address of the constant on the stack.  It will
continue execution at DODOES. (not currently implemented)  DODOES pushes the
IP on the stack, gets the DOES> address and pushes that on the return stack.
EXIT returns to pushed address.  It seems to me that DODOES no longer needs
to push the IP since DOVAR is doing that.

> There is a third solution, actually, which is to make it a doubly
> indirect threaded compiler ~ have the contents at the code field
> address be the address of a C function pointer rather than being a C
> function pointer itself. Then you can embed the C function pointer for
> DODOES at the head of the DOES segment and you are set.

I'd have to review how exactly I did that.  There was quite a bit of
juggling until I found an ANSI C compatible solution for addresses,
constants, function pointers, etc.  I.e., I'm not sure at the moment for
which one the C type would be correct.

> > I decide to eliminate DOCON since I also have LIT. Why use a
> > primitive for a constant that can only be used in the CFA when I can
> > use LIT for constants anywhere as long as I use ENTER ... EXIT?
>
> The normal rationale is efficiency ~ saving the execution of the ENTER
> and EXIT. If the focus is on a small kernel, its fine to have pre-
> compiled constants using LIT.

Yes, but in my case that adds a primitive, i.e., C code, instead of Forth
code as text or precompiled in C.

> > If LIT can fetch the next value from the instruction stream, place
> > it on the stack, and continue execution with the next compiled
> > address, then one should be able to code a similar word that
> > places the address of the next value on the stack and continues
> > execution.
>
> Where would you use it?

DOVAR, the DODOES described above, ...

> [...] is not used anywhere else, its hard to see what
> the benefit is.

Well, it should eliminate a primitive which is C code.  One primitive is not
a big issue, but the fewer the better.  The Forth code can become more
generalized or standardized and less C environment specific.

> > As for the DOES>, the changed definition seems to be compiling
> > properly and in a way I think should work. But, I would need to
> > change DOVAR to allow execution to continue with the next compiled
> > address after the variable value.
>
> But you can't use that alternate DOVAR for CREATE, because CREATE
> can have a body much longer than just one cell. Just consider a normal
> long string constant,
>
> : $CONSTANT ( ca u "name" )
>    CREATE DUP , HERE SWAP CHARS DUP ALLOT MOVE
>    DOES> DUP @ SWAP CELL+ ;
>
> Where its:
>       <name-structure>
> CFA:  DOCREATE ; or maybe DODOES
>       ; ?? Maybe one cell padding for DOES> segment address
>       .word u ; stored cell long length
>       .char ... ; "u" chars in string.

I think $CONSTANT would do this:

<dictionary header>
CFA: DOVAR
comma'd constant
.string ... ;  ( non-standard format )
DODOES
DOES> address
EXIT

Yes, if DOVAR continues execution after the constant, that would require a
branch or 'DOSTR' to skip over ALLOT'd space ...  So, there are some issues
with user defined strings and arrays.  I think a different definition could
place the ALLOT'd space after the code ...  If so, is this an implementation
issue?  I.e., are there or could there be some Forth's for which the
$CONSTANT definition will fail validly?  , COMMA and C, seem to be the
primary uses of ALLOT, at least in what I've coded so far.  It's possible
that ALLOT could be modified or duplicated so that large allocations place a
branch around the allotted space.  String concatenation or linked lists via
multiple ALLOTs might be an issue.  Are those done that way in Forth?
Anyway, just a thought ...


Rod Pemberton



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


Thread

Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-13 09:47 -0500
  Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-17 04:57 -0500
    Re: dot-quote implementation question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-12-17 04:20 -0600
      Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-18 07:18 -0500
        Re: dot-quote implementation question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-12-18 06:30 -0600
          Re: dot-quote implementation question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-12-20 03:04 -0600
  Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-17 08:15 -0800
    Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-18 07:53 -0500
      Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-18 09:14 -0800
        Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-19 05:24 -0500
          Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-19 09:11 -0800
            Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-19 10:53 -0800
          Re: dot-quote implementation question "Elizabeth D. Rather" <erather@forth.com> - 2011-12-19 08:38 -1000
            Re: dot-quote implementation question "A. K." <akk@nospam.org> - 2011-12-19 21:34 +0100
              Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-19 12:51 -0800
      Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-18 10:16 -0800
      Re: dot-quote implementation question "Elizabeth D. Rather" <erather@forth.com> - 2011-12-18 08:18 -1000
        Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-19 05:25 -0500
          Re: dot-quote implementation question Coos Haak <chforth@hccnet.nl> - 2011-12-19 22:23 +0100
            Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-20 10:53 -0500
              Re: dot-quote implementation question Coos Haak <chforth@hccnet.nl> - 2011-12-20 19:58 +0100
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-20 11:44 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-21 16:16 -0500
              Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-20 11:50 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-21 14:56 -0500
          Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-21 21:49 -0500
      Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-18 14:33 -0800
        Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-19 05:26 -0500
          Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-19 09:38 -0800
            Re: dot-quote implementation question "Elizabeth D. Rather" <erather@forth.com> - 2011-12-19 08:49 -1000
              Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-19 13:04 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-20 10:57 -0500
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-20 12:23 -0800
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-20 14:27 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-21 16:14 -0500
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-21 14:53 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-21 21:48 -0500
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-21 22:02 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-29 03:39 -0500
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-29 12:37 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-30 13:31 -0500
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-30 11:12 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-31 05:52 -0500
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-31 11:33 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-31 20:10 -0500
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-31 19:12 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-01-04 05:13 -0500
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2012-01-04 12:49 -0800
                Re: dot-quote implementation question Coos Haak <chforth@hccnet.nl> - 2011-12-22 00:55 +0100
                Re: dot-quote implementation question Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-12-20 21:43 +0000
              Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-19 13:25 -0800
                Re: dot-quote implementation question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-12-20 03:00 -0600
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-20 04:40 -0800
                Re: dot-quote implementation question Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-12-20 21:55 +0000
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-20 14:33 -0800
                Re: dot-quote implementation question Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-12-22 20:33 +0000
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-22 13:32 -0800
                Re: dot-quote implementation question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-12-21 03:01 -0600
                Re: dot-quote implementation question Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-12-22 20:38 +0000
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-20 10:53 -0500
            Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-20 10:49 -0500
              Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-20 08:20 -0800
          Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-20 04:49 -0800
            Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-20 10:58 -0500
              Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-21 08:41 -0800
                Re: dot-quote implementation question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-12-21 16:14 -0500
                Re: dot-quote implementation question BruceMcF <agila61@netscape.net> - 2011-12-21 15:14 -0800

csiph-web