Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Everyone is entitled to an *informed* opinion." -- Harlan Ellison


devel / comp.lang.forth / Re: conditional parameter passing

SubjectAuthor
* conditional parameter passingKrishna Myneni
+* Re: conditional parameter passingdxforth
|`- Re: conditional parameter passingKrishna Myneni
+* Re: conditional parameter passingPaul Rubin
|+* Re: conditional parameter passingKrishna Myneni
||+- Re: conditional parameter passingMarcel Hendrix
||`* Re: conditional parameter passingAnton Ertl
|| `- Re: conditional parameter passingKrishna Myneni
|`* Re: conditional parameter passingKrishna Myneni
| +- Re: conditional parameter passingKrishna Myneni
| `* Re: conditional parameter passingPaul Rubin
|  `* Re: conditional parameter passingminf...@arcor.de
|   `* Re: conditional parameter passingPaul Rubin
|    +* Re: conditional parameter passingKrishna Myneni
|    |`- Re: conditional parameter passingPaul Rubin
|    `* Re: conditional parameter passingminf...@arcor.de
|     +- Re: conditional parameter passingPaul Rubin
|     +* Re: conditional parameter passingDoug Hoffman
|     |+* Re: conditional parameter passingminf...@arcor.de
|     ||`- Re: conditional parameter passingDoug Hoffman
|     |`* Re: conditional parameter passingKrishna Myneni
|     | `* Re: conditional parameter passingDoug Hoffman
|     |  `- Re: conditional parameter passingKrishna Myneni
|     `* Re: conditional parameter passingKrishna Myneni
|      `* Re: conditional parameter passingdxforth
|       `* Re: conditional parameter passingKrishna Myneni
|        `- Re: conditional parameter passingdxforth
+* Re: conditional parameter passingAnton Ertl
|`* Re: conditional parameter passingKrishna Myneni
| `- Re: conditional parameter passingAnton Ertl
+- Re: conditional parameter passingKrishna Myneni
`- Re: conditional parameter passingminf...@arcor.de

Pages:12
conditional parameter passing

<sdim55$n0v$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14030&group=comp.lang.forth#14030

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: conditional parameter passing
Date: Sat, 24 Jul 2021 22:34:59 -0500
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <sdim55$n0v$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 03:35:01 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="04f98a02e72e28bd7bff593e39c7da2c";
logging-data="23583"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cSEe8q4U1X1d9V3zM8UZy"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:dst37mA+ps9th6RN15PJLj7I2Gg=
Content-Language: en-US
X-Mozilla-News-Host: snews://news.eternal-september.org:563
 by: Krishna Myneni - Sun, 25 Jul 2021 03:34 UTC

Recently, I had occasion to write a Forth word which takes two different
lengths of parameter lists. The word decides how many parameters to
remove from the stack based on a conditional test of the parameter on
top of the stack, either

( i*x n1 n2 n3 nc -- i*x )

or

( i*x n1 n2 n3 n4 nc -- i*x )

This is distinct from passing the number of arguments to the word on the
stack ( i*x n -- j*x ), a technique which is useful for storing data
from the stack into arrays or matrices (for example, see }FPUT or }}FPUT
utility words from the Forth Scientific Library).

My particular example was for initializing two different structures, one
of which has the same fields as the other, plus an extra field.

BEGIN-STRUCTURE TInfo% \ byte code token info
FIELD: T->NameCount \ name string count
FIELD: T->Name \ name string address
FIELD: T->OpCount \ trailing operand count in cells
END-STRUCTURE

BEGIN-STRUCTURE ExtTInfo% \ extended token info
drop TInfo% \ structure inherits TInfo% fields
FIELD: ET->NCaddr \ native code address
END-STRUCTURE

: ti! ( c-addr u noperands op | c-addr u nop addr-nc op -- )
dup MAX_TOKENS >= >r
op[]
r> IF tuck ET->NCaddr ! THEN
tuck T->OpCount !
tuck T->NameCount !
T->Name ! ;

The conditional test is made on the parameter "op", and determines
whether or not the extra field ET->NCaddr is also initialized from the
stack. The word OP[] returns an appropriate, previously allotted
structure address of the proper type, based on the value of "op" so
there are actually two conditional tests being performed within this code.

I don't know of non-stack-based languages which can specify procedures
which take a variable length of arguments based on a run-time
conditional test within the function. It's an interesting technique
which is easily done in Forth, but I don't recall having coded like this
before.

-- Krishna Myneni

Re: conditional parameter passing

<sdis2b$1v0o$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14031&group=comp.lang.forth#14031

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Sun, 25 Jul 2021 15:15:54 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sdis2b$1v0o$1@gioia.aioe.org>
References: <sdim55$n0v$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="64536"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Sun, 25 Jul 2021 05:15 UTC

On 25/07/2021 13:34, Krishna Myneni wrote:
>
> I don't know of non-stack-based languages which can specify procedures
> which take a variable length of arguments based on a run-time
> conditional test within the function.

Variable inputs amounts to a wrapper for discrete functions.

Re: conditional parameter passing

<87r1fnnd0r.fsf@nightsong.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14032&group=comp.lang.forth#14032

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Sat, 24 Jul 2021 23:06:12 -0700
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <87r1fnnd0r.fsf@nightsong.com>
References: <sdim55$n0v$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="635a38599f01249bcdbc0ad9f765077a";
logging-data="30439"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JzaG2+MZgRQUYS6pNN62D"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:OLaiweUOFMR6rqTuR3C6jHePyL8=
sha1:Pz7igHEM789NOkg3MmWF8KCc3jw=
 by: Paul Rubin - Sun, 25 Jul 2021 06:06 UTC

Krishna Myneni <krishna.myneni@ccreweb.org> writes:
> I don't know of non-stack-based languages which can specify procedures
> which take a variable length of arguments based on a run-time
> conditional test within the function.

You mean like printf in C?

Re: conditional parameter passing

