Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Almost nothing in Perl serves a single purpose. -- Larry Wall in <199712040054.QAA13811@wall.org>


devel / comp.lang.forth / Re: IMMEDIATE and def_macro

SubjectAuthor
* IMMEDIATE and def_macronone
+* Re: IMMEDIATE and def_macroKaz Kylheku
|`- Re: IMMEDIATE and def_macronone
`* Re: IMMEDIATE and def_macroNN
 `* Re: IMMEDIATE and def_macroccur...@gmail.com
  `* Re: IMMEDIATE and def_macroNN
   `- Re: IMMEDIATE and def_macronone

1
IMMEDIATE and def_macro

<nnd$274ec76a$1e14a220@7c962486245f4d15>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=23963&group=comp.lang.forth#23963

  copy link   Newsgroups: comp.lang.forth comp.lang.lisp
Newsgroups: comp.lang.forth,comp.lang.lisp
Subject: IMMEDIATE and def_macro
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$274ec76a$1e14a220@7c962486245f4d15>
Organization: KPN B.V.
Date: Fri, 07 Jul 2023 14:15:27 +0200
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe006.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 45
Injection-Date: Fri, 07 Jul 2023 14:15:27 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2521
 by: none - Fri, 7 Jul 2023 12:15 UTC

I'm trying to implement mal on ciforth
https://github.com/kanaka/mal
Amounts to implementing a dialect of lisp using a dialect of Forth.

In step 8 I encounter the following:

-Add a new attribute is_macro to mal function types. This should
default to false.

Am I mistaken or is this the familiar immediate flag added to
Forth definitions?

- Add a new special form defmacro!. This is very similar to the def!
form, but before the evaluated value (mal function) is set in the
environment, the is_macro attribute should be set to true.

Much like colon definitions, later to be modified by IMMEDIATE to add
that behaviour.

- Add a macroexpand function: This function takes arguments ast and env.
It calls is_macro_call with ast and env and loops while that condition
is true. Inside the loop, the first element of the ast list (a
symbol), is looked up in the environment to get the macro function.
This macro function is then called/applied with the rest of the ast
elements (2nd through the last) as arguments. The return value of the
macro call becomes the new value of ast. When the loop completes
because ast no longer represents a macro call, the current value of
ast is returned.

How is this different from executing an immediate definition in
the middle of deferring an action? The only difference seems
to be that Forth does this much cleaner and with less caveats.
First and foremost it is far easier to keep track of arguments.
They reside on the stack.

Am I the first to notice this? Chuck Moore was a student of McCarthy.
Perhaps he invented Forth as a simpler version of lisp.

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: IMMEDIATE and def_macro

<20230707102938.23@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=23966&group=comp.lang.forth#23966

  copy link   Newsgroups: comp.lang.forth comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.forth,comp.lang.lisp
Subject: Re: IMMEDIATE and def_macro
Date: Fri, 7 Jul 2023 17:57:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 99
Message-ID: <20230707102938.23@kylheku.com>
References: <nnd$274ec76a$1e14a220@7c962486245f4d15>
Injection-Date: Fri, 7 Jul 2023 17:57:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f779c27224260df751517bdd9ccf5abe";
logging-data="1483085"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19x7gwo5scIU0El3ZYROmti0XsLzezCU+w="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:8Nlm8JEem3PpK63mw38uuj2xz5M=
 by: Kaz Kylheku - Fri, 7 Jul 2023 17:57 UTC

On 2023-07-07, albert@cherry.(none) (albert) <albert@cherry> wrote:
> I'm trying to implement mal on ciforth
> https://github.com/kanaka/mal
> Amounts to implementing a dialect of lisp using a dialect of Forth.
>
> In step 8 I encounter the following:
>
> -Add a new attribute is_macro to mal function types. This should
> default to false.
>
> Am I mistaken or is this the familiar immediate flag added to
> Forth definitions?

It may be similar. Macros are invoked during expansion.
Code can be expanded without being executed immediately. Or
at all. For instance

;; function is only defined, not called; but macro is called
(defun foo ()
(macro ..))

;; macro likely called in spite of being dead code.
;; (unless expander handles trivial dead code elimination cases).
(if nil
(macro ...))

> - Add a new special form defmacro!. This is very similar to the def!
> form, but before the evaluated value (mal function) is set in the
> environment, the is_macro attribute should be set to true.
>
> Much like colon definitions, later to be modified by IMMEDIATE to add
> that behaviour.

There amy be some similarities, but that doesn't necessarily mean
you can solve the MAL task by mapping macros directly to IMMEDIATE
words.
>
> - Add a macroexpand function: This function takes arguments ast and env.
> It calls is_macro_call with ast and env and loops while that condition
> is true.
>
> How is this different from executing an immediate definition in
> the middle of deferring an action? The only difference seems
> to be that Forth does this much cleaner and with less caveats.
> First and foremost it is far easier to keep track of arguments.
> They reside on the stack.

The user of the macro system doesn't have any problem with argument
tracking; arguments nicely appear as lexically scoped identifiers,
bound on entry into the function.

If you're writing code in Forth to make that work, then of course
that is your problem.

If you're making a Forth from scratch, you have to implement
several stacks yourself.

If you're making a Lisp from scratch, you have to implement
environments.

The simplest possible implementation of environments is stack-like.
The environment is the head of an association list, which looks like
this: ((b . 1) (a . 2)) for an environment which contains two
variables a and b bound to values 1 and 2.

A new binding is created with cons:

(cons (cons 'c 3) previous-env)

In some Lisps like Common Lisp, there is an acons for this:

(acons 'c 3 previous-env)

a new env is returned which looks like ((c . 3) (b . 1) (a . 2)).

The new environment doesn't clobber the old one; the environment
is a local variable in a recursive interpreter, passed around through
its recursion.

That's a reference model for a lexically scoped Lisp that came
into the Lisp culture mainly via the Scheme influence.

A lexically scoped Lisp doesn't have to reveal to the programs
the detailed representation of environments. Unless a special
escape hatch is provided for it, programs don't see the hidden
"env" variable. This is a good thing because it allows programs
to be compiled. Compiled code uses a radically different
representation of the environment.

> Am I the first to notice this? Chuck Moore was a student of McCarthy.
> Perhaps he invented Forth as a simpler version of lisp.

Even assembly languages have actions that are done now, while
assembling the code, and not at run-time.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: IMMEDIATE and def_macro

<nnd$7e70b6b4$022046df@684c07a62c9b2601>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=23972&group=comp.lang.forth#23972

  copy link   Newsgroups: comp.lang.forth comp.lang.lisp
Newsgroups: comp.lang.forth,comp.lang.lisp
References: <nnd$274ec76a$1e14a220@7c962486245f4d15> <20230707102938.23@kylheku.com>
Subject: Re: IMMEDIATE and def_macro
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$7e70b6b4$022046df@684c07a62c9b2601>
Organization: KPN B.V.
Date: Sat, 08 Jul 2023 10:05:06 +0200
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe005.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 88
Injection-Date: Sat, 08 Jul 2023 10:05:06 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 3891
 by: none - Sat, 8 Jul 2023 08:05 UTC

In article <20230707102938.23@kylheku.com>,
Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>On 2023-07-07, albert@cherry.(none) (albert) <albert@cherry> wrote:
>> I'm trying to implement mal on ciforth
>> https://github.com/kanaka/mal
>> Amounts to implementing a dialect of lisp using a dialect of Forth.
>>
<SNIP>
(much appreciated insight)

>
>If you're writing code in Forth to make that work, then of course
>that is your problem.
>
>If you're making a Forth from scratch, you have to implement
>several stacks yourself.
>
>If you're making a Lisp from scratch, you have to implement
>environments.
>
>The simplest possible implementation of environments is stack-like.
>The environment is the head of an association list, which looks like
>this: ((b . 1) (a . 2)) for an environment which contains two
>variables a and b bound to values 1 and 2.

That is available in Forth under the name wordlist.
There is a structure name VOCABULARY that have names and
traditionally are linked among themselves, that can be used
to point to outer environments.

>
>A new binding is created with cons:
>
> (cons (cons 'c 3) previous-env)

In my forth this is implemented as
[``set'' and ``get'' is the name prescribed by mal.]
\ Add symbol value to the current.
: set >R $, R@ >NFA ! R> CURRENT @ LINK ;
Note that each of these components are available in the Forth
core.
Finding a name through a recursive environments is done by
\ For sc env-wid , return item . or throw. Follow outer links.
: get
BEGIN DUP >R (FIND) DUP 0= WHILE
DROP R> WID>VFA @ DUP 0= 8010 ?ERROR
>WID REPEAT
NIP NIP RDROP ;
Likewise each of the components are present in the Forth core.
Not necessarily ISO standard words, but language components
needed to implement Forth that are repurposed.

>
>In some Lisps like Common Lisp, there is an acons for this:
>
> (acons 'c 3 previous-env)
>
>a new env is returned which looks like ((c . 3) (b . 1) (a . 2)).
>
>The new environment doesn't clobber the old one; the environment
>is a local variable in a recursive interpreter, passed around through
>its recursion.
>
>That's a reference model for a lexically scoped Lisp that came
>into the Lisp culture mainly via the Scheme influence.
>
>A lexically scoped Lisp doesn't have to reveal to the programs
>the detailed representation of environments. Unless a special
>escape hatch is provided for it, programs don't see the hidden
>"env" variable. This is a good thing because it allows programs
>to be compiled. Compiled code uses a radically different
>representation of the environment.

This recursive fibonacci function works
(def! fib (fn* (N) (if (= N 0) 1 (if (= N 1) 1 \
(+ (fib (- N 1)) (fib (- N 2)))))))

So the idea that Forth dictionary entries can serve as lisp "objects"
and that wordlists can serve as hashes has worked so far.

>Kas
Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: IMMEDIATE and def_macro

<f636ccef-d345-4c82-89b8-36257fe0a301n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=23982&group=comp.lang.forth#23982

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:57d2:0:b0:635:6fb4:ec58 with SMTP id y18-20020ad457d2000000b006356fb4ec58mr67929qvx.1.1688995624203;
Mon, 10 Jul 2023 06:27:04 -0700 (PDT)
X-Received: by 2002:a63:b555:0:b0:557:3ed2:395f with SMTP id
u21-20020a63b555000000b005573ed2395fmr8691105pgo.12.1688995623637; Mon, 10
Jul 2023 06:27:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 10 Jul 2023 06:27:03 -0700 (PDT)
In-Reply-To: <nnd$274ec76a$1e14a220@7c962486245f4d15>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23c5:6f05:3a01:9df3:bac8:fdc0:4691;
posting-account=9A5f7goAAAD_QfJPZnlK3Xq_UhzYjdP-
NNTP-Posting-Host: 2a00:23c5:6f05:3a01:9df3:bac8:fdc0:4691
References: <nnd$274ec76a$1e14a220@7c962486245f4d15>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f636ccef-d345-4c82-89b8-36257fe0a301n@googlegroups.com>
Subject: Re: IMMEDIATE and def_macro
From: november.nihal@gmail.com (NN)
Injection-Date: Mon, 10 Jul 2023 13:27:04 +0000
Content-Type: text/plain; charset="UTF-8"
 by: NN - Mon, 10 Jul 2023 13:27 UTC

On Friday, 7 July 2023 at 13:15:31 UTC+1, none albert wrote:
> I'm trying to implement mal on ciforth
> https://github.com/kanaka/mal
> Amounts to implementing a dialect of lisp using a dialect of Forth.
>
> In step 8 I encounter the following:
>
> -Add a new attribute is_macro to mal function types. This should
> default to false.
>
> Am I mistaken or is this the familiar immediate flag added to
> Forth definitions?
>
> - Add a new special form defmacro!. This is very similar to the def!
> form, but before the evaluated value (mal function) is set in the
> environment, the is_macro attribute should be set to true.
>
> Much like colon definitions, later to be modified by IMMEDIATE to add
> that behaviour.
>
> - Add a macroexpand function: This function takes arguments ast and env.
> It calls is_macro_call with ast and env and loops while that condition
> is true. Inside the loop, the first element of the ast list (a
> symbol), is looked up in the environment to get the macro function.
> This macro function is then called/applied with the rest of the ast
> elements (2nd through the last) as arguments. The return value of the
> macro call becomes the new value of ast. When the loop completes
> because ast no longer represents a macro call, the current value of
> ast is returned.
>
> How is this different from executing an immediate definition in
> the middle of deferring an action? The only difference seems
> to be that Forth does this much cleaner and with less caveats.
> First and foremost it is far easier to keep track of arguments.
> They reside on the stack.
>
> Am I the first to notice this? Chuck Moore was a student of McCarthy.
> Perhaps he invented Forth as a simpler version of lisp.
>
> Groetjes Albert
> --
> Don't praise the day before the evening. One swallow doesn't make spring.
> You must not say "hey" before you have crossed the bridge. Don't sell the
> hide of the bear until you shot it. Better one bird in the hand than ten in
> the air. First gain is a cat spinning. - the Wise from Antrim -

I did not know Mr Moore was a student of McCarthy.

If its the case Mr Moore was knowledgeable about lisp its not a big leap to see him
coming up with a simpler version we now know as forth. But I have never seen
Mr Moore say that either, so perhaps we are wrong to make this assumption.
( can someone can ask at the next svfig meeting ? )

Re: IMMEDIATE and def_macro

<901d630b-84a4-47b1-a228-2df5fb1b1bf3n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24003&group=comp.lang.forth#24003

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a0c:bece:0:b0:634:80af:caec with SMTP id f14-20020a0cbece000000b0063480afcaecmr19159qvj.0.1689167004398;
Wed, 12 Jul 2023 06:03:24 -0700 (PDT)
X-Received: by 2002:a9d:6ad1:0:b0:6b9:620e:d6a7 with SMTP id
m17-20020a9d6ad1000000b006b9620ed6a7mr2012091otq.1.1689167003992; Wed, 12 Jul
2023 06:03:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 12 Jul 2023 06:03:23 -0700 (PDT)
In-Reply-To: <f636ccef-d345-4c82-89b8-36257fe0a301n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.226.84.101; posting-account=6vDblwoAAACW49Ffg8eFokdu0AA_JQb0
NNTP-Posting-Host: 136.226.84.101
References: <nnd$274ec76a$1e14a220@7c962486245f4d15> <f636ccef-d345-4c82-89b8-36257fe0a301n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <901d630b-84a4-47b1-a228-2df5fb1b1bf3n@googlegroups.com>
Subject: Re: IMMEDIATE and def_macro
From: ccurl609@gmail.com (ccur...@gmail.com)
Injection-Date: Wed, 12 Jul 2023 13:03:24 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1563
 by: ccur...@gmail.com - Wed, 12 Jul 2023 13:03 UTC

To me, in the Forth context, MACRO means to copy the code in the MACRO's definition into the word, as opposed to compiling a call to the word.

I support MACROs in my dialect for 2 reasons; I call them INLINE.

(1) it improves the performance by removing the overhead of the call
(2) it can save memory ... my implementation is byte-coded, so on a 64-bit system, a call takes 9 bytes.

- Chris

Re: IMMEDIATE and def_macro

<c5639efe-14c0-47ca-8631-78f502275a37n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24008&group=comp.lang.forth#24008

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:bc1:b0:635:93ec:4d87 with SMTP id ff1-20020a0562140bc100b0063593ec4d87mr5897qvb.2.1689267557837;
Thu, 13 Jul 2023 09:59:17 -0700 (PDT)
X-Received: by 2002:a05:6870:a8a5:b0:1b0:1957:da4c with SMTP id
eb37-20020a056870a8a500b001b01957da4cmr2100640oab.0.1689267557456; Thu, 13
Jul 2023 09:59:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 13 Jul 2023 09:59:17 -0700 (PDT)
In-Reply-To: <901d630b-84a4-47b1-a228-2df5fb1b1bf3n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23c5:6f05:3a01:9bdd:20c:bf12:300d;
posting-account=9A5f7goAAAD_QfJPZnlK3Xq_UhzYjdP-
NNTP-Posting-Host: 2a00:23c5:6f05:3a01:9bdd:20c:bf12:300d
References: <nnd$274ec76a$1e14a220@7c962486245f4d15> <f636ccef-d345-4c82-89b8-36257fe0a301n@googlegroups.com>
<901d630b-84a4-47b1-a228-2df5fb1b1bf3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c5639efe-14c0-47ca-8631-78f502275a37n@googlegroups.com>
Subject: Re: IMMEDIATE and def_macro
From: november.nihal@gmail.com (NN)
Injection-Date: Thu, 13 Jul 2023 16:59:17 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 17
 by: NN - Thu, 13 Jul 2023 16:59 UTC

On Wednesday, 12 July 2023 at 14:03:25 UTC+1, ccur...@gmail.com wrote:
> To me, in the Forth context, MACRO means to copy the code in the MACRO's definition into the word, as opposed to compiling a call to the word.
>
> I support MACROs in my dialect for 2 reasons; I call them INLINE.
>
> (1) it improves the performance by removing the overhead of the call
> (2) it can save memory ... my implementation is byte-coded, so on a 64-bit system, a call takes 9 bytes.
>
> - Chris

In forth definitions are compiled or executed. Forth works with words and lisp works with forms.
I can imagine an example where code is in a string which is then inserted into another string before
being compiled or writing a special word that inserts postpone(s) into definition.

I could never get the second one working it was too complicated for me. The first one worked but I
didnt have a usecase for it.

How did you get your macro to copy code from a macro into a word ?

Re: IMMEDIATE and def_macro

<nnd$31e7b488$3610ba1b@3386041020792a4e>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24010&group=comp.lang.forth#24010

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: IMMEDIATE and def_macro
References: <nnd$274ec76a$1e14a220@7c962486245f4d15> <f636ccef-d345-4c82-89b8-36257fe0a301n@googlegroups.com> <901d630b-84a4-47b1-a228-2df5fb1b1bf3n@googlegroups.com> <c5639efe-14c0-47ca-8631-78f502275a37n@googlegroups.com>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$31e7b488$3610ba1b@3386041020792a4e>
Organization: KPN B.V.
Date: Thu, 13 Jul 2023 20:43:26 +0200
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 63
Injection-Date: Thu, 13 Jul 2023 20:43:26 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 3216
 by: none - Thu, 13 Jul 2023 18:43 UTC

In article <c5639efe-14c0-47ca-8631-78f502275a37n@googlegroups.com>,
NN <november.nihal@gmail.com> wrote:
>On Wednesday, 12 July 2023 at 14:03:25 UTC+1, ccur...@gmail.com wrote:
>> To me, in the Forth context, MACRO means to copy the code in the
>MACRO's definition into the word, as opposed to compiling a call to the
>word.
>>
>> I support MACROs in my dialect for 2 reasons; I call them INLINE.
>>
>> (1) it improves the performance by removing the overhead of the call
>> (2) it can save memory ... my implementation is byte-coded, so on a
>64-bit system, a call takes 9 bytes.
>>
>> - Chris
>
>In forth definitions are compiled or executed. Forth works with words
>and lisp works with forms.
>I can imagine an example where code is in a string which is then
>inserted into another string before
> being compiled or writing a special word that inserts postpone(s) into
>definition.
>
>I could never get the second one working it was too complicated for me.
>The first one worked but I
>didnt have a usecase for it.
>
>How did you get your macro to copy code from a macro into a word ?

A simple method is to compile it and than copy the result in line.
It requires a bit of carnal knowledge.

10 \ Alias of :, define a word that inlines it code.
11 : :I CREATE IMMEDIATE ] LATEST HIDDEN !CSP
12 DOES> STATE @ IF BEGIN $@ DUP '(;) <> WHILE , REPEAT 2DROP
13 ELSE >R THEN ;

It is state smart so that it executes in interpret mode.
It handles unpaired returns stack manipulations,
but obviously that can only be used in compile mode.
It copies the compiled code after CREATE into the current definition
until an EXIT i.e. (;) is encountered.
If relative branches are used, it happily inserts loops and ifs.
(;) is an alias for EXIT , such that the code can contain an exit.

Don't bother with POSTPONE's , that is cumbersome.

LATEST HIDDEN is to be replaced by code to manipulate the smudge
bit or some such.

It is not really that hard.

Example
:I add + ;

: sum3 add add ;

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor