Re: [stack] comments - 1 (inlining)

stevan apter — 2000-07-06 10:54:08

----- Original Message -----
From: <phimvt@...>
To: <concatenative@egroups.com>
Sent: Thursday, July 06, 2000 12:51 AM
Subject: [stack] comments - 1


> 3. Inlining
> There was some good discussion on the cost and benefits of inlining.
> In the prototype I was not concerned with efficiency. But a future Joy
> might well have two kinds of definitions:
> square == dup * ;
> cube =inline= dup dup * * ;
> or something like that. Any thoughts?

hi manfred - welcome back.

in conk, i use 'set' for this purpose:

3 "cube" [dup dup * *] set
`cube
i
27

set takes a string and a list and returns a bare function, denoted by the
leading backtick.

if cube existed at definition-time, then

3 cube [dup dup * *] set

would cause it to consume the value 3 on the stack, and the definition
would fail.

'set' is also useful to turn system variables on and off:

"T" 1 set (* turn trace on *)
`T
1 2 3 4 + * +
`T
`T 1
`T 1 2
`T 1 2 3
`T 1 2 3 4
`T 1 2 7
`T 1 14
`T 15