<2021Jul25.080142@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14033&group=comp.lang.forth#14033

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Sun, 25 Jul 2021 06:01:42 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 86
Message-ID: <2021Jul25.080142@mips.complang.tuwien.ac.at>
References: <sdim55$n0v$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="3a9da7f4055550120b631e882934953b";
logging-data="4843"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZZ8glYVDzSaamLJJV4Osl"
Cancel-Lock: sha1:BzLL3OZfb24qNPSZQ1whosYJInQ=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 25 Jul 2021 06:01 UTC

Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>Recently, I had occasion to write a Forth word which takes two different
>lengths of parameter lists. The word decides how many parameters to
>remove from the stack based on a conditional test of the parameter on
>top of the stack, either
>
>( i*x n1 n2 n3 nc -- i*x )
>
>or
>
>( i*x n1 n2 n3 n4 nc -- i*x )
....
>My particular example was for initializing two different structures, one
>of which has the same fields as the other, plus an extra field.

In that case, use two words:

>BEGIN-STRUCTURE TInfo% \ byte code token info
> FIELD: T->NameCount \ name string count
> FIELD: T->Name \ name string address
> FIELD: T->OpCount \ trailing operand count in cells
>END-STRUCTURE
>
>BEGIN-STRUCTURE ExtTInfo% \ extended token info
> drop TInfo% \ structure inherits TInfo% fields
> FIELD: ET->NCaddr \ native code address
>END-STRUCTURE
>
>
>: ti! ( c-addr u noperands op | c-addr u nop addr-nc op -- )
> dup MAX_TOKENS >= >r
> op[]
> r> IF tuck ET->NCaddr ! THEN
> tuck T->OpCount !
> tuck T->NameCount !
> T->Name ! ;

Better:

: ti!1 ( c-addr u noperands op -- addr )
op[]
tuck T->OpCount !
tuck T->NameCount !
tuck T->Name ! ;

: ti! ( c-addr u noperands op -- )
ti!1 drop ;

: extti! ( addr-nc c-addr u nop op -- )
ti!1 ET->NCaddr ! ;

No conditions, no variable stack effects, easier to understand.

>I don't know of non-stack-based languages which can specify procedures
>which take a variable length of arguments based on a run-time
>conditional test within the function.

Lisp has optional parameters. C has them (in particular, printf()).
Probably others, too.

>It's an interesting technique
>which is easily done in Forth, but I don't recall having coded like this
>before.

Variable stack effects make the word and the code containing it harder
to understand and makes it harder to use. E.g., in this case, if you
only want to pass op as a constant, you can resolve the IF during
programming and call TI! or EXTTI! as appropriate; and if you want to
pass a run-time-determined op, you have to wrap your TI! in an IF that
supplies the additional parameter in one case and not in the other
case; and then you could again use my TI! and EXTTI! in the branches
of the IF.

Another option is to always supply the addr-nc parameter, and have an
IF that stores or drops it depending on whether it's an ExtTInfo% or a
TInfo%.

Yet another option is to use an object-oriented package and use the
initialization stuff of that.

- 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 2021: https://euro.theforth.net/2021

Re: conditional parameter passing

<sdjai7$rvr$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14034&group=comp.lang.forth#14034

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Sun, 25 Jul 2021 04:23:17 -0500
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <sdjai7$rvr$1@dont-email.me>
References: <sdim55$n0v$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 09:23:19 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="04f98a02e72e28bd7bff593e39c7da2c";
logging-data="28667"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yuIischPv3V4iNySclcai"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:YZBz9jzupvu5e32FwlEwiWYQK48=
In-Reply-To: <sdim55$n0v$1@dont-email.me>
Content-Language: en-US
 by: Krishna Myneni - Sun, 25 Jul 2021 09:23 UTC

On 7/24/21 10:34 PM, Krishna Myneni wrote:
> Recently, I had occasion to write a Forth word which takes two different
> lengths of parameter lists. The word decides how many parameters to
> remove from the stack based on a conditional test of the parameter on
> top of the stack, either
>
> ( i*x n1 n2 n3 nc -- i*x )
>
> or
>
> ( i*x n1 n2 n3 n4 nc -- i*x )
>
....
> I don't know of non-stack-based languages which can specify procedures
> which take a variable length of arguments based on a run-time
> conditional test within the function. It's an interesting technique
> which is easily done in Forth, but I don't recall having coded like this
> before.
>

It took me a moment to recognize this. It's a form of "polymorphism" or
"function overloading" in Forth. In C++ one can declare and implement a
function with several types of input parameter lists. The compiler
creates separate procedures for each but they can all be referenced by a
single name since the argument list is known at compile time. No
conditional tests are needed in that case.

In Forth we can implement "word overloading" if one of the parameters
has information about the type of the argument list to be used. The
cost, however, is a runtime test, which is less efficient. However, the
technique can be useful sometimes when it is desired to avoid creating
additional words.

Krishna

Re: conditional parameter passing

<sdjalg$rvr$2@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14035&group=comp.lang.forth#14035

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Sun, 25 Jul 2021 04:25:04 -0500
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <sdjalg$rvr$2@dont-email.me>
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 09:25:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="04f98a02e72e28bd7bff593e39c7da2c";
logging-data="28667"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/A9MjjW2jckgFYG+kGxOSF"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:61/yEf3Q4txiXIBnBJte7NoOOXA=
In-Reply-To: <87r1fnnd0r.fsf@nightsong.com>
Content-Language: en-US
 by: Krishna Myneni - Sun, 25 Jul 2021 09:25 UTC

On 7/25/21 1:06 AM, Paul Rubin wrote:
> Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>> I don't know of non-stack-based languages which can specify procedures
>> which take a variable length of arguments based on a run-time
>> conditional test within the function.
>
> You mean like printf in C?
>

No, I don't mean like printf(). The number of arguments is based on a
"run-time" conditional test, not on something done at compile time.

The example is more illustrative of function overloading in C++.

-- Krishna

Re: conditional parameter passing

<sdjbii$1vs$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14036&group=comp.lang.forth#14036

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Sun, 25 Jul 2021 04:40:32 -0500
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <sdjbii$1vs$1@dont-email.me>
References: <sdim55$n0v$1@dont-email.me>
<2021Jul25.080142@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 09:40:34 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="04f98a02e72e28bd7bff593e39c7da2c";
logging-data="2044"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kww/ZH22CtvfYaJKvpLW9"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:wEr2XeIIUh8F9PimJ/EREefFzko=
In-Reply-To: <2021Jul25.080142@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Krishna Myneni - Sun, 25 Jul 2021 09:40 UTC

On 7/25/21 1:01 AM, Anton Ertl wrote:
> Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>> Recently, I had occasion to write a Forth word which takes two different
>> lengths of parameter lists. The word decides how many parameters to
>> remove from the stack based on a conditional test of the parameter on
>> top of the stack, either
>>
>> ( i*x n1 n2 n3 nc -- i*x )
>>
>> or
>>
>> ( i*x n1 n2 n3 n4 nc -- i*x )
> ...
>> My particular example was for initializing two different structures, one
>> of which has the same fields as the other, plus an extra field.
>
> In that case, use two words:
>
....
>
> No conditions, no variable stack effects, easier to understand.
>

It is too rigid a stance to say don't use "word overloading" in Forth,
although it requires additional run-time tests. It can certainly be
mis-used. But in my particular application where I have to execute many
calls to "ti!" to initialize structures, it makes the coding simpler.

>> I don't know of non-stack-based languages which can specify procedures
>> which take a variable length of arguments based on a run-time
>> conditional test within the function.
>
> Lisp has optional parameters. C has them (in particular, printf()).
> Probably others, too.
>

Function overloading in C++ is the closest technique in non-stack-based
languages. This technique simply hides the different functions which are
created by the compiler, all of which can be referenced by a single name
based on the known argument list at compile-time.

-- Krishna

Re: conditional parameter passing

<sdjbke$1vs$2@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14037&group=comp.lang.forth#14037

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Sun, 25 Jul 2021 04:41:34 -0500
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <sdjbke$1vs$2@dont-email.me>
References: <sdim55$n0v$1@dont-email.me> <sdis2b$1v0o$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 09:41:35 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="04f98a02e72e28bd7bff593e39c7da2c";
logging-data="2044"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HIo7DjQAgSYjjHET66YJr"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:JOG0erjgzUEqV1mbJ1JRt1ls470=
In-Reply-To: <sdis2b$1v0o$1@gioia.aioe.org>
Content-Language: en-US
 by: Krishna Myneni - Sun, 25 Jul 2021 09:41 UTC

On 7/25/21 12:15 AM, dxforth wrote:
> On 25/07/2021 13:34, Krishna Myneni wrote:
>>
>> I don't know of non-stack-based languages which can specify procedures
>> which take a variable length of arguments based on a run-time
>> conditional test within the function.
>
> Variable inputs amounts to a wrapper for discrete functions.

Agreed. But discrete functions don't always need a separate name.

-- Krishna

Re: conditional parameter passing

<486b7658-b944-42e9-a59a-11845983945an@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14038&group=comp.lang.forth#14038

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:518f:: with SMTP id b15mr12682911qvp.52.1627206383518;
Sun, 25 Jul 2021 02:46:23 -0700 (PDT)
X-Received: by 2002:a05:620a:7e4:: with SMTP id k4mr12774146qkk.328.1627206383351;
Sun, 25 Jul 2021 02:46:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.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: Sun, 25 Jul 2021 02:46:23 -0700 (PDT)
In-Reply-To: <sdjalg$rvr$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:4922:49c6:c477:8386;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:4922:49c6:c477:8386
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com> <sdjalg$rvr$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <486b7658-b944-42e9-a59a-11845983945an@googlegroups.com>
Subject: Re: conditional parameter passing
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Sun, 25 Jul 2021 09:46:23 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1532
 by: Marcel Hendrix - Sun, 25 Jul 2021 09:46 UTC

On Sunday, July 25, 2021 at 11:25:06 AM UTC+2, Krishna Myneni wrote:
> No, I don't mean like printf(). The number of arguments is based on a
> "run-time" conditional test, not on something done at compile time.

printf() is using a mini interpreter and the ABI makes a conditional
test in the caller unnecessary. I use printf in DLLs called from Forth.

-marcel

Re: conditional parameter passing

<404bc2c7-e55f-4487-b46a-c99e176d9ce6n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14039&group=comp.lang.forth#14039

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:5cad:: with SMTP id q13mr13050004qvh.10.1627207545630;
Sun, 25 Jul 2021 03:05:45 -0700 (PDT)
X-Received: by 2002:ac8:7f48:: with SMTP id g8mr10867405qtk.79.1627207545482;
Sun, 25 Jul 2021 03:05:45 -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: Sun, 25 Jul 2021 03:05:45 -0700 (PDT)
In-Reply-To: <sdim55$n0v$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f2c:8b8d:75e1:2713:3940:8dcc;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f2c:8b8d:75e1:2713:3940:8dcc
References: <sdim55$n0v$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <404bc2c7-e55f-4487-b46a-c99e176d9ce6n@googlegroups.com>
Subject: Re: conditional parameter passing
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Sun, 25 Jul 2021 10:05:45 +0000
Content-Type: text/plain; charset="UTF-8"
 by: minf...@arcor.de - Sun, 25 Jul 2021 10:05 UTC

Krishna Myneni schrieb am Sonntag, 25. Juli 2021 um 05:35:05 UTC+2:
> Recently, I had occasion to write a Forth word which takes two different
> lengths of parameter lists. The word decides how many parameters to
> remove from the stack based on a conditional test of the parameter on
> top of the stack, either
>
> ( i*x n1 n2 n3 nc -- i*x )
>
> or
>
> ( i*x n1 n2 n3 n4 nc -- i*x )
>
> This is distinct from passing the number of arguments to the word on the
> stack ( i*x n -- j*x ), a technique which is useful for storing data
> from the stack into arrays or matrices (for example, see }FPUT or }}FPUT
> utility words from the Forth Scientific Library).
>
> My particular example was for initializing two different structures, one
> of which has the same fields as the other, plus an extra field.
>
>
> BEGIN-STRUCTURE TInfo% \ byte code token info
> FIELD: T->NameCount \ name string count
> FIELD: T->Name \ name string address
> FIELD: T->OpCount \ trailing operand count in cells
> END-STRUCTURE
>
> BEGIN-STRUCTURE ExtTInfo% \ extended token info
> drop TInfo% \ structure inherits TInfo% fields
> FIELD: ET->NCaddr \ native code address
> END-STRUCTURE
>

Make them a UNION.

Re: conditional parameter passing

<2021Jul25.160930@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14041&group=comp.lang.forth#14041

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Sun, 25 Jul 2021 14:09:30 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 38
Message-ID: <2021Jul25.160930@mips.complang.tuwien.ac.at>
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com> <sdjalg$rvr$2@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="3a9da7f4055550120b631e882934953b";
logging-data="31107"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182Qg//pUAt+YYTxLBTVT4R"
Cancel-Lock: sha1:514R+f1vFfwnjFgAkrLxp4uWKQ0=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 25 Jul 2021 14:09 UTC

Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>On 7/25/21 1:06 AM, Paul Rubin wrote:
>> Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>>> I don't know of non-stack-based languages which can specify procedures
>>> which take a variable length of arguments based on a run-time
>>> conditional test within the function.
>>
>> You mean like printf in C?
>>
>
>No, I don't mean like printf(). The number of arguments is based on a
>"run-time" conditional test, not on something done at compile time.
>
>The example is more illustrative of function overloading in C++.

Your TI! decides at run-time (based on the value on the top-of-stack
at run-time) how many stack items to consume.

C's printf() decides at run-time (based on the first parameter at
run-time) how many parameters to access.

C++'s overloading decides at compile time which function with the same
name, but different parameters to call (based on number and types of
all parameters, not based on the run-time value of one parameter).

Conclusion: Your TI! is like printf(), not like C++ overloading.

The reason is that Forth does not provide compile-time information on
the numbers and types of parameters. That's why you cannot have
overloading resolution, and that's why we have, e.g.,
.. U. D. F. etc.

- 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 2021: https://euro.theforth.net/2021

Re: conditional parameter passing

<2021Jul25.162126@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14042&group=comp.lang.forth#14042

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Sun, 25 Jul 2021 14:21:26 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 28
Message-ID: <2021Jul25.162126@mips.complang.tuwien.ac.at>
References: <sdim55$n0v$1@dont-email.me> <2021Jul25.080142@mips.complang.tuwien.ac.at> <sdjbii$1vs$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="3a9da7f4055550120b631e882934953b";
logging-data="31107"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/h51TFhb7kCUW+7mWleOqg"
Cancel-Lock: sha1:hH3uaVupuoBUvH1ArgkZbIU9lzE=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 25 Jul 2021 14:21 UTC

Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>It is too rigid a stance to say don't use "word overloading" in Forth,

Overloading resolution by the compiler is impossible for stuff on the
stack in Forth, because the compiler has no type or arity information.

Doing similar things with run-time resolution is unidiomatic, although
not unheard of.

There is also TO for which the compiler can resolve the overloading
based on the word type after the TO.

Makes me wonder whether your TI! could become another instance of "TO
name Run-Time" semantics. To do that, your TInfo and ExtTInfo
instances would have to be named words (and you need a Forth system
that (like Gforth) makes it easy to define the "TO name run-time"
action for new word types).

Another option for your example is to always have the ET->NCaddr in
your Tinfo structure, and pass, say, 0 as addr-nc parameter when
calling TI!.

- 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 2021: https://euro.theforth.net/2021

Re: conditional parameter passing

<sdk0jp$89f$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14043&group=comp.lang.forth#14043

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Sun, 25 Jul 2021 10:39:35 -0500
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <sdk0jp$89f$1@dont-email.me>
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
<sdjalg$rvr$2@dont-email.me> <2021Jul25.160930@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 15:39:37 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="04f98a02e72e28bd7bff593e39c7da2c";
logging-data="8495"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ckWEpuZ6sKK5RuGkAWjg+"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:7PMri6zpP7MDXUPiaSDdtSwERdc=
In-Reply-To: <2021Jul25.160930@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Krishna Myneni - Sun, 25 Jul 2021 15:39 UTC

On 7/25/21 9:09 AM, Anton Ertl wrote:
> Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>> On 7/25/21 1:06 AM, Paul Rubin wrote:
>>> Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>>>> I don't know of non-stack-based languages which can specify procedures
>>>> which take a variable length of arguments based on a run-time
>>>> conditional test within the function.
>>>
>>> You mean like printf in C?
>>>
>>
>> No, I don't mean like printf(). The number of arguments is based on a
>> "run-time" conditional test, not on something done at compile time.
>>
>> The example is more illustrative of function overloading in C++.
>
> Your TI! decides at run-time (based on the value on the top-of-stack
> at run-time) how many stack items to consume.
>
> C's printf() decides at run-time (based on the first parameter at
> run-time) how many parameters to access.
>

Certainly C's printf() parses the format string (first arg) at run-time.
However, I expect that the number of parameters it pushes onto the
machine stack (or in registers) is determined from the full argument
list at compile time.

> C++'s overloading decides at compile time which function with the same
> name, but different parameters to call (based on number and types of
> all parameters, not based on the run-time value of one parameter).
>
> Conclusion: Your TI! is like printf(), not like C++ overloading.
>

Yes, I'm aware that C++ overloading works in a different way from what
I'm doing with TI! . However, it is similar in use to overloaded functions.

I don't believe that TI! is precisely like printf() either -- for
example, the conditional test to determine the number and type of
arguments consumed by the word can be decided by more than one parameter.

> The reason is that Forth does not provide compile-time information on
> the numbers and types of parameters. That's why you cannot have
> overloading resolution, and that's why we have, e.g.,
> . U. D. F. etc.
>

I did not claim equivalency with C++ overloading -- that's clear in my
earlier post. I only note that when a parameter value can be used to
determine the logical number and type of parameters needed by the word,
the word name can be effectively overloaded. This is advantageous in
some instances. As you note, this can lead to confusion when not
carefully used.

-- Krishna

Re: conditional parameter passing

<sdm34a$q78$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14046&group=comp.lang.forth#14046

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Mon, 26 Jul 2021 05:34:48 -0500
Organization: A noiseless patient Spider
Lines: 88
Message-ID: <sdm34a$q78$1@dont-email.me>
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 26 Jul 2021 10:34:50 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ba36c7bb15c0e8973b9b4d5cbc677a19";
logging-data="26856"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196nH2GV/ed3ZSIV06FSCSg"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:ITx54TezO0O7H2bYarlgvgLHm+A=
In-Reply-To: <87r1fnnd0r.fsf@nightsong.com>
Content-Language: en-US
 by: Krishna Myneni - Mon, 26 Jul 2021 10:34 UTC

On 7/25/21 1:06 AM, Paul Rubin wrote:
> Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>> I don't know of non-stack-based languages which can specify procedures
>> which take a variable length of arguments based on a run-time
>> conditional test within the function.
>
> You mean like printf in C?
>

To illustrate two fundamental differences between a stack-based language
like Forth and languages like C and C++, let's consider the following
examples:

1. C++ (with overloaded function)
-------
void ti_store ( int Ncount, char* Name, int Ocount, int op );
void ti_store ( int Ncount, char* Name, int Ocount, byte* nc, int op );

int caller()
{ ....

if (op < 256)
ti_store( ncount, str, ocount, op );
else
ti_store( ncount, str, ocount, ncaddr, op );
....
}

2. C (printf example)
--------

int caller()
{ char* fmt1 = "Ncount: %d Name: %s Ocount: %d op: %d";
char* fmt2 = "Ncount: %d Name: %s Ocount: %d NC: %x op: %d";
....
if (op < 256)
printf( fmt1, ncount, str, ocount, op );
else
printf( fmt2, ncount, str, ocount, ncaddr, op );
....
}

3. Forth (with overloaded word)
-------

: caller ( -- )
....
ncount str ocount op
op 256 >= if ncaddr swap then ti!
....
;

4. Forth (analog of printf)
------------
: caller ( -- )
....
ncount str ocount op
op 256 >= if ncaddr swap then ti.
;

In example 1 (C++), the number of arguments to ti_store() and the
particular version of ti_store() to be called is decided at compile time
not at run time.

In example 2 (C), the number of arguments to printf() is determined at
compile time, not at run time. Furthermore, the format strings are
provided by the caller() for each of the two cases.

In contrast, in Forth (example 3), the number of arguments passed to
"TI!" is determined at run time. Also, in Forth (example 4), the output
formats for the two cases may be determined by "TI." (analog of printf)
and not by CALLER.

-- Krishna

Re: conditional parameter passing

<sdm9di$88e$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14048&group=comp.lang.forth#14048

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Mon, 26 Jul 2021 07:22:09 -0500
Organization: A noiseless patient Spider
Lines: 90
Message-ID: <sdm9di$88e$1@dont-email.me>
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
<sdm34a$q78$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 26 Jul 2021 12:22:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ba36c7bb15c0e8973b9b4d5cbc677a19";
logging-data="8462"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181hAAnOtmZGRcTp24oy09Q"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:7mO0rmI6r83HMth7nBiRP3R1YJ8=
In-Reply-To: <sdm34a$q78$1@dont-email.me>
Content-Language: en-US
 by: Krishna Myneni - Mon, 26 Jul 2021 12:22 UTC

On 7/26/21 5:34 AM, Krishna Myneni wrote:
> On 7/25/21 1:06 AM, Paul Rubin wrote:
>> Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>>> I don't know of non-stack-based languages which can specify procedures
>>> which take a variable length of arguments based on a run-time
>>> conditional test within the function.
>>
>> You mean like printf in C?
>>
>
> To illustrate two fundamental differences between a stack-based language
> like Forth and languages like C and C++, let's consider the following
> examples:
>
> 1. C++  (with overloaded function)
> -------
> void ti_store ( int Ncount, char* Name, int Ocount, int op );
> void ti_store ( int Ncount, char* Name, int Ocount, byte* nc, int op );
>
> int caller()
> {
> ...
>
>    if (op < 256)
>      ti_store( ncount, str, ocount, op );
>    else
>      ti_store( ncount, str, ocount, ncaddr, op );
> ...
> }
>
>
> 2. C (printf example)
> --------
>
> int caller()
> {
>    char* fmt1 = "Ncount: %d Name: %s Ocount: %d op: %d";
>    char* fmt2 = "Ncount: %d Name: %s Ocount: %d NC: %x op: %d";
> ...
>    if (op < 256)
>      printf( fmt1, ncount, str, ocount, op );
>   else
>      printf( fmt2, ncount, str, ocount, ncaddr, op );
> ...
> }
>
>
> 3. Forth (with overloaded word)
> -------
>
> : caller ( -- )
> ...
>     ncount str ocount op
>     op 256 >= if ncaddr swap then ti!
> ...
> ;
>
> 4. Forth (analog of printf)
> ------------
> : caller ( -- )
> ...
>    ncount str ocount op
>    op 256 >= if ncaddr swap then ti.
> ;
>
>
> In example 1 (C++), the number of arguments to ti_store() and the
> particular version of ti_store() to be called is decided at compile time
> not at run time.
>

Clarification: The particular version of ti_store() to be called in each
statement is decided at compile time in the C++ program. The branching,
which occurs at run-time, simply executes a function with a fixed
parameter list.

>
> In contrast, in Forth (example 3), the number of arguments passed to
> "TI!" is determined at run time. Also, in Forth (example 4), the output
> formats for the two cases may be determined by "TI." (analog of printf)
> and not by CALLER.
>

The latter statement about the formatting being decided by TI. is not
intended to be an example of a fundamental difference -- it can be done
with C as well.

-- KM

Re: conditional parameter passing

<87mtq9nldl.fsf@nightsong.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14049&group=comp.lang.forth#14049

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Mon, 26 Jul 2021 08:30:14 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <87mtq9nldl.fsf@nightsong.com>
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
<sdm34a$q78$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="22134713b7188bf826e05868c5e5dccc";
logging-data="20804"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/UQgKM3wWdPsTNTFkaXttw"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:0aUh6WMiIwZTLBwJSRz7XVlLrOM=
sha1:uGi0GECKzo5uu4JeQJSpx+hlQYA=
 by: Paul Rubin - Mon, 26 Jul 2021 15:30 UTC

Krishna Myneni <krishna.myneni@ccreweb.org> writes:
> In contrast, in Forth (example 3), the number of arguments passed to
> "TI!" is determined at run time. Also, in Forth (example 4), the
> output formats for the two cases may be determined by "TI." (analog of
> printf) and not by CALLER.

Ok, how about Lisp:

(apply #'+ '(1 2 3)) => returns 6

The '(1 2 3) is an arbitrary runtime list that gets passed to the +
function as args. Python etc. can do similar things.

Re: conditional parameter passing

<df8a9523-1dd4-415c-bee5-d669e681b0e0n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14051&group=comp.lang.forth#14051

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:1472:: with SMTP id j18mr18422416qkl.483.1627319717210; Mon, 26 Jul 2021 10:15:17 -0700 (PDT)
X-Received: by 2002:a0c:fbd1:: with SMTP id n17mr18810481qvp.19.1627319717074; Mon, 26 Jul 2021 10:15:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.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: Mon, 26 Jul 2021 10:15:16 -0700 (PDT)
In-Reply-To: <87mtq9nldl.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f2c:8b0d:4cd6:992e:a51f:bd20; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f2c:8b0d:4cd6:992e:a51f:bd20
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com> <sdm34a$q78$1@dont-email.me> <87mtq9nldl.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <df8a9523-1dd4-415c-bee5-d669e681b0e0n@googlegroups.com>
Subject: Re: conditional parameter passing
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Mon, 26 Jul 2021 17:15:17 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 20
 by: minf...@arcor.de - Mon, 26 Jul 2021 17:15 UTC

Paul Rubin schrieb am Montag, 26. Juli 2021 um 17:30:17 UTC+2:
> Krishna Myneni <krishna...@ccreweb.org> writes:
> > In contrast, in Forth (example 3), the number of arguments passed to
> > "TI!" is determined at run time. Also, in Forth (example 4), the
> > output formats for the two cases may be determined by "TI." (analog of
> > printf) and not by CALLER.
> Ok, how about Lisp:
>
> (apply #'+ '(1 2 3)) => returns 6
>
> The '(1 2 3) is an arbitrary runtime list that gets passed to the +
> function as args. Python etc. can do similar things.

That must have been said with tongue in cheek. ;-)

FWIW my Forth can do
m[ 1 2 ; 5 7 ] minv
or
m[ 2 ] minv
to invert a matrix. Anyhow it is not "arity-aware".

Re: conditional parameter passing

<87im0wolcj.fsf@nightsong.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14053&group=comp.lang.forth#14053

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Mon, 26 Jul 2021 13:45:32 -0700
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <87im0wolcj.fsf@nightsong.com>
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
<sdm34a$q78$1@dont-email.me> <87mtq9nldl.fsf@nightsong.com>
<df8a9523-1dd4-415c-bee5-d669e681b0e0n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="22134713b7188bf826e05868c5e5dccc";
logging-data="25139"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cpfzUV0JbedAFcUhFKtL4"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:2mvQpfvJiWXVh+Ced+gtFOw5ut0=
sha1:ShGqKCtCK5f4x4mVN8cE+TRskkE=
 by: Paul Rubin - Mon, 26 Jul 2021 20:45 UTC

"minf...@arcor.de" <minforth@arcor.de> writes:
>> (apply #'+ '(1 2 3)) => returns 6 ...
> That must have been said with tongue in cheek. ;-)
> FWIW my Forth can do
> m[ 1 2 ; 5 7 ] minv

I don't understand about tongue and cheek? '(1 2 3) is not passed to +
as a list, it is passed as args. (apply #'cons '(1 2)) is the same as
(cons 1 2). Cons takes exactly two args and (apply #'cons (1 2 3))
would throw a error from cons, because of the wrong arg count.

Re: conditional parameter passing

<sdno00$qap$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14054&group=comp.lang.forth#14054

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: krishna....@ccreweb.org (Krishna Myneni)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Mon, 26 Jul 2021 20:37:02 -0500
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <sdno00$qap$1@dont-email.me>
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
<sdm34a$q78$1@dont-email.me> <87mtq9nldl.fsf@nightsong.com>
<df8a9523-1dd4-415c-bee5-d669e681b0e0n@googlegroups.com>
<87im0wolcj.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 27 Jul 2021 01:37:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a949b37ead328db42db355d50b9d5477";
logging-data="26969"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JgeBbl1pTVUyOkDctn+pv"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:oAR61OEyxUlPqVOJOdbTxd1g/Gk=
In-Reply-To: <87im0wolcj.fsf@nightsong.com>
Content-Language: en-US
 by: Krishna Myneni - Tue, 27 Jul 2021 01:37 UTC

On 7/26/21 3:45 PM, Paul Rubin wrote:
> "minf...@arcor.de" <minforth@arcor.de> writes:
>>> (apply #'+ '(1 2 3)) => returns 6 ...
>> That must have been said with tongue in cheek. ;-)
>> FWIW my Forth can do
>> m[ 1 2 ; 5 7 ] minv
>
> I don't understand about tongue and cheek? '(1 2 3) is not passed to +
> as a list, it is passed as args. (apply #'cons '(1 2)) is the same as
> (cons 1 2). Cons takes exactly two args and (apply #'cons (1 2 3))
> would throw a error from cons, because of the wrong arg count.
>

All I see is a Lisp function, APPLY, which takes two fixed arguments: 1)
a reference to a binary operator and 2) a single parameter representing
a variable length list. APPLY iterates the operator over the length of
the list, which it can determine with no additional parameters. Your
example does not appear to involve passing a variable number of
arguments to a function.

However, I'll admit my knowledge of LISP isn't as deep as with C or C++.
If you provide the assembly code (x86 or x86_64) generated by your LISP
compiler (non-stack-based) for your example, I should be able say
whether or not this example is equivalent to the Forth examples I
provided for variable length arg list.

-- Krishna

Re: conditional parameter passing

<87eebknvhy.fsf@nightsong.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14056&group=comp.lang.forth#14056

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Mon, 26 Jul 2021 23:03:53 -0700
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <87eebknvhy.fsf@nightsong.com>
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
<sdm34a$q78$1@dont-email.me> <87mtq9nldl.fsf@nightsong.com>
<df8a9523-1dd4-415c-bee5-d669e681b0e0n@googlegroups.com>
<87im0wolcj.fsf@nightsong.com> <sdno00$qap$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="34c8ffbf4e82e9645cd88e63ef307b92";
logging-data="32710"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SXvRGFeEIqv0Y+YstnoL/"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:JAxy2gc4WzIiNEYHPv2E7Yf181A=
sha1:AKFBgo94+MZ7KU820ARHlRJsAQ0=
 by: Paul Rubin - Tue, 27 Jul 2021 06:03 UTC

Krishna Myneni <krishna.myneni@ccreweb.org> writes:
> All I see is a Lisp function, APPLY, which takes two fixed arguments:
> 1) a reference to a binary operator and 2) a single parameter
> representing a variable length list.

No the first arg is an arbitrary function (call it F), not necessarily a
binary operator. APPLY takes the second arg (the list), and supplies
its contents as individual args to F. So (apply #'foo '(1 2 3 4 5))
calls function foo with the five arguments 1 2 3 4 5. Foo doesn't
receive a list.

> If you provide the assembly code (x86 or x86_64) generated by your
> LISP compiler (non-stack-based) for your example

It would take me some fooling around to get asm code to post, but it's a
normal function call. For example, if FOO expects 5 args passed in
registers, then that's what happens. FOO would be written something
like

(DEFUN foo (first second third fourth fifth)
(.... code ...))

which would be like

: foo {: first second third fourth fifth :}

using Forth locals. The args passed to foo get bound to those names.

You can define functions that take variable numbers of args too, like

(DEFUN bar (first second &rest others)
(... code ... ))

and then saying (bar 1 2 3 4 5) would call bar, with "first" bound to 1,
"second" bound to 2, and "others" bound to the list '(3 4 5). The
special keyword &rest means that the func will take a variable # of
args, with the first few required and given names, and the rest received
as a list.

In the general case, above allocates temporary storage for the &rest
parameter '(3 4 5), with the GC later reclaiming the storage. So
everything is very dynamic (i.e. runtime-controlled), much more than
Forth is. You can confuse yourself pretty badly with that dynamicness
if you aren't careful. But Lisp makes things like that very convenient
compared to Forth, at the expense of memory consumption.

Re: conditional parameter passing

<3fa7328f-8593-4455-b725-91ca1a13cf84n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14057&group=comp.lang.forth#14057

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:8242:: with SMTP id e63mr21126314qkd.294.1627375138033;
Tue, 27 Jul 2021 01:38:58 -0700 (PDT)
X-Received: by 2002:a37:7c3:: with SMTP id 186mr21025256qkh.109.1627375137880;
Tue, 27 Jul 2021 01:38:57 -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: Tue, 27 Jul 2021 01:38:57 -0700 (PDT)
In-Reply-To: <87im0wolcj.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.157.99.156; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 87.157.99.156
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
<sdm34a$q78$1@dont-email.me> <87mtq9nldl.fsf@nightsong.com>
<df8a9523-1dd4-415c-bee5-d669e681b0e0n@googlegroups.com> <87im0wolcj.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3fa7328f-8593-4455-b725-91ca1a13cf84n@googlegroups.com>
Subject: Re: conditional parameter passing
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Tue, 27 Jul 2021 08:38:58 +0000
Content-Type: text/plain; charset="UTF-8"
 by: minf...@arcor.de - Tue, 27 Jul 2021 08:38 UTC

Paul Rubin schrieb am Montag, 26. Juli 2021 um 22:45:35 UTC+2:
> "minf...@arcor.de" <minf...@arcor.de> writes:
> >> (apply #'+ '(1 2 3)) => returns 6 ...
> > That must have been said with tongue in cheek. ;-)
> > FWIW my Forth can do
> > m[ 1 2 ; 5 7 ] minv
> I don't understand about tongue and cheek? '(1 2 3) is not passed to +
> as a list, it is passed as args. (apply #'cons '(1 2)) is the same as
> (cons 1 2). Cons takes exactly two args and (apply #'cons (1 2 3))
> would throw a error from cons, because of the wrong arg count.

https://dictionary.cambridge.org/de/worterbuch/englisch/tongue-in-cheek

To do that in Forth, the parser of a new word would have to evaluate
the stack annotation as necessary part of the word definition. Next step
would be a syntax tree in the compiler, etc etc.

It wouldn't be Forth anymore.

Re: conditional parameter passing

<87a6m7o9oi.fsf@nightsong.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14062&group=comp.lang.forth#14062

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: conditional parameter passing
Date: Tue, 27 Jul 2021 12:09:49 -0700
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <87a6m7o9oi.fsf@nightsong.com>
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
<sdm34a$q78$1@dont-email.me> <87mtq9nldl.fsf@nightsong.com>
<df8a9523-1dd4-415c-bee5-d669e681b0e0n@googlegroups.com>
<87im0wolcj.fsf@nightsong.com>
<3fa7328f-8593-4455-b725-91ca1a13cf84n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="34c8ffbf4e82e9645cd88e63ef307b92";
logging-data="4154"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Eu32eEfEqjNrApwRIp2M0"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:b4RnGNVyIsdleKZU8Zj1iukn5tc=
sha1:u7liaCyMj5vKnVy9X9f7VMJmH1M=
 by: Paul Rubin - Tue, 27 Jul 2021 19:09 UTC

"minf...@arcor.de" <minforth@arcor.de> writes:
>> >> (apply #'+ '(1 2 3)) => returns 6 ...
> https://dictionary.cambridge.org/de/worterbuch/englisch/tongue-in-cheek

I'm familiar with the expression, and just didn't see how it applied to
the context.

> To do that in Forth, the parser of a new word would have to evaluate
> the stack annotation as necessary part of the word definition.

No I don't think so. '(1 2 3) is a memory structure in Lisp for which
there could be a Forth equivalent, perhaps an array plus a cell
indicating its length. The Forth equivalent of APPLY would copy the
array contents onto the stack, then invoke the target word.

Re: conditional parameter passing

<61008794$0$706$14726298@news.sunsite.dk>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14063&group=comp.lang.forth#14063

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Subject: Re: conditional parameter passing
Newsgroups: comp.lang.forth
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
<sdm34a$q78$1@dont-email.me> <87mtq9nldl.fsf@nightsong.com>
<df8a9523-1dd4-415c-bee5-d669e681b0e0n@googlegroups.com>
<87im0wolcj.fsf@nightsong.com>
<3fa7328f-8593-4455-b725-91ca1a13cf84n@googlegroups.com>
From: dhoffman...@gmail.com (Doug Hoffman)
Date: Tue, 27 Jul 2021 18:24:20 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <3fa7328f-8593-4455-b725-91ca1a13cf84n@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 26
Message-ID: <61008794$0$706$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 09099da4.news.sunsite.dk
X-Trace: 1627424660 news.sunsite.dk 706 glidedog@gmail.com/68.55.82.126:50591
X-Complaints-To: staff@sunsite.dk
 by: Doug Hoffman - Tue, 27 Jul 2021 22:24 UTC

On 7/27/21 4:38 AM, minf...@arcor.de wrote:

> To do that in Forth, the parser of a new word would have to evaluate
> the stack annotation as necessary part of the word definition. Next step
> would be a syntax tree in the compiler, etc etc.
>
> It wouldn't be Forth anymore.

FMS2, ANS Forth extension. I believe it's still Forth.

-Doug

0 ' + i{ 1 2 3 4 5 } :apply . \ => 15 ok

0e ' f+ f{ 1.1 2.45 3 4.6 5 } :apply f. \ => 16.15 ok

0 ' + i{ 1 2 3
4 5 8 900 64
5 0 77 } :apply . \ => 1069 ok

[: emit space ;] s" Hello" >string :apply \ => H e l l o ok
' . s" Hello" >string :apply \ => 72 101 108 108 111 ok

Re: conditional parameter passing

<c73ccca3-23c9-4d70-bd4f-f3cb7402dbdfn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14067&group=comp.lang.forth#14067

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ae9:c316:: with SMTP id n22mr24926970qkg.481.1627454999823; Tue, 27 Jul 2021 23:49:59 -0700 (PDT)
X-Received: by 2002:a37:9543:: with SMTP id x64mr26652577qkd.217.1627454999677; Tue, 27 Jul 2021 23:49:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.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: Tue, 27 Jul 2021 23:49:59 -0700 (PDT)
In-Reply-To: <61008794$0$706$14726298@news.sunsite.dk>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f2c:8b93:98c2:b481:9ce3:bbed; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f2c:8b93:98c2:b481:9ce3:bbed
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com> <sdm34a$q78$1@dont-email.me> <87mtq9nldl.fsf@nightsong.com> <df8a9523-1dd4-415c-bee5-d669e681b0e0n@googlegroups.com> <87im0wolcj.fsf@nightsong.com> <3fa7328f-8593-4455-b725-91ca1a13cf84n@googlegroups.com> <61008794$0$706$14726298@news.sunsite.dk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c73ccca3-23c9-4d70-bd4f-f3cb7402dbdfn@googlegroups.com>
Subject: Re: conditional parameter passing
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 28 Jul 2021 06:49:59 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 26
 by: minf...@arcor.de - Wed, 28 Jul 2021 06:49 UTC

Doug Hoffman schrieb am Mittwoch, 28. Juli 2021 um 00:24:22 UTC+2:
> On 7/27/21 4:38 AM, minf...@arcor.de wrote:
>
> > To do that in Forth, the parser of a new word would have to evaluate
> > the stack annotation as necessary part of the word definition. Next step
> > would be a syntax tree in the compiler, etc etc.
> >
> > It wouldn't be Forth anymore.
> FMS2, ANS Forth extension. I believe it's still Forth.
>
> -Doug
>
>
> 0 ' + i{ 1 2 3 4 5 } :apply . \ => 15 ok
>
> 0e ' f+ f{ 1.1 2.45 3 4.6 5 } :apply f. \ => 16.15 ok
>
> 0 ' + i{ 1 2 3
> 4 5 8 900 64
> 5 0 77 } :apply . \ => 1069 ok
>
>
> [: emit space ;] s" Hello" >string :apply \ => H e l l o ok
> ' . s" Hello" >string :apply \ => 72 101 108 108 111 ok

Neat. But I guess that there is no compile-time check,
:apply will eat anything thrown to it.

Re: conditional parameter passing

<61012ed3$0$705$14726298@news.sunsite.dk>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14069&group=comp.lang.forth#14069

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Subject: Re: conditional parameter passing
Newsgroups: comp.lang.forth
References: <sdim55$n0v$1@dont-email.me> <87r1fnnd0r.fsf@nightsong.com>
<sdm34a$q78$1@dont-email.me> <87mtq9nldl.fsf@nightsong.com>
<df8a9523-1dd4-415c-bee5-d669e681b0e0n@googlegroups.com>
<87im0wolcj.fsf@nightsong.com>
<3fa7328f-8593-4455-b725-91ca1a13cf84n@googlegroups.com>
<61008794$0$706$14726298@news.sunsite.dk>
<c73ccca3-23c9-4d70-bd4f-f3cb7402dbdfn@googlegroups.com>
From: dhoffman...@gmail.com (Doug Hoffman)
Date: Wed, 28 Jul 2021 06:17:51 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <c73ccca3-23c9-4d70-bd4f-f3cb7402dbdfn@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 26
Message-ID: <61012ed3$0$705$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 3148dc49.news.sunsite.dk
X-Trace: 1627467475 news.sunsite.dk 705 glidedog@gmail.com/68.55.82.126:50914
X-Complaints-To: staff@sunsite.dk
 by: Doug Hoffman - Wed, 28 Jul 2021 10:17 UTC

On 7/28/21 2:49 AM, minf...@arcor.de wrote:
> Doug Hoffman schrieb am Mittwoch, 28. Juli 2021 um 00:24:22 UTC+2:

>> FMS2, ANS Forth extension. I believe it's still Forth.
....
>> 0 ' + i{ 1 2 3 4 5 } :apply . \ => 15 ok
....
>> ' . s" Hello" >string :apply \ => 72 101 108 108 111 ok

> Neat. But I guess that there is no compile-time check,
> :apply will eat anything thrown to it.

Not anything. :apply must receive an object that responds to the :each
iterator message. If it isn't an object it will crash. If the object
doesn't know :each it will say "message not understood".

Oforth does it the same way, but is cleaner IMO:

0 #+ [ 1, 2, 3, 4, 5 ] apply . \ => 15 ok
0 #+ [ 1.1, 2.45, 3, 4.6, 5 ] apply . \ => 16.15
#[ emit 32 emit ] "Hello" apply \ => H e l l o ok
#[ . ] "Hello" apply \ => 72 101 108 108 111 ok

-Doug

Pages:12
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